From 3a002fb9c23fc9a6384bc1b30a8e364924bb574e Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Tue, 7 Oct 2025 21:46:03 +0200 Subject: 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). --- src/cfg.hh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'src/cfg.hh') diff --git a/src/cfg.hh b/src/cfg.hh index a4a7865..3be9a00 100644 --- a/src/cfg.hh +++ b/src/cfg.hh @@ -1,6 +1,7 @@ #ifndef CFG_HH #define CFG_HH +#include #include #include #include @@ -24,10 +25,6 @@ class Config { [[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; @@ -35,6 +32,14 @@ class Config { Config& operator=(Config const&) = delete; }; +[[nodiscard]] +std::unique_ptr load_all(std::string_view name, + std::vector& errors); + +[[nodiscard]] +std::unique_ptr load_one(std::filesystem::path const& path, + std::vector& errors); + } // namespace cfg #endif // CFG_HH -- cgit v1.2.3-70-g09d2