This repository has been archived by the owner on Feb 5, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
sqlite3helper.h
68 lines (56 loc) · 2.57 KB
/
sqlite3helper.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#ifndef SQLITE3HELPER_H
#define SQLITE3HELPER_H
#include <QSharedPointer>
#include <QString>
#include <lua.hpp>
#include <sqlite3.h>
class Sqlite3Helper
{
public:
Sqlite3Helper();
~Sqlite3Helper();
void bind(sqlite3_stmt *pVM, int nParam, const QString &sValue);
void bind(sqlite3_stmt *pVM, int nParam, const char *szValue);
void bind(sqlite3_stmt *pVM, int nParam, const int nValue);
void bind(sqlite3_stmt *pVM, int nParam, const int64_t nValue);
void bind(sqlite3_stmt *pVM, int nParam, const double dValue);
void bind(sqlite3_stmt *pVM, int nParam, const unsigned char *blobValue, int nLen);
void bindNull(sqlite3_stmt *pVM, int nParam);
int bindParameterIndex(sqlite3_stmt *pVM, const char *szParam);
void bind(sqlite3_stmt *pVM, const char *szParam, const QString &sValue);
void bind(sqlite3_stmt *pVM, const char *szParam, const char *szValue);
void bind(sqlite3_stmt *pVM, const char *szParam, const int nValue);
void bind(sqlite3_stmt *pVM, const char *szParam, const int64_t nValue);
void bind(sqlite3_stmt *pVM, const char *szParam, const double dwValue);
void bind(sqlite3_stmt *pVM, const char *szParam, const unsigned char *blobValue, int nLen);
void bindNull(sqlite3_stmt *pVM, const char *szParam);
sqlite3_stmt *compile(const QString &szSQL);
sqlite3_stmt *compile(const char *szSQL);
int execDML(const QString &szSQL);
int execDML(const char *szSQL);
int execDML(sqlite3_stmt *pVM);
int execQuery(sqlite3_stmt *pVM, bool &eof);
bool nextRow(sqlite3_stmt *pVM, bool &eof);
bool isDatabaseOpened();
bool closeDatabaseConnection();
int checkExists(const QString &field, const QString &name);
bool openDatabase(const QString &name);
bool createDatabase(const QString &name);
bool beginTransaction();
bool endTransaction();
bool rollbackTransaction();
bool vacuum();
void setLuaState(lua_State *L);
void bindCustomFunctions();
void setRegexpPattern(const QString &pattern);
static void levelGlob(sqlite3_context *ctx, int /*argc*/, sqlite3_value **argv);
static void luaMatch(sqlite3_context *ctx, int /*argc*/, sqlite3_value **argv);
static void qtRegexp(sqlite3_context *ctx, int /*argc*/, sqlite3_value **argv);
private:
sqlite3 * m_db;
static lua_State * g_L;
QString m_dbFile;
QRegularExpression m_regexp;
};
typedef QSharedPointer<Sqlite3Helper> Sqlite3HelperPtr;
#endif // SQLITE3HELPER_H