fix bug 100 DefaultValue::Bind for floats
This commit is contained in:
@@ -381,7 +381,7 @@ DefaultValueTest::RunTests (void)
|
||||
DefaultValue::Bind ("test-c", "257");
|
||||
NumericDefaultValue<float> x ("test-x", "help-x", 10.0);
|
||||
NumericDefaultValue<double> y ("test-y", "help-y", 10.0);
|
||||
|
||||
DefaultValue::Bind ("test-y", "-3");
|
||||
|
||||
EnumDefaultValue<enum MyEnum> e ("test-e", "help-e",
|
||||
MY_ENUM_C, "C",
|
||||
|
||||
@@ -219,6 +219,7 @@ private:
|
||||
virtual bool DoParseValue (const std::string &value);
|
||||
virtual std::string DoGetType (void) const;
|
||||
virtual std::string DoGetDefaultValue (void) const;
|
||||
T RealMin (void) const;
|
||||
T m_defaultValue;
|
||||
T m_minValue;
|
||||
T m_maxValue;
|
||||
@@ -377,7 +378,7 @@ NumericDefaultValue<T>::NumericDefaultValue (std::string name,
|
||||
T defaultValue)
|
||||
: DefaultValueBase (name, help),
|
||||
m_defaultValue (defaultValue),
|
||||
m_minValue (std::numeric_limits<T>::min ()),
|
||||
m_minValue (RealMin ()),
|
||||
m_maxValue (std::numeric_limits<T>::max ()),
|
||||
m_value (defaultValue)
|
||||
{
|
||||
@@ -469,6 +470,21 @@ NumericDefaultValue<T>::DoGetDefaultValue (void) const
|
||||
return oss.str ();
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T
|
||||
NumericDefaultValue<T>::RealMin (void) const
|
||||
{
|
||||
if (std::numeric_limits<T>::is_integer)
|
||||
{
|
||||
return std::numeric_limits<T>::min ();
|
||||
}
|
||||
else
|
||||
{
|
||||
return -std::numeric_limits<T>::max ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**************************************************************
|
||||
**************************************************************/
|
||||
|
||||
|
||||
Reference in New Issue
Block a user