added ConfigVersion

This commit is contained in:
badaix 2016-03-08 08:33:35 +01:00
parent ca3a12a8d4
commit 5951c123c9

View file

@ -48,6 +48,8 @@ Config::Config()
{ {
json j; json j;
ifs >> j; ifs >> j;
if (j.count("ConfigVersion"))
{
json jClient = j["Client"]; json jClient = j["Client"];
for (json::iterator it = jClient.begin(); it != jClient.end(); ++it) for (json::iterator it = jClient.begin(); it != jClient.end(); ++it)
{ {
@ -55,7 +57,8 @@ Config::Config()
client->fromJson(*it); client->fromJson(*it);
client->connected = false; client->connected = false;
clients.push_back(client); clients.push_back(client);
// logO << "Client:\n" << std::setw(4) << client->toJson() << '\n'; // logO << "Client:\n" << std::setw(4) << client->toJson() << '\n';
}
} }
} }
} }
@ -70,6 +73,7 @@ void Config::save()
{ {
std::ofstream ofs(filename_.c_str(), std::ofstream::out|std::ofstream::trunc); std::ofstream ofs(filename_.c_str(), std::ofstream::out|std::ofstream::trunc);
json clients = { json clients = {
{"ConfigVersion", 1},
{"Client", getClientInfos()} {"Client", getClientInfos()}
}; };
ofs << std::setw(4) << clients; ofs << std::setw(4) << clients;