| | |
| | | {
|
| | | }
|
| | |
|
| | | AppConfig::AppConfig(string path)
|
| | | {
|
| | | loadConfig(path);
|
| | | }
|
| | |
|
| | | AppConfig::~AppConfig()
|
| | | {
|
| | | }
|
| | |
| | | void AppConfig::loadConfig(string path)
|
| | | {
|
| | | fstream fs(path);
|
| | | if (!fs.is_open()) {
|
| | | if (!fs.is_open())
|
| | | {
|
| | | save(path);
|
| | | return;
|
| | | }
|
| | | Json::CharReaderBuilder builder;
|
| | | auto reader = builder.newCharReader();
|
| | | JSONCPP_STRING doc; |
| | | std::getline(fs, doc, (char)EOF);
|
| | | JSONCPP_STRING doc;
|
| | | std::getline(fs, doc, (char) EOF);
|
| | | reader->parse(doc.data(), doc.data() + doc.size(), &root, false);
|
| | | }
|
| | |
|
| | | void AppConfig::save(string path)
|
| | | {
|
| | | ofstream ofs(path);
|
| | | ofs << root.toStyledString();
|
| | | ofs.close();
|
| | | }
|
| | | void AppConfig::clear(){
|
| | |
|
| | | void AppConfig::clear()
|
| | | {
|
| | | root.clear();
|
| | | }
|