X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_Common.cpp;h=9c4df7f57c539174f1496979685e7d8b48c113e9;hb=22df2f3d52b661c4cffef91085300cffc02dfa65;hp=e0837036eb71d200a1a40581e3a98ad3854dfcba;hpb=eb4e6139c4d447d5d9e13f8bb2a8641cb5dd7efa;p=modules%2Fshaper.git diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index e0837036e..9c4df7f57 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; } @@ -126,10 +128,14 @@ std::string getProperty(xmlNodePtr theNode, const char* thePropName) return result; } +std::string getNormalizedProperty(xmlNodePtr theNode, const char* thePropName) +{ + return normalize(getProperty(theNode, 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 +144,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; +}