diff options
| author | Joel Klinghed <the_jk@spawned.biz> | 2025-10-07 21:46:03 +0200 |
|---|---|---|
| committer | Joel Klinghed <the_jk@spawned.biz> | 2025-10-19 00:13:47 +0200 |
| commit | 3a002fb9c23fc9a6384bc1b30a8e364924bb574e (patch) | |
| tree | 7cfb59964bc20bbb14d157426b2aad4481deb90d /src/cfg.hh | |
| parent | 62a4abb9bf6551417130c3c6f9bba147930895ef (diff) | |
cfg: Make load less magic
Don't try to guess from name, instead, have one method for only
loading one config from a file (that might be relative) and loading
a config from config dirs using a name (that might contain slash).
Diffstat (limited to 'src/cfg.hh')
| -rw-r--r-- | src/cfg.hh | 13 |
1 files changed, 9 insertions, 4 deletions
@@ -1,6 +1,7 @@ #ifndef CFG_HH #define CFG_HH +#include <filesystem> #include <memory> #include <optional> #include <string_view> @@ -24,10 +25,6 @@ class Config { [[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; @@ -35,6 +32,14 @@ class Config { 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 |
