forked from mia/Aegisub
Remove a write-only variable in option.cpp
Originally committed to SVN as r5453.
This commit is contained in:
parent
6ec63cdde1
commit
b25066e3c3
1 changed files with 19 additions and 28 deletions
|
@ -112,40 +112,31 @@ OptionValue* Options::Get(const std::string &name) {
|
||||||
|
|
||||||
|
|
||||||
void Options::Flush() {
|
void Options::Flush() {
|
||||||
|
|
||||||
json::Object obj_out;
|
json::Object obj_out;
|
||||||
|
|
||||||
bool ok;
|
|
||||||
|
|
||||||
for (OptionValueMap::const_iterator i = values.begin(); i != values.end(); ++i) {
|
for (OptionValueMap::const_iterator i = values.begin(); i != values.end(); ++i) {
|
||||||
|
|
||||||
std::string key = i->first.substr(i->first.rfind("/")+1, i->first.size());
|
std::string key = i->first.substr(i->first.rfind("/")+1, i->first.size());
|
||||||
|
|
||||||
int type = i->second->GetType();
|
switch (i->second->GetType()) {
|
||||||
|
case OptionValue::Type_String:
|
||||||
switch (type) {
|
PutOption(obj_out, i->first, (json::String)i->second->GetString());
|
||||||
case OptionValue::Type_String: {
|
break;
|
||||||
ok = PutOption(obj_out, i->first, (json::String)i->second->GetString());
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OptionValue::Type_Int:
|
case OptionValue::Type_Int:
|
||||||
ok = PutOption(obj_out, i->first, (json::Number)(const double)i->second->GetInt());
|
PutOption(obj_out, i->first, (json::Number)(const double)i->second->GetInt());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_Double:
|
case OptionValue::Type_Double:
|
||||||
ok = PutOption(obj_out, i->first, (json::Number)i->second->GetDouble());
|
PutOption(obj_out, i->first, (json::Number)i->second->GetDouble());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_Colour: {
|
case OptionValue::Type_Colour:
|
||||||
std::string str = std::string(i->second->GetColour());
|
PutOption(obj_out, i->first, (json::String)i->second->GetColour());
|
||||||
ok = PutOption(obj_out, i->first, (json::String)str);
|
break;
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
case OptionValue::Type_Bool:
|
case OptionValue::Type_Bool:
|
||||||
ok = PutOption(obj_out, i->first, (json::Boolean)i->second->GetBool());
|
PutOption(obj_out, i->first, (json::Boolean)i->second->GetBool());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_List_String: {
|
case OptionValue::Type_List_String: {
|
||||||
std::vector<std::string> array_string;
|
std::vector<std::string> array_string;
|
||||||
|
@ -159,7 +150,7 @@ void Options::Flush() {
|
||||||
array.Insert(obj);
|
array.Insert(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
ok = PutOption(obj_out, i->first, (json::Array)array);
|
PutOption(obj_out, i->first, (json::Array)array);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -174,7 +165,7 @@ void Options::Flush() {
|
||||||
obj["int"] = json::Number((const double)*i_int);
|
obj["int"] = json::Number((const double)*i_int);
|
||||||
array.Insert(obj);
|
array.Insert(obj);
|
||||||
}
|
}
|
||||||
ok = PutOption(obj_out, i->first, (json::Array)array);
|
PutOption(obj_out, i->first, (json::Array)array);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -189,7 +180,7 @@ void Options::Flush() {
|
||||||
obj["double"] = json::Number(*i_double);
|
obj["double"] = json::Number(*i_double);
|
||||||
array.Insert(obj);
|
array.Insert(obj);
|
||||||
}
|
}
|
||||||
ok = PutOption(obj_out, i->first, (json::Array)array);
|
PutOption(obj_out, i->first, (json::Array)array);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -208,7 +199,7 @@ void Options::Flush() {
|
||||||
|
|
||||||
array.Insert(obj);
|
array.Insert(obj);
|
||||||
}
|
}
|
||||||
ok = PutOption(obj_out, i->first, (json::Array)array);
|
PutOption(obj_out, i->first, (json::Array)array);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -223,7 +214,7 @@ void Options::Flush() {
|
||||||
obj["bool"] = json::Boolean(*i_bool);
|
obj["bool"] = json::Boolean(*i_bool);
|
||||||
array.Insert(obj);
|
array.Insert(obj);
|
||||||
}
|
}
|
||||||
ok = PutOption(obj_out, i->first, (json::Array)array);
|
PutOption(obj_out, i->first, (json::Array)array);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -243,7 +234,7 @@ bool Options::PutOption(json::Object &obj, const std::string &path, const json::
|
||||||
if (pos != obj.End())
|
if (pos != obj.End())
|
||||||
throw OptionErrorDuplicateKey("Key already exists");
|
throw OptionErrorDuplicateKey("Key already exists");
|
||||||
|
|
||||||
obj.Insert(json::Object::Member(path, value));
|
obj[path] = value;
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
std::string thispart = path.substr(0, path.find("/"));
|
std::string thispart = path.substr(0, path.find("/"));
|
||||||
|
|
Loading…
Reference in a new issue