Quick refactor of the config system to make it easier to refactor config.cpp/hpp later.
This commit is contained in:
parent
47f659ae8e
commit
e523aa8b02
29 changed files with 138 additions and 140 deletions
34
config.hpp
34
config.hpp
|
|
@ -4,22 +4,26 @@
|
|||
#include <codecvt>
|
||||
#include <filesystem>
|
||||
|
||||
struct Config {
|
||||
static std::filesystem::path BASE_DIR;
|
||||
nlohmann::json $config;
|
||||
std::string $src_path;
|
||||
namespace settings {
|
||||
struct Config {
|
||||
static std::filesystem::path BASE_DIR;
|
||||
nlohmann::json $config;
|
||||
std::string $src_path;
|
||||
|
||||
Config(const std::string src_path);
|
||||
Config(const std::string src_path);
|
||||
|
||||
Config(nlohmann::json config, std::string src_path)
|
||||
: $config(config), $src_path(src_path) {}
|
||||
Config(nlohmann::json config, std::string src_path)
|
||||
: $config(config), $src_path(src_path) {}
|
||||
|
||||
nlohmann::json &operator[](size_t);
|
||||
nlohmann::json &operator[](const std::string &key);
|
||||
nlohmann::json &json() { return $config; };
|
||||
std::wstring wstring(const std::string main_key, const std::string sub_key);
|
||||
std::vector<std::string> keys();
|
||||
nlohmann::json &operator[](size_t);
|
||||
nlohmann::json &operator[](const std::string &key);
|
||||
nlohmann::json &json() { return $config; };
|
||||
std::wstring wstring(const std::string main_key, const std::string sub_key);
|
||||
std::vector<std::string> keys();
|
||||
|
||||
static void set_base_dir(const char *optarg);
|
||||
static std::filesystem::path path_to(const std::string& path);
|
||||
};
|
||||
static void set_base_dir(const char *optarg);
|
||||
static std::filesystem::path path_to(const std::string& path);
|
||||
};
|
||||
|
||||
Config get(const std::string &name);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue