diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2026-01-02 22:42:31 +0100 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2026-01-02 22:42:31 +0100 |
| commit | 6ed8f5151719fbc14ec0ac6d28a346d1f74cf2ca (patch) | |
| tree | ebe7588e89e1aa2ae5376acf85f3a3a7b2ec7e10 /src/cfg.hh | |
Diffstat (limited to 'src/cfg.hh')
| -rw-r--r-- | src/cfg.hh | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/src/cfg.hh b/src/cfg.hh new file mode 100644 index 0000000..3be9a00 --- /dev/null +++ b/src/cfg.hh @@ -0,0 +1,45 @@ +#ifndef CFG_HH +#define CFG_HH + +#include <filesystem> +#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; + + protected: + Config() = default; + + Config(Config const&) = delete; + Config& operator=(Config const&) = delete; +}; + +[[nodiscard]] +std::unique_ptr<Config> load_all(std::string_view name, + std::vector<std::string>& errors); + +[[nodiscard]] +std::unique_ptr<Config> load_one(std::filesystem::path const& path, + std::vector<std::string>& errors); + +} // namespace cfg + +#endif // CFG_HH |
