DSL
DB_SQLite.h
1 //@AUTOHEADER@BEGIN@
2 /***********************************************************************\
3 | Drift Standard Libraries v1.01 |
4 | Copyright 2010-2023 Drift Solutions / Indy Sams |
5 | Docs and more information available at https://www.driftsolutions.dev |
6 | This file released under the 3-clause BSD license, |
7 | see included DSL.LICENSE.TXT file for details. |
8 \***********************************************************************/
9 //@AUTOHEADER@END@
10 
11 #ifndef _INCLUDE_SQLITECONX_H_
12 #define _INCLUDE_SQLITECONX_H_
13 
14 #include <drift/DB_Common.h>
15 #include <sqlite3.h>
16 
17 #if defined(DSL_DLL) && defined(WIN32)
18  #if defined(DSL_SQLITE_EXPORTS)
19  #define DSL_SQLITE_API extern "C" __declspec(dllexport)
20  #define DSL_SQLITE_API_CLASS __declspec(dllexport)
21  #else
22  #define DSL_SQLITE_API extern "C" __declspec(dllimport)
23  #define DSL_SQLITE_API_CLASS __declspec(dllimport)
24  #endif
25 #else
26  #define DSL_SQLITE_API DSL_API_VIS
27  #define DSL_SQLITE_API_CLASS DSL_API_VIS
28 #endif
29 
30 class DSL_SQLITE_API_CLASS SQLite_Result {
31 public:
32  size_t ind = 0;
33  vector<SC_Row> rows;
34 };
35 
36 class DSL_SQLITE_API_CLASS DB_SQLite: public SQLConx {
37 public:
38  DB_SQLite();
39  ~DB_SQLite();
40 
41  bool Open(const string& filename);
42  bool OpenV2(const string& filename, int flags, const string& vfs="");
43  bool IsOpen();
44  void Close();
45 
46  string GetErrorString();
47  int GetError();
48 
49  bool NoResultQuery(const string& query);
50  SQLite_Result * Query(const string& query);
51  size_t NumRows(SQLite_Result *result);
52  bool FetchRow(SQLite_Result *result, SC_Row& retRow);
53  bool FreeResult(SQLite_Result *result);
54 
55  uint32_t InsertID();
56  int64_t InsertID64();
57  int AffectedRows();
58  uint32_t GetQueryCount();
59 
60  string EscapeString(const string& str);
61  string MPrintf(const char * str, ...);
62  sqlite3 * GetHandle();
63 
64  SQLConxMulti * MultiStart();
65  bool MultiSend(SQLConxMulti *);
66  bool MultiEnd(SQLConxMulti *);
67 
68 private:
69  sqlite3 * handle;
70  uint32_t query_count = 0;
71 };
72 
73 #endif //_INCLUDE_SQLITECONX_H_
Definition: DB_SQLite.h:36
Definition: DB_Common.h:14
Definition: DB_Common.h:26
Definition: DB_Common.h:36
Definition: DB_SQLite.h:30