not used
[ghsmtp.git] / CDB.hpp
blobd5ab2d93cc692f17db493f3fca4c0dba430bfa42
1 #ifndef CDB_DOT_HPP
2 #define CDB_DOT_HPP
4 #include <memory>
5 #include <optional>
6 #include <string>
7 #include <string_view>
9 extern "C" {
10 #include <cdb.h>
13 #include "fs.hpp"
15 class CDB {
16 public:
17 CDB(CDB const&) = delete;
18 CDB& operator=(CDB const&) = delete;
20 CDB() = default;
21 ~CDB();
23 bool open(fs::path db);
24 std::optional<std::string> find(std::string_view key);
25 bool contains(std::string_view key);
26 bool contains_lc(std::string_view key);
27 constexpr bool is_open() const;
29 private:
30 int fd_{-1};
31 cdb cdb_{0};
34 constexpr bool CDB::is_open() const { return fd_ != -1; }
36 #endif // CDB_DOT_HPP