add 'def' to settings info
This commit is contained in:
@@ -102,6 +102,26 @@ dv::value SettingsHandler::getValue(const std::string& name) const {
|
||||
}
|
||||
}
|
||||
|
||||
dv::value SettingsHandler::getDefault(const std::string& name) const {
|
||||
auto found = map.find(name);
|
||||
if (found == map.end()) {
|
||||
throw std::runtime_error("setting '" + name + "' does not exist");
|
||||
}
|
||||
auto setting = found->second;
|
||||
|
||||
if (auto number = dynamic_cast<NumberSetting*>(setting)) {
|
||||
return static_cast<number_t>(number->getDefault());
|
||||
} else if (auto integer = dynamic_cast<IntegerSetting*>(setting)) {
|
||||
return static_cast<integer_t>(integer->getDefault());
|
||||
} else if (auto flag = dynamic_cast<FlagSetting*>(setting)) {
|
||||
return flag->getDefault();
|
||||
} else if (auto string = dynamic_cast<StringSetting*>(setting)) {
|
||||
return string->getDefault();
|
||||
} else {
|
||||
throw std::runtime_error("type is not implemented for '" + name + "'");
|
||||
}
|
||||
}
|
||||
|
||||
std::string SettingsHandler::toString(const std::string& name) const {
|
||||
auto found = map.find(name);
|
||||
if (found == map.end()) {
|
||||
|
||||
Reference in New Issue
Block a user