4 * Created on: Apr 17, 2014
8 #include "Config_Common.h"
9 #include <Config_Keywords.h>
11 #include <libxml/parser.h>
12 #include <libxml/tree.h>
14 #include <sstream> //for stringstream
16 bool isElementNode(xmlNodePtr theNode)
18 return theNode->type == XML_ELEMENT_NODE;
21 bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)
24 const xmlChar* aName = theNode->name;
25 if (!aName || !isElementNode(theNode)) {
28 if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {
31 va_list args; // define argument list variable
32 va_start(args, theNodeName); // init list; point to last defined argument
34 char *anArg = va_arg (args, char*); // get next argument
37 if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {
38 va_end(args); // cleanup the system stack
42 va_end(args); // cleanup the system stack
46 bool hasChild(xmlNodePtr theNode)
48 xmlNodePtr aNode = theNode->children;
49 for( ; aNode; aNode = aNode->next) {
50 if (isElementNode(theNode)) {
57 bool getValidatorInfo(xmlNodePtr theNode,
58 std::string& outValidatorId,
59 std::list<std::string>& outValidatorParameters)
62 char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID);
63 if (!anIdProp || anIdProp[0] == 0) {
66 outValidatorId = std::string(anIdProp);
68 //Validator parameters:
69 char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS);
70 if (aParamProp && aParamProp[0] != 0) {
71 std::string aPropString = std::string(aParamProp);
72 std::stringstream aPropStringStream(aPropString);
73 char COMMA_DELIM = ',';
74 std::string aValidatorParameter;
75 while (std::getline(aPropStringStream, aValidatorParameter, ',')) {
76 outValidatorParameters.push_back(aValidatorParameter);
82 std::string library(const std::string& theLibName)
84 std::string aLibName = theLibName;
86 static std::string aLibExt( ".so" );
87 if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") {
88 aLibName = "lib" + aLibName;
91 static std::string aLibExt(".dll");
93 std::string anExt = aLibName.substr(aLibName.size() - 4);