本文整理汇总了C++中ConfigVariable::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigVariable::getName方法的具体用法?C++ ConfigVariable::getName怎么用?C++ ConfigVariable::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigVariable
的用法示例。
在下文中一共展示了ConfigVariable::getName方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: loadSettings
void GameConfig::loadSettings(const INI::Section& section,
std::vector<ConfigVariable*>& settings)
{
try {
std::vector<ConfigVariable*>::iterator i;
for(i = settings.begin(); i != settings.end(); i++) {
ConfigVariable* var = *i;
try {
ConfigInt* confint = dynamic_cast<ConfigInt*> (var);
if(confint) {
*confint = section.getIntValue(confint->getName());
continue;
}
ConfigXY* confxy = dynamic_cast<ConfigXY*> (var);
if(confxy) {
confxy->set(section.getIntValue(confxy->getName() + "_x"),
section.getIntValue(confxy->getName() + "_y"));
continue;
}
ConfigBool* confbool = dynamic_cast<ConfigBool*> (var);
if(confbool) {
std::string str =
section.getValue(confbool->getName());
if(str == "yes" || str == "1" || str == "on")
*confbool = true;
else if(str == "no" || str == "0" || str == "off")
*confbool = false;
else
throw Exception("No boolean value for setting '%s'.",
confbool->getName().c_str());
continue;
}
ConfigStringSpecialChars* confstringspecial = dynamic_cast<ConfigStringSpecialChars*> (var);
if(confstringspecial) {
*confstringspecial = section.getValue(confstringspecial->getName());
continue;
}
ConfigString* confstring = dynamic_cast<ConfigString*> (var);
if(confstring)
*confstring = section.getValue(confstring->getName());
// we have a value from config file in the variable now
//var->setNonDefaultValue();
// now each subclass changethis if the value has been changed
} catch(std::exception& e) {
LOG(("Skipping config '%s': %s", var->getName().c_str(),
e.what()));
}
}
} catch(std::exception& e) {
LOG(("Couldn't find config section '%s', skipping...",
section.getName().c_str()));
}
}