-
Notifications
You must be signed in to change notification settings - Fork 1
/
SQLiteDatabase.hpp
48 lines (38 loc) · 1.23 KB
/
SQLiteDatabase.hpp
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
// SQLiteDatabase.hpp
// AmiKo-wx
//
// Created by Alex Bettarini on 16 Jun 2020
// Copyright © 2020 Ywesee GmbH. All rights reserved.
#pragma once
#include <wx/wx.h>
#include <sqlite3.h>
// TODO wxVector<wxVariant>
#define ONE_SQL_RESULT std::vector<struct myStruct>
#define ALL_SQL_RESULTS std::vector<ONE_SQL_RESULT>
union myType { // only simple types allowed
char *c;
int i;
double d;
};
struct myStruct {
int type;
union myType u;
myStruct() {u.c = nullptr;} // constructor
};
class SQLiteDatabase
{
public:
SQLiteDatabase();
virtual ~SQLiteDatabase() {}
void initReadOnlyWithPath(wxString path);
void initReadWriteWithPath(wxString path);
bool createWithPath_andTable_andColumns(wxString path, wxString table, wxString columns);
ALL_SQL_RESULTS performQuery(wxString query);
int numberRecordsForTable(wxString table);
bool insertRowIntoTable_forColumns_andValues(wxString table, wxString columns, wxString values);
bool updateRowIntoTable_forExpressions_andConditions(wxString table, wxString expressions, wxString conditions);
bool deleteRowFromTable_withUId(wxString table, wxString uId);
void close();
private:
sqlite3 *database;
};