diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2019-06-30 16:38:25 -0700 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2019-06-30 16:40:08 -0700 |
commit | 49ceae681b4889ed9500fa9c15b21cca7eb08fc3 (patch) | |
tree | eaa687c2c2bfa116c25b220512adbcc8da324f93 /Alc/alconfig.cpp | |
parent | 3658dafdcbbd114caaf81cb27cf6ccc07045b0aa (diff) |
Return optionals from the remaining ConfigValue* methods
Diffstat (limited to 'Alc/alconfig.cpp')
-rw-r--r-- | Alc/alconfig.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/Alc/alconfig.cpp b/Alc/alconfig.cpp index c5abd6ab..36aac48d 100644 --- a/Alc/alconfig.cpp +++ b/Alc/alconfig.cpp @@ -517,23 +517,22 @@ al::optional<unsigned int> ConfigValueUInt(const char *devName, const char *bloc static_cast<unsigned int>(std::strtoul(val, nullptr, 0))}; } -int ConfigValueFloat(const char *devName, const char *blockName, const char *keyName, float *ret) +al::optional<float> ConfigValueFloat(const char *devName, const char *blockName, const char *keyName) { const char *val = GetConfigValue(devName, blockName, keyName, ""); - if(!val[0]) return 0; + if(!val[0]) return al::nullopt; - *ret = std::strtof(val, nullptr); - return 1; + return al::optional<float>{al::in_place, std::strtof(val, nullptr)}; } -int ConfigValueBool(const char *devName, const char *blockName, const char *keyName, int *ret) +al::optional<bool> ConfigValueBool(const char *devName, const char *blockName, const char *keyName) { const char *val = GetConfigValue(devName, blockName, keyName, ""); - if(!val[0]) return 0; + if(!val[0]) return al::nullopt; - *ret = (strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 || - strcasecmp(val, "on") == 0 || atoi(val) != 0); - return 1; + return al::optional<bool>{al::in_place, + strcasecmp(val, "true") == 0 || strcasecmp(val, "yes") == 0 || + strcasecmp(val, "on") == 0 || atoi(val) != 0}; } int GetConfigValueBool(const char *devName, const char *blockName, const char *keyName, int def) |