From df1e9664e176377cb8f9501d1b828ee42cd8e8f8 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Feb 2012 22:02:34 +0300 Subject: Fix reading float default parameters. --- src/configuration.cpp | 52 +++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/configuration.cpp b/src/configuration.cpp index c4f1cc360..1ff205195 100644 --- a/src/configuration.cpp +++ b/src/configuration.cpp @@ -217,6 +217,11 @@ int Configuration::getIntValue(const std::string &key) const defaultValue = 0; } } + else if (itdef->second->getType() == VariableData::DATA_FLOAT) + { + defaultValue = static_cast( + (static_cast(itdef->second))->getData()); + } } else { @@ -321,11 +326,38 @@ float Configuration::getFloatValue(const std::string &key) const { DefaultsData::const_iterator itdef = mDefaultsData->find(key); - if (itdef != mDefaultsData->end() && itdef->second - && itdef->second->getType() == VariableData::DATA_FLOAT) + if (itdef != mDefaultsData->end() && itdef->second) { - defaultValue = static_cast( - (static_cast(itdef->second))->getData()); + if (itdef->second->getType() == VariableData::DATA_FLOAT) + { + defaultValue = static_cast( + (static_cast(itdef->second))->getData()); + } + else if (itdef->second->getType() + == VariableData::DATA_STRING) + { + defaultValue = atof((static_cast( + itdef->second))->getData().c_str()); + } + else if (itdef->second->getType() + == VariableData::DATA_BOOL) + { + if ((static_cast( + itdef->second))->getData()) + { + defaultValue = 1; + } + else + { + defaultValue = 0; + } + } + else if (itdef->second->getType() + == VariableData::DATA_INT) + { + defaultValue = (static_cast( + itdef->second))->getData(); + } } else { @@ -385,6 +417,18 @@ bool Configuration::getBoolValue(const std::string &key) const defaultValue = false; } } + if (itdef->second->getType() == VariableData::DATA_FLOAT) + { + if (static_cast((static_cast( + itdef->second))->getData()) != 0) + { + defaultValue = true; + } + else + { + defaultValue = false; + } + } } else { -- cgit v1.2.3-70-g09d2