⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdbquery.h

📁 一个自行开发的内存数据管理的包
💻 H
字号:
#ifndef __MdbQuery_h__
#define __MdbQuery_h__

#include <list>
#include <new>
#include "Exception.h"
#include "MdbDict.h"
#include "MdbTbl.h"
#include "MdbHtIndex.h"

using namespace std;

class CMDatabase;

class CMdbQuery:public CRowSet
{
friend class CMDatabase;
protected:
class CMdbField:public CRowSet::CField
{
public:
CMdbField(CMdbQuery &cMdbQuery):m_cMdbQuery(cMdbQuery) {}
void setFieldName(const char *szFieldName) { m_szFieldName =  szFieldName; }
virtual operator char();
virtual operator unsigned char();
virtual operator short();
virtual operator unsigned short();
virtual operator int();
virtual operator unsigned int();
virtual operator long();
virtual operator unsigned long();
virtual operator long long();
virtual operator unsigned long long();
virtual operator const char *();
virtual void operator=(char nVal);
virtual void operator=(unsigned char nVal);
virtual void operator=(short nVal);
virtual void operator=(unsigned short nVal);
virtual void operator=(int  nVal);
virtual void operator=(unsigned int  nVal);
virtual void operator=(long nVal);
virtual void operator=(unsigned long nVal);
virtual void operator=(long long nVal);
virtual void operator=(unsigned long long nVal);
virtual void operator=(const char *pVal);
private: 
CMdbQuery &m_cMdbQuery;
const char *m_szFieldName;
};
public:
CMdbQuery(MALLOC *pcAlloc,ACE_Process_Mutex *pcLatch,CMdbDict *pcDbDict,int nMyPid,const char *szTableName,int nFieldCnt,const char **szFieldNames,int *pnFieldTypes,void **ppVals,bool bUpdate);  //查询/查询更改构造函数
CMdbQuery(MALLOC *pcAlloc,ACE_Process_Mutex *pcLatch,CMdbDict *pcDbDict,int nMyPid,SCreateTblPara *psCreateTblPara,SCreateIdxesPara *psCreateIdxesPara);   //建表构造函数
CMdbQuery(MALLOC *pcAlloc,ACE_Process_Mutex *pcLatch,CMdbDict *pcDbDict,int nMyPid,const char *szTableName);   //删表构造函数
virtual void 	destroy();
virtual void 	resetRec(){ m_psCurRecord = m_ppsRecords.end(); }
virtual bool 	nextRec();
virtual bool 	prevRec();
virtual void 	clear();
virtual void  	deleteRec();
virtual void  	createRec();
virtual CField &  operator[](const char *szFieldName) { m_cMdbField.setFieldName(szFieldName); return m_cMdbField;}
void  setFieldValByName(const char *szFieldName,int nFieldType,const void *pVal);
void  getFieldValByName(const char *szFieldName,int nFieldType,void *pVal);
void  setFieldValByIndex(int nFieldIndex,int nFieldType,const void *pVal);
void  getFieldValByIndex(int nFieldIndex,int nFieldType,void *pVal);
int   getColCnt() { return m_psTblMeta->m_nColCnt; }
private:
CMdbQuery();      //阻止使用缺省构造函数
virtual ~CMdbQuery() {}   //阻止栈上创建对象
CMdbQuery(const CMdbQuery & cMdbQuery);  //阻止拷贝构造函数
void operator=(const CMdbQuery & cMdbQuery); //阻止赋值函数
void operator delete(void *p) { ::operator delete(p); }  //阻止外部动态删除对象
inline void cleanUp();

void  updateIndex(CMdbTbl *pcMdbTbl,const char *szFieldName,int nFieldType,const void *pVal);
void  latchLock();
void  latchUnLock();
bool  ownerTable();
void  unOwnerTable();
CProcNode  *shareTable();
//bool  shareTable();
void  unShareTable();
void  ownerTableMeta(const char *szTableName);
void  shareTableMeta(const char *szTableName);
void  unOwnerTableMeta();
void  unShareTableMeta();
void  deleteTableMeta(const char *szTableName);
void  insertTableMeta(SCreateTblPara *psCreateTblPara,SCreateIdxesPara *psCreateIdxesPara);
private:
list<CRecordNode *> m_ppsRecords;
MALLOC *m_pcAlloc;
ACE_Process_Mutex *m_pcLatch;
CMdbDict *m_pcDbDict;
CDbTableMeta *m_psTblMeta;
typedef list<CRecordNode *>::iterator CListIter;
CListIter m_psCurRecord;
CMdbField m_cMdbField;
pid_t m_nMyPid;
CProcNode *m_psSharePid;
bool  m_bUpdate;
};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -