summaryrefslogtreecommitdiff
path: root/src/cfg.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/cfg.hh')
-rw-r--r--src/cfg.hh40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/cfg.hh b/src/cfg.hh
new file mode 100644
index 0000000..a4a7865
--- /dev/null
+++ b/src/cfg.hh
@@ -0,0 +1,40 @@
+#ifndef CFG_HH
+#define CFG_HH
+
+#include <memory>
+#include <optional>
+#include <string_view>
+#include <vector>
+
+namespace cfg {
+
+class Config {
+ public:
+ virtual ~Config() = default;
+
+ [[nodiscard]]
+ virtual std::optional<std::string_view> get(std::string_view name) const = 0;
+
+ [[nodiscard]]
+ bool has(std::string_view name) const;
+ [[nodiscard]]
+ std::optional<int64_t> get_int64(std::string_view name) const;
+ [[nodiscard]]
+ std::optional<uint64_t> get_uint64(std::string_view name) const;
+ [[nodiscard]]
+ std::optional<bool> get_bool(std::string_view name) const;
+
+ [[nodiscard]]
+ static std::unique_ptr<Config> load(std::string_view name,
+ std::vector<std::string>& errors);
+
+ protected:
+ Config() = default;
+
+ Config(Config const&) = delete;
+ Config& operator=(Config const&) = delete;
+};
+
+} // namespace cfg
+
+#endif // CFG_HH