std::vector<int> stringToRGB(const std::string& theColor);
int stringToInteger(const std::string& theInt);
-double stringToDouble(const std::string& theDouble);
bool stringToBoolean(const std::string& theInt);
Config_Properties Config_PropManager::myProps;
return atoi(theInt.c_str());
}
-double stringToDouble(const std::string& theDouble)
+double Config_PropManager::stringToDouble(const std::string& theDouble)
{
+ std::string aStr = theDouble;
+
+ // change locale and convert "," to "." if exists
+ std::string aCurLocale = setlocale(LC_NUMERIC, 0);
+ setlocale(LC_NUMERIC, "C");
+ int dotpos = (int)aStr.find(',');
+ if (dotpos != std::string::npos)
+ aStr.replace(dotpos, 1, ".");
+
char* p;
- return strtod(theDouble.c_str(), &p);
+ double aValue = strtod(aStr.c_str(), &p);
+
+ // restore locale
+ setlocale(LC_NUMERIC, aCurLocale.c_str());
+ return aValue;
}
bool stringToBoolean(const std::string& theBoolean)
//! Returns boolean by given section and name
CONFIG_EXPORT static bool boolean(const std::string& theSection,
const std::string& theName);
+ //! Returns convertion of the string to double value. Temporary changes locale to process
+ //! values contained "," or "." separator.
+ //! \param theDouble a value to be converted
+ //! \return double result or zero
+ CONFIG_EXPORT static double stringToDouble(const std::string& theDouble);
private:
CONFIG_EXPORT static Config_Properties myProps; ///< List of all stored properties
SET(PROJECT_LIBRARIES
ModelAPI
Events
+ Config
GeomAPI
)
INCLUDE_DIRECTORIES(
${CAS_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/src/ModelAPI
+ ${PROJECT_SOURCE_DIR}/src/Config
${PROJECT_SOURCE_DIR}/src/Events
${PROJECT_SOURCE_DIR}/src/GeomAPI
${PROJECT_SOURCE_DIR}/src/GeomDataAPI
#include "GeomValidators_Positive.h"
+#include <Config_PropManager.h>
#include <Events_InfoMessage.h>
#include <ModelAPI_AttributeDouble.h>
if(theArguments.size() == 1) {
std::list<std::string>::const_iterator anIt = theArguments.begin();
char *aErr;
- double aValue = strtod((*anIt).c_str(), &aErr);
- if(*aErr == 0) {
+ double aValue = Config_PropManager::stringToDouble((*anIt).c_str());
+ if(aValue != 0) {
// very probably ok
aMinValue = aValue;
}