X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FConfig%2FConfig_Common.cpp;h=9c4df7f57c539174f1496979685e7d8b48c113e9;hb=22df2f3d52b661c4cffef91085300cffc02dfa65;hp=b3a93acd1963a5fd52eaf6a78e9294803172cd55;hpb=acebef0bc5fb22dc9672e0046085b896e957af56;p=modules%2Fshaper.git diff --git a/src/Config/Config_Common.cpp b/src/Config/Config_Common.cpp index b3a93acd1..9c4df7f57 100644 --- a/src/Config/Config_Common.cpp +++ b/src/Config/Config_Common.cpp @@ -1,3 +1,5 @@ +// Copyright (C) 2014-20xx CEA/DEN, EDF R&D + /* * Config_Common.cpp * @@ -14,9 +16,12 @@ #include // for stringstream #include -#include // for std::transform +#include // for std::transform + bool isElementNode(xmlNodePtr theNode) { + if (!theNode) + return false; return theNode->type == XML_ELEMENT_NODE; } @@ -55,7 +60,7 @@ bool isWidgetNode(xmlNodePtr theNode) return false; //it should not be a "source" or a "validator" node - return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NULL); + return !isNode(theNode, NODE_SOURCE, NODE_VALIDATOR, NODE_SELFILTER, NULL); } bool hasChild(xmlNodePtr theNode) @@ -69,25 +74,25 @@ bool hasChild(xmlNodePtr theNode) return false; } -bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId, +bool getParametersInfo(xmlNodePtr theNode, std::string& outPropertyId, std::list& outValidatorParameters) { - //Validator id: + //Property id: char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID); if (!anIdProp || anIdProp[0] == 0) { return false; } - outValidatorId = std::string(anIdProp); + outPropertyId = std::string(anIdProp); - //Validator parameters: - char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS); + //Property parameters: + char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST _PARAMETERS); if (aParamProp && aParamProp[0] != 0) { std::string aPropString = std::string(aParamProp); std::stringstream aPropStringStream(aPropString); char COMMA_DELIM = ','; - std::string aValidatorParameter; - while (std::getline(aPropStringStream, aValidatorParameter, ',')) { - outValidatorParameters.push_back(aValidatorParameter); + std::string aParameter; + while (std::getline(aPropStringStream, aParameter, ',')) { + outValidatorParameters.push_back(aParameter); } } return true; @@ -95,6 +100,8 @@ bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId, std::string library(const std::string& theLibName) { + if(theLibName.empty()) + return std::string(); std::string aLibName = theLibName; #ifndef WIN32 static std::string aLibExt( ".so" ); @@ -121,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; @@ -133,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; +}