diff options
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 |
