diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-10-07 20:56:33 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-10-19 00:13:47 +0200 |
| commit | 62a4abb9bf6551417130c3c6f9bba147930895ef (patch) | |
| tree | 51c6359faa7193e82c6fa8ee5402edb24d450ab1 /src/cfg.hh | |
| parent | 4f6e76493fb74f5385d5a14dce3a01c9901802ed (diff) | |
cfg: New module
Reads config files
Diffstat (limited to 'src/cfg.hh')
| -rw-r--r-- | src/cfg.hh | 40 |
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 |
