48 lines
1.0 KiB
C++
48 lines
1.0 KiB
C++
#include "Configuration.hpp"
|
|
|
|
Configuration::Configuration(Node *parent) : Configuration(parent, "config") {}
|
|
|
|
Configuration::Configuration(Node *parent, fs::path path) : Node(parent)
|
|
{
|
|
std::cout << "Constructing Configuration with parent " << parent <<
|
|
" and path " << path << std::endl;
|
|
config_path = path;
|
|
set_defaults();
|
|
load();
|
|
}
|
|
|
|
void Configuration::set_defaults()
|
|
{
|
|
sys_config["keys"] = {
|
|
{"record", {"CTRL", "SHIFT", "F10"}},
|
|
{"screenshot", "F9"}
|
|
};
|
|
}
|
|
|
|
void Configuration::load()
|
|
{
|
|
load(config_path);
|
|
}
|
|
|
|
void Configuration::load(fs::path path)
|
|
{
|
|
std::ifstream contents(path);
|
|
contents >> config;
|
|
config["blob"] = false;
|
|
config["slime"][1] = {420, 69};
|
|
config["goo"] = "yum";
|
|
std::cout << std::setw(4) << config << std::endl;
|
|
std::cout << std::setw(4) << sys_config << std::endl;
|
|
}
|
|
|
|
void Configuration::write()
|
|
{
|
|
write(config_path);
|
|
}
|
|
|
|
void Configuration::write(fs::path path)
|
|
{
|
|
std::ofstream output(path);
|
|
output << std::setw(tab_width) << config << std::endl;
|
|
}
|