/** Get the value of an option, using def if it does not exist */
unsigned long getUInt(const std::string& key, unsigned long def, unsigned long min = 0, unsigned long max = ULONG_MAX);
/** Get the value of an option, using def if it does not exist */
- double getFloat(const std::string& key, double def);
+ double getFloat(const std::string& key, double def, double min = DBL_MIN, double max = DBL_MAX);
/** Get the value of an option, using def if it does not exist */
bool getBool(const std::string& key, bool def = false);
#pragma once
+#include <cfloat>
#include <climits>
#include <cmath>
#include <csignal>
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)
if (insane->getBool(confkey))
return false;
- float itrigger = insane->getFloat("trigger", 95.5);
+ float itrigger = insane->getFloat("trigger", 95.5, 0.0, 100.0);
long matches = test.Run(mask);