Add method write() to Config.

This commit is contained in:
tastytea 2019-12-25 06:25:11 +01:00
parent 8a0c69b1e8
commit ed14492b46
Signed by: tastytea
GPG Key ID: CFC39497F1B26E07
2 changed files with 15 additions and 7 deletions

View File

@ -167,13 +167,8 @@ void Config::generate()
newjson[_profile]["max_size"] = std::stoul(line);
_json = newjson;
ofstream file{get_filename()};
if (file.good())
{
file << newjson.toStyledString();
}
BOOST_LOG_TRIVIAL(debug) << "Wrote config file.";
BOOST_LOG_TRIVIAL(debug) << "Generated configuration.";
write();
}
string Config::get_access_token(const string &instance) const
@ -242,4 +237,15 @@ void Config::parse()
BOOST_LOG_TRIVIAL(debug) << "Read config: " << data;
}
void Config::write() const
{
ofstream file{get_filename()};
if (file.good())
{
file << _json.toStyledString();
}
BOOST_LOG_TRIVIAL(debug) << "Wrote config file.";
}
} // namespace mastorss

View File

@ -68,6 +68,8 @@ public:
ProfileData data;
void write() const;
private:
const string _profile;
Json::Value _json;