X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_Common.cpp;h=2da152dccd3c9ea4271fb4066786e624f68c62af;hb=60e95a5502a6940c6c27ce5d561b3c684b0b0a4f;hp=e0837036eb71d200a1a40581e3a98ad3854dfcba;hpb=340b387f8fe22028900d0f2ba2b81eac538014c4;p=modules%2Fshaper.git diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index e0837036e..2da152dcc 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -20,6 +20,8 @@ bool isElementNode(xmlNodePtr theNode) { + if (!theNode) + return false; return theNode->type == XML_ELEMENT_NODE; } @@ -128,8 +130,7 @@ std::string getProperty(xmlNodePtr theNode, const char* thePropName) bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool theDefault) { - std::string prop = getProperty(theNode, theAttributeName); - std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower); + std::string prop = normalize(getProperty(theNode, theAttributeName)); bool result = theDefault; if (prop == "true" || prop == "1") { result = true; @@ -138,3 +139,17 @@ bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool } return result; } + +CONFIG_EXPORT std::string normalize(const char* theString) +{ + if (!theString) + return std::string(); + return normalize(std::string(theString)); +} + +CONFIG_EXPORT std::string normalize(const std::string& theString) +{ + std::string result = theString; + std::transform(result.begin(), result.end(), result.begin(), ::tolower); + return result; +}