Salome HOME
FIx for issue #360 : make switching on/off checking of transactions in Session -...
[modules/shaper.git] / src / Config / Config_Common.cpp
index e0837036eb71d200a1a40581e3a98ad3854dfcba..2da152dccd3c9ea4271fb4066786e624f68c62af 100644 (file)
@@ -20,6 +20,8 @@
 \r
 bool isElementNode(xmlNodePtr theNode)\r
 {\r
+  if (!theNode)\r
+    return false;\r
   return theNode->type == XML_ELEMENT_NODE;\r
 }\r
 \r
@@ -128,8 +130,7 @@ std::string getProperty(xmlNodePtr theNode, const char* thePropName)
 \r
 bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool theDefault)\r
 {\r
-  std::string prop = getProperty(theNode, theAttributeName);\r
-  std::transform(prop.begin(), prop.end(), prop.begin(), ::tolower);\r
+  std::string prop = normalize(getProperty(theNode, theAttributeName));\r
   bool result = theDefault;\r
   if (prop == "true" || prop == "1") {\r
     result = true;\r
@@ -138,3 +139,17 @@ bool getBooleanAttribute(xmlNodePtr theNode, const char* theAttributeName, bool
   }\r
   return result;\r
 }\r
+\r
+CONFIG_EXPORT std::string normalize(const char* theString)\r
+{\r
+  if (!theString)\r
+    return std::string();\r
+  return normalize(std::string(theString));\r
+}\r
+\r
+CONFIG_EXPORT std::string normalize(const std::string& theString)\r
+{\r
+  std::string result = theString;\r
+  std::transform(result.begin(), result.end(), result.begin(), ::tolower);\r
+  return result;\r
+}\r