]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/configparser.cpp
Move a bunch of optional module numerics to the module source file.
[user/henk/code/inspircd.git] / src / configparser.cpp
index 624f3aea64689cf14c9f4529ec85925bf2b64132..8a3042ebadba5393f4281eeb244fc2fd11181f76 100644 (file)
@@ -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;
@@ -507,12 +524,15 @@ unsigned long ConfigTag::getDuration(const std::string& key, unsigned long def,
        return ret;
 }
 
-double ConfigTag::getFloat(const std::string &key, double def)
+double ConfigTag::getFloat(const std::string& key, double def, double min, double max)
 {
        std::string result;
        if (!readString(key, result))
                return def;
-       return strtod(result.c_str(), NULL);
+
+       double res = strtod(result.c_str(), NULL);
+       CheckRange(tag, key, res, def, min, max);
+       return res;
 }
 
 bool ConfigTag::getBool(const std::string &key, bool def)