My Project
ICRecordSet.h
1 #pragma once
2 #include "SQLStatement.h"
3 struct sqlite3_stmt;
4 struct sqlite3;
5 
6 namespace ParaInfoCenter
7 {
8  class CICDBManager;
9  class DBEntity;
10 
12  class PE_CORE_DECL CICRecordSetItem
13  {
14  public:
15  enum IC_DATA_TYPE{
16  _NONE,_INT,_FLOAT, _INT64,_TEXT,_TEXT16,_BLOB
17  };
18  //they will return 0 or NULL if the index is not valid
19  //you can get data of the same item several times without any performance penalty
20  operator int();
21  operator bool();
22  operator DWORD();
23  operator int64();
24  operator char*();
25  operator char16_t*();
26  operator void*();
27  operator double();
28  operator float();
29  const char *GetNameA();
30  const char16_t *GetName();
31  CICRecordSetItem(int index,sqlite3_stmt *stmt);
33  CICRecordSetItem& operator =(const CICRecordSetItem&);
34  CICRecordSetItem& operator =(const int&);
35  CICRecordSetItem& operator =(const int64&);
36  CICRecordSetItem& operator =(const bool&);
37  CICRecordSetItem& operator =(const double&);
38  CICRecordSetItem& operator =(const float&);
39  CICRecordSetItem& operator =(const char*);
40  CICRecordSetItem& operator =(const char16_t*);
41  void SetBlob(const void *value,int nlength);
42  friend class CICRecordSet;
47  int GetDataLength(){return m_length;};
48  protected:
49  void CleanOldData();
50  int m_index;
51  sqlite3_stmt *m_stmt;
52  bool m_needInit;
53  int m_type;
54  char *m_sName;
55  char16_t *m_wName;
56  int m_length;
57  union{
58  void *bData;
59  int iData;
60  int64 nDataInt64;
61  double fData;
62  char *sData;
63  char16_t *wData;
64  };
65  };
66 
90  class CICRecordSet : public CSQLStatement
91  {
92  friend class DBEntity;
93  public:
94  static int SOK;
95  static int SEOF;
96  static int SBOF;
100  PE_CORE_DECL CICRecordSetItem& operator[](int index);
101  PE_CORE_DECL void Initialize(sqlite3_stmt* stmt);
102  PE_CORE_DECL void Initialize(const char* sql);
103  PE_CORE_DECL void Initialize(const char16_t *sql);
104  PE_CORE_DECL void Release();
105  //return 0 means ok, otherwise sth is wrong, either eof or bof or other error
106  PE_CORE_DECL int NextRow();
107  PE_CORE_DECL int ColumnCount(){return m_columnNum;}
108  PE_CORE_DECL const char* GetColumnName(int index);
109  PE_CORE_DECL const char16_t* GetColumnName16(int index);
110 
111  PE_CORE_DECL int64 GetLastInsertRowID();
112  PE_CORE_DECL ~CICRecordSet();
113  //void operator delete(void *p);
114  protected:
115  /* CICRecordSet(sqlite3_stmt* stmt);
116  CICRecordSet(const char *sql);
117  CICRecordSet(const char16_t* sql);*/
118  CICRecordSet();
119  vector<CICRecordSetItem*> m_items;
120 
121  CICRecordSetItem* m_empty;
122  bool m_bUpdatable;
123  int m_columnNum;//number of columns in a row
124 
125  };
126 }
ParaInfoCenter::DBEntity DBEntity
database entity
Definition: ParaDatabase.h:13
data field in a record.
Definition: ICRecordSet.h:12
Definition: PEtypes.h:503
a single database file.
Definition: ICDBManager.h:39
this represents SQL statement or stored procedure.
Definition: SQLStatement.h:11
int GetDataLength()
in bytes.
Definition: ICRecordSet.h:47
CICRecordSet is both the result and wrapper of a sql statement(procedure).
Definition: ICRecordSet.h:90