From 62a4abb9bf6551417130c3c6f9bba147930895ef Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 7 Oct 2025 20:56:33 +0200 Subject: cfg: New module Reads config files --- src/cfg.hh | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 src/cfg.hh (limited to 'src/cfg.hh') 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 +#include +#include +#include + +namespace cfg { + +class Config { + public: + virtual ~Config() = default; + + [[nodiscard]] + virtual std::optional get(std::string_view name) const = 0; + + [[nodiscard]] + bool has(std::string_view name) const; + [[nodiscard]] + std::optional get_int64(std::string_view name) const; + [[nodiscard]] + std::optional get_uint64(std::string_view name) const; + [[nodiscard]] + std::optional get_bool(std::string_view name) const; + + [[nodiscard]] + static std::unique_ptr load(std::string_view name, + std::vector& errors); + + protected: + Config() = default; + + Config(Config const&) = delete; + Config& operator=(Config const&) = delete; +}; + +} // namespace cfg + +#endif // CFG_HH -- cgit v1.2.3-70-g09d2