diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-27 19:33:45 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-10-27 19:33:45 +0100 |
commit | b2fc208fbdb55ecc3cba59e2dd51976ce829a4be (patch) | |
tree | 1a60e74b7533403831868b04943978987cec2c75 /src/crepe/DB.h | |
parent | ecc5761fa78ccb57db958467c3fc999aceadd409 (diff) |
WIP db facade
Diffstat (limited to 'src/crepe/DB.h')
-rw-r--r-- | src/crepe/DB.h | 34 |
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); +}; + +} + |