aboutsummaryrefslogtreecommitdiff
path: root/frontend/DB.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 01:29:58 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-30 01:29:58 +0100
commitb9e738502260b8f448289c9888203971c7749c76 (patch)
tree09477251ba49307173a112e0cd5dbdd3633346ce /frontend/DB.h
parente4261302944303781c952943e3290c99e2cabc52 (diff)
WIP SQL gedoe
Diffstat (limited to 'frontend/DB.h')
-rw-r--r--frontend/DB.h26
1 files changed, 22 insertions, 4 deletions
diff --git a/frontend/DB.h b/frontend/DB.h
index b464f9f..5c88940 100644
--- a/frontend/DB.h
+++ b/frontend/DB.h
@@ -4,15 +4,33 @@
#include <functional>
#include <sqlite3.h>
+class DB;
+
+class DBStatement {
+ std::unique_ptr<sqlite3_stmt, std::function<void(sqlite3_stmt*)>> stmt;
+public:
+ DBStatement(DB &, const std::string & query);
+
+public:
+ DBStatement & unbind();
+ DBStatement & bind(const std::string & text);
+ DBStatement & bind(const int & number);
+public:
+ void execute();
+
+private:
+ int param_index = 1;
+ DB & db;
+};
+
class DB {
- typedef std::unique_ptr<sqlite3, std::function<void(sqlite3*)>> unique_sqlite3;
- typedef std::unique_ptr<sqlite3_stmt, std::function<void(sqlite3_stmt*)>> unique_sqlite3_stmt;
+ friend class DBStatement;
public:
DB(const std::string & path);
- unique_sqlite3_stmt prepare(const std::string & query);
+ DBStatement prepare(const std::string & query);
private:
- unique_sqlite3 db = NULL;
+ std::unique_ptr<sqlite3, std::function<void(sqlite3*)>> db = NULL;
};