4 * Created on: Apr 17, 2014
\r
8 #include "Config_Common.h"
\r
9 #include <Config_Keywords.h>
\r
11 #include <libxml/parser.h>
\r
12 #include <libxml/tree.h>
\r
14 #include <sstream> //for stringstream
\r\r
15 bool isElementNode(xmlNodePtr theNode)
\r
17 return theNode->type == XML_ELEMENT_NODE;
\r
20 bool isNode(xmlNodePtr theNode, const char* theNodeName, ...)
\r
22 bool result = false;
\r
23 const xmlChar* aName = theNode->name;
\r
24 if (!aName || !isElementNode(theNode)) {
\r
27 if (!xmlStrcmp(aName, (const xmlChar *) theNodeName)) {
\r
30 va_list args; // define argument list variable
\r
31 va_start(args, theNodeName); // init list; point to last defined argument
\r
33 char *anArg = va_arg (args, char*); // get next argument
\r
36 if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {
\r
37 va_end(args); // cleanup the system stack
\r
41 va_end(args); // cleanup the system stack
\r
45 bool hasChild(xmlNodePtr theNode)
\r
47 xmlNodePtr aNode = theNode->children;
\r
48 for (; aNode; aNode = aNode->next) {
\r
49 if (isElementNode(theNode)) {
\r
56 bool getValidatorInfo(xmlNodePtr theNode, std::string& outValidatorId,
\r
57 std::list<std::string>& outValidatorParameters)
\r
60 char* anIdProp = (char*) xmlGetProp(theNode, BAD_CAST _ID);
\r
61 if (!anIdProp || anIdProp[0] == 0) {
\r
64 outValidatorId = std::string(anIdProp);
\r
66 //Validator parameters:
\r
67 char* aParamProp = (char*) xmlGetProp(theNode, BAD_CAST VALIDATOR_PARAMETERS);
\r
68 if (aParamProp && aParamProp[0] != 0) {
\r
69 std::string aPropString = std::string(aParamProp);
\r
70 std::stringstream aPropStringStream(aPropString);
\r
71 char COMMA_DELIM = ',';
\r
72 std::string aValidatorParameter;
\r
73 while (std::getline(aPropStringStream, aValidatorParameter, ',')) {
\r
74 outValidatorParameters.push_back(aValidatorParameter);
\r
80 std::string library(const std::string& theLibName)
\r
82 std::string aLibName = theLibName;
\r
84 static std::string aLibExt( ".so" );
\r
85 if (aLibName.size() < 3 || aLibName.substr(0, 3) !="lib") {
\r
86 aLibName = "lib" + aLibName;
\r
89 static std::string aLibExt(".dll");
\r
91 std::string anExt = aLibName.substr(aLibName.size() - 4);
\r
92 if (anExt != aLibExt)
\r
93 aLibName += aLibExt;
\r