00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef _INCLUDE_SQLITECONX_H_
00012 #define _INCLUDE_SQLITECONX_H_
00013
00014 #include <drift/DB_Common.h>
00015 #include <sqlite3.h>
00016
00017 #if defined(DSL_DLL) && defined(WIN32)
00018 #if defined(DSL_SQLITE_EXPORTS)
00019 #define DSL_SQLITE_API extern "C" __declspec(dllexport)
00020 #define DSL_SQLITE_API_CLASS __declspec(dllexport)
00021 #else
00022 #define DSL_SQLITE_API extern "C" __declspec(dllimport)
00023 #define DSL_SQLITE_API_CLASS __declspec(dllimport)
00024 #endif
00025 #else
00026 #define DSL_SQLITE_API
00027 #define DSL_SQLITE_API_CLASS
00028 #endif
00029
00030 class DSL_SQLITE_API_CLASS SQLite_Result {
00031 public:
00032 size_t ind = 0;
00033 vector<SC_Row> rows;
00034 };
00035
00036 class DSL_SQLITE_API_CLASS DB_SQLite: public SQLConx {
00037 public:
00038 DB_SQLite();
00039 ~DB_SQLite();
00040
00041 bool Open(std::string filename);
00042 bool IsOpen();
00043 void Close();
00044
00045 std::string GetErrorString();
00046 int GetError();
00047
00048 SQLite_Result * Query(std::string query, uint32_t len = 0);
00049 size_t NumRows(SQLite_Result *result);
00050 bool FetchRow(SQLite_Result *result, SC_Row& retRow);
00051 bool FreeResult(SQLite_Result *result);
00052
00053 uint32_t InsertID();
00054 int64_t InsertID64();
00055 int AffectedRows();
00056 uint32_t GetQueryCount();
00057
00058 std::string EscapeString(std::string str);
00059 std::string MPrintf(const char * str, ...);
00060 sqlite3 * GetHandle();
00061
00062 SQLConxMulti * MultiStart();
00063 bool MultiSend(SQLConxMulti *);
00064 bool MultiEnd(SQLConxMulti *);
00065 void SCM_Query(std::string query, uint32_t len = 0);
00066
00067 private:
00068 sqlite3 * handle;
00069 uint32_t query_count = 0;
00070 };
00071
00072 #endif //_INCLUDE_SQLITECONX_H_