Basic config system from a json file but it's got serious issues. Can't copy construct it because of the variable blocking copying, and it can't even be put into the dinkyecs in any way.

This commit is contained in:
Zed A. Shaw 2024-11-02 21:14:58 -04:00
parent 24b1e4a500
commit 0ba789697a
7 changed files with 93 additions and 5 deletions

15
config.cpp Normal file
View file

@ -0,0 +1,15 @@
#include "config.hpp"
Config::Config(const std::string src_path) : $src_path(src_path) {
std::ifstream infile($src_path);
$config = json::parse(infile);
}
json &Config::operator[](const std::string &key) {
return $config[key];
}
std::wstring Config::wstring(const std::string main_key, const std::string sub_key) {
const std::string& str_val = $config[main_key][sub_key];
return $converter.from_bytes(str_val);
}