forked from mia/Aegisub
Make ConfigVisitor::AddOptionValue less dumb
Originally committed to SVN as r5818.
This commit is contained in:
parent
8fcd3daf28
commit
092ecafe58
1 changed files with 13 additions and 20 deletions
|
@ -129,14 +129,8 @@ void ConfigVisitor::Visit(const json::Null& null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigVisitor::AddOptionValue(OptionValue* opt) {
|
void ConfigVisitor::AddOptionValue(OptionValue* opt) {
|
||||||
OptionValue *opt_cur;
|
if (!values.count(name)) {
|
||||||
|
values[name] = opt;
|
||||||
OptionValueMap::iterator index;
|
|
||||||
|
|
||||||
if ((index = values.find(name)) != values.end()) {
|
|
||||||
opt_cur = index->second;
|
|
||||||
} else {
|
|
||||||
values.insert(OptionValuePair(name, opt));
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,46 +138,45 @@ void ConfigVisitor::AddOptionValue(OptionValue* opt) {
|
||||||
// method throws
|
// method throws
|
||||||
std::auto_ptr<OptionValue> auto_opt(opt);
|
std::auto_ptr<OptionValue> auto_opt(opt);
|
||||||
|
|
||||||
int type = opt_cur->GetType();
|
switch (opt->GetType()) {
|
||||||
switch (type) {
|
|
||||||
case OptionValue::Type_String:
|
case OptionValue::Type_String:
|
||||||
opt_cur->SetString(opt->GetString());
|
values[name]->SetString(opt->GetString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_Int:
|
case OptionValue::Type_Int:
|
||||||
opt_cur->SetInt(opt->GetInt());
|
values[name]->SetInt(opt->GetInt());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_Double:
|
case OptionValue::Type_Double:
|
||||||
opt_cur->SetDouble(opt->GetDouble());
|
values[name]->SetDouble(opt->GetDouble());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_Colour:
|
case OptionValue::Type_Colour:
|
||||||
opt_cur->SetColour(opt->GetColour());
|
values[name]->SetColour(opt->GetColour());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_Bool:
|
case OptionValue::Type_Bool:
|
||||||
opt_cur->SetBool(opt->GetBool());
|
values[name]->SetBool(opt->GetBool());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_List_String:
|
case OptionValue::Type_List_String:
|
||||||
opt_cur->SetListString(opt->GetListString());
|
values[name]->SetListString(opt->GetListString());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_List_Int:
|
case OptionValue::Type_List_Int:
|
||||||
opt_cur->SetListInt(opt->GetListInt());
|
values[name]->SetListInt(opt->GetListInt());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_List_Double:
|
case OptionValue::Type_List_Double:
|
||||||
opt_cur->SetListDouble(opt->GetListDouble());
|
values[name]->SetListDouble(opt->GetListDouble());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_List_Colour:
|
case OptionValue::Type_List_Colour:
|
||||||
opt_cur->SetListColour(opt->GetListColour());
|
values[name]->SetListColour(opt->GetListColour());
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OptionValue::Type_List_Bool:
|
case OptionValue::Type_List_Bool:
|
||||||
opt_cur->SetListBool(opt->GetListBool());
|
values[name]->SetListBool(opt->GetListBool());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue