Created
October 2, 2014 20:27
-
-
Save hacst/2b047b19e2eb7b053610 to your computer and use it in GitHub Desktop.
MetaParams::typeCheckedFromSettings specialization for size_t in case I end up needing it one day (Mumble code)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <> | |
size_t MetaParams::typeCheckedFromSettings(const QString &name, const size_t &defaultValue) { | |
QVariant cfgVariable = qsSettings->value(name, defaultValue); | |
bool ok = false; | |
qulonglong value = cfgVariable.toULongLong(ok); | |
if (!ok || value > std::numeric_limits<size_t>::max()) { | |
qCritical() << "Configuration variable" << name << "is of invalid format. Set to default value of" << defaultValue << "."; | |
return defaultValue; | |
} | |
return static_cast<size_t>(value); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment