2,新增“Apps”; 3,新增“Common”; 4,新增“FileList”; 5,新增“MediaX”; 6,新增“OpenSource”; 7,新增“Samples”; 8,新增“SoftwareBusinessLines”.
81 lines
1.6 KiB
C++
81 lines
1.6 KiB
C++
#ifndef _GdSQLite3_H_
|
|
#define _GdSQLite3_H_
|
|
|
|
#include <QString>
|
|
#include <QVariant>
|
|
|
|
#include <thread>
|
|
#include <chrono>
|
|
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_
|