X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_PropManager.cpp;h=de17ec1a5fddd86dfaa67a9a9cdd3616ce5a68e6;hb=982481c856def9c064e5f2bb65de11a5b254da6e;hp=e6f800c27f649ba7c91b23f5c4ac701ff5a79e59;hpb=66af250951f489574b0229b9c6a5b18a1b358ac6;p=modules%2Fshaper.git diff --git a/src/Config/Config_PropManager.cpp b/src/Config/Config_PropManager.cpp index e6f800c27..de17ec1a5 100644 --- a/src/Config/Config_PropManager.cpp +++ b/src/Config/Config_PropManager.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + // File: Config_PropManager.cpp // Created: 13 Aug 2014 // Author: Vitaly SMETANNIKOV @@ -7,11 +9,14 @@ std::vector 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; -Config_Prop* Config_PropManager::registerProp(const std::string& theSection, const std::string& theName, - const std::string& theTitle, Config_Prop::PropType theType, +Config_Prop* Config_PropManager::registerProp(const std::string& theSection, + const std::string& theName, + const std::string& theTitle, + Config_Prop::PropType theType, const std::string& theDefaultValue) { Config_Prop* aProp = findProp(theSection, theName); @@ -119,6 +124,14 @@ double Config_PropManager::real(const std::string& theSection, const std::string return stringToDouble(aStr); } +bool Config_PropManager::boolean(const std::string& theSection, + const std::string& theName, + const std::string& theDefault) +{ + std::string aStr = string(theSection, theName, theDefault); + return stringToBoolean(aStr); +} + std::vector stringToRGB(const std::string& theColor) { std::vector aRes(3); @@ -140,7 +153,7 @@ std::vector stringToRGB(const std::string& theColor) aBuf[1] = theColor[6]; aRes[2] = strtol(aBuf, &aP, 16); } else { - int aPos = theColor.find(","); + int aPos = (int)theColor.find(","); char aBuf[10]; // Get Red std::size_t length = theColor.copy(aBuf, aPos, 0); @@ -148,7 +161,7 @@ std::vector stringToRGB(const std::string& theColor) aRes[0] = atoi(aBuf); // Get Green - int aNPos = theColor.find(",", aPos + 1); + int aNPos = (int)theColor.find(",", aPos + 1); length = theColor.copy(aBuf, aNPos - aPos - 1, aPos + 1); aBuf[length] = '\0'; aRes[1] = atoi(aBuf); @@ -171,3 +184,8 @@ double stringToDouble(const std::string& theDouble) char* p; return strtod(theDouble.c_str(), &p); } + +bool stringToBoolean(const std::string& theBoolean) +{ + return theBoolean == "true"; +}