aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/DB.h
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-27 19:33:45 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-27 19:33:45 +0100
commitb2fc208fbdb55ecc3cba59e2dd51976ce829a4be (patch)
tree1a60e74b7533403831868b04943978987cec2c75 /src/crepe/DB.h
parentecc5761fa78ccb57db958467c3fc999aceadd409 (diff)
WIP db facade
Diffstat (limited to 'src/crepe/DB.h')
-rw-r--r--src/crepe/DB.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/crepe/DB.h b/src/crepe/DB.h
new file mode 100644
index 0000000..010ef42
--- /dev/null
+++ b/src/crepe/DB.h
@@ -0,0 +1,34 @@
+#pragma once
+
+#include <string>
+#include <functional>
+#include <memory>
+
+namespace libdb {
+extern "C" {
+#include <db.h>
+}
+}
+
+namespace crepe {
+
+class DB {
+public:
+ DB(const char * path);
+ virtual ~DB() = default;
+
+public:
+ std::string get(const std::string & key);
+ void set(const std::string & key, const std::string & value);
+ bool has(const std::string & key);
+
+private:
+ std::unique_ptr<libdb::DB, std::function<void(libdb::DB *)>> db;
+ std::unique_ptr<libdb::DBC, std::function<void(libdb::DBC *)>> cursor;
+
+private:
+ libdb::DBT to_thing(const std::string & thing);
+};
+
+}
+