-/*
- * Config_Common.cpp
- *
- * Created on: Apr 17, 2014
- * Author: sbh
- */
-
-#include "Config_Common.h"
-#include <Config_Keywords.h>
-
-#include <libxml/parser.h>
-#include <libxml/tree.h>
-
-#include <sstream> //for stringstream
-
-bool isElementNode(xmlNodePtr theNode)
-{
- return theNode->type == XML_ELEMENT_NODE;
-}
-
-bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)
-{
- bool result = false;
- const xmlChar* aName = theNode->name;
- if (!aName || !isElementNode(theNode)) {
- return false;
- }
- if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {
- return true;
- }
- va_list args; // define argument list variable
- va_start(args, theNodeName); // init list; point to last defined argument
- while(true) {
- char *anArg = va_arg (args, char*); // get next argument
- if (anArg == NULL)
- break;
- if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {
- va_end(args); // cleanup the system stack
- return true;
- }
- }
- va_end(args); // cleanup the system stack
- return false;
-}
-
-bool hasChild(xmlNodePtr theNode)
-{
- xmlNodePtr aNode = theNode->children;
- for( ; aNode; aNode = aNode->next) {
- if (isElementNode(theNode)) {
- return true;
- }
- }
- return false;
-}
-
-bool getValidatorInfo(xmlNodePtr theNode,
- std::string& outValidatorId,
- std::list<std::string>& outValidatorParameters)
-{
- //Validator id:
- char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID);
- if (!anIdProp || anIdProp[0] == 0) {
- return false;
- }
- outValidatorId = std::string(anIdProp);
-
- //Validator parameters:
- char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_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);
- }
- }
- return true;
-}
-
-std::string library(const std::string& theLibName)
-{
- std::string aLibName = theLibName;
-#ifndef WIN32
- static std::string aLibExt( ".so" );
- if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") {
- aLibName = "lib" + aLibName;
- }
-#else
- static std::string aLibExt(".dll");
-#endif
- std::string anExt = aLibName.substr(aLibName.size() - 4);
- if (anExt != aLibExt)
- aLibName += aLibExt;
-
- return aLibName;
-}
+/*\r
+ * Config_Common.cpp\r
+ *\r
+ * Created on: Apr 17, 2014\r
+ * Author: sbh\r
+ */\r
+\r
+#include "Config_Common.h"\r
+#include <Config_Keywords.h>\r
+\r
+#include <libxml/parser.h>\r
+#include <libxml/tree.h>\r
+\r
+#include <sstream> //for stringstream\r\r
+bool isElementNode(xmlNodePtr theNode)\r
+{\r
+ return theNode->type == XML_ELEMENT_NODE;\r
+}\r
+\r
+bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)\r
+{\r
+ bool result = false;\r
+ const xmlChar* aName = theNode->name;\r
+ if (!aName || !isElementNode(theNode)) {\r
+ return false;\r
+ }\r
+ if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {\r
+ return true;\r
+ }\r
+ va_list args; // define argument list variable\r
+ va_start(args, theNodeName); // init list; point to last defined argument\r
+ while (true) {\r
+ char *anArg = va_arg (args, char*); // get next argument\r
+ if (anArg == NULL)\r
+ break;\r
+ if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {\r
+ va_end(args); // cleanup the system stack\r
+ return true;\r
+ }\r
+ }\r
+ va_end(args); // cleanup the system stack\r
+ return false;\r
+}\r
+\r
+bool hasChild(xmlNodePtr theNode)\r
+{\r
+ xmlNodePtr aNode = theNode->children;\r
+ for (; aNode; aNode = aNode->next) {\r
+ if (isElementNode(theNode)) {\r
+ return true;\r
+ }\r
+ }\r
+ return false;\r
+}\r
+\r
+bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,\r
+ std::list<std::string>& outValidatorParameters)\r
+{\r
+ //Validator id:\r
+ char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID);\r
+ if (!anIdProp || anIdProp[0] == 0) {\r
+ return false;\r
+ }\r
+ outValidatorId = std::string(anIdProp);\r
+\r
+ //Validator parameters:\r
+ char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS);\r
+ if (aParamProp && aParamProp[0] != 0) {\r
+ std::string aPropString = std::string(aParamProp);\r
+ std::stringstream aPropStringStream(aPropString);\r
+ char COMMA_DELIM = ',';\r
+ std::string aValidatorParameter;\r
+ while (std::getline(aPropStringStream, aValidatorParameter, ',')) {\r
+ outValidatorParameters.push_back(aValidatorParameter);\r
+ }\r
+ }\r
+ return true;\r
+}\r
+\r
+std::string library(const std::string& theLibName)\r
+{\r
+ std::string aLibName = theLibName;\r
+#ifndef WIN32\r
+ static std::string aLibExt( ".so" );\r
+ if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") {\r
+ aLibName = "lib" + aLibName;\r
+ }\r
+#else\r
+ static std::string aLibExt(".dll");\r
+#endif\r
+ std::string anExt = aLibName.substr(aLibName.size() - 4);\r
+ if (anExt != aLibExt)\r
+ aLibName += aLibExt;\r
+\r
+ return aLibName;\r
+}\r