#ifndef _GdSQLite3_H_ #define _GdSQLite3_H_ #include #include #include #include using namespace std; #include "./include/SQLite3/sqlite3.h" /* * 基础数据库类 */ class GdSQLite3 { friend class GdSQLite3RecordSet; public: GdSQLite3(); ~GdSQLite3(); // bool OpenDB(const QString& strDBName); void CloseDB(); bool IsOpen(); bool Execute(const QString& strSQL); // bool QueryAllTableInfo(QString& strResult, const QString& strTable); protected: sqlite3* GetDB(); private: static int CallBack_Execute(void* pOwner, int nColCount, char** lpszValue, char** lpszColName); int DoExecute(int nColCount, char** lpszValue, char** lpszColName); private: bool EgTransaction(); private: sqlite3* m_pDB; bool m_bOpen; QString m_strDBName; QString m_strLastQueryResult; }; /* * 数据集类 */ class GdSQLite3RecordSet { public: enum eDataType { eDT_Int = 1, eDT_Int64 = 2, eDT_Double = 3, eDT_Text = 4, eDT_Blob = 5, }; GdSQLite3RecordSet(GdSQLite3* pGdSQLite3); ~GdSQLite3RecordSet(); bool Open(const QString& strQuerySQL); void Close(); bool Next(); bool GetValue(QVariant& varVal, int nCol, GdSQLite3RecordSet::eDataType eDT); private: GdSQLite3* m_pGdSQLite3; sqlite3_stmt* m_pStmt; bool m_bOpen; bool m_bValueReady; }; #endif // _GdSQLite3_H_