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:
parent
24b1e4a500
commit
0ba789697a
7 changed files with 93 additions and 5 deletions
15
config.cpp
Normal file
15
config.cpp
Normal 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);
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue