diff options
| author | 2018-04-14 15:43:03 +0100 | |
|---|---|---|
| committer | 2018-04-16 15:29:55 +0100 | |
| commit | 780dda83ba3857bc3c330d4b5d38bb251a9d879b (patch) | |
| tree | 75034915142a3e1362f0f9d59c8e96e1eec22931 /src/configparser.cpp | |
| parent | Convert ConfigTag::getDuration to return an unsigned long. (diff) | |
Add ConfigTag::getUInt for reading unsigned config values.
Diffstat (limited to 'src/configparser.cpp')
| -rw-r--r-- | src/configparser.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/configparser.cpp b/src/configparser.cpp index 624f3aea6..5ee86c811 100644 --- a/src/configparser.cpp +++ b/src/configparser.cpp @@ -496,6 +496,23 @@ long ConfigTag::getInt(const std::string &key, long def, long min, long max) return res; } +unsigned long ConfigTag::getUInt(const std::string& key, unsigned long def, unsigned long min, unsigned long max) +{ + std::string result; + if (!readString(key, result)) + return def; + + const char* res_cstr = result.c_str(); + char* res_tail = NULL; + unsigned long res = strtoul(res_cstr, &res_tail, 0); + if (res_tail == res_cstr) + return def; + + CheckMagnitude(tag, key, result, res, def, res_tail); + CheckRange(tag, key, res, def, min, max); + return res; +} + unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def, unsigned long min, unsigned long max) { std::string duration; |
