ip_allow_
[ghsmtp.git] / CDB.hpp
blobab437c8ab538d7cda872d7a41f3f0fb95642c7a4
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 constexpr bool is_open() const;
28 private:
29 int fd_{-1};
30 cdb cdb_{0};
33 constexpr bool CDB::is_open() const { return fd_ != -1; }
35 #endif // CDB_DOT_HPP