4 * Created on: Apr 1, 2014
8 #include <Config_WidgetAPI.h>
10 #include <libxml\parser.h>
11 #include <libxml\tree.h>
14 Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml)
16 myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str());
21 Config_WidgetAPI::~Config_WidgetAPI()
26 void Config_WidgetAPI::reset()
28 xmlNodePtr aRoot = xmlDocGetRootElement(myDoc);
30 myCurrentNode = aRoot->children;
34 bool Config_WidgetAPI::nextWidget()
37 myCurrentNode = myCurrentNode->next;
39 return myCurrentNode != NULL;
42 std::string Config_WidgetAPI::widgetType()
44 std::string result = "";
46 result = std::string((char *) myCurrentNode->name);
51 std::string Config_WidgetAPI::getProperty(const char* thePropName)
53 std::string result = "";
54 char* aPropChars = (char*) xmlGetProp(myCurrentNode, BAD_CAST thePropName);
55 if (!aPropChars || aPropChars[0] == 0)
57 result = std::string(aPropChars);
61 std::string Config_WidgetAPI::widgetId()
63 return getProperty("id");
66 std::string Config_WidgetAPI::widgetTooltip()
68 return getProperty("tooltip");
71 std::string Config_WidgetAPI::widgetIcon()
73 return getProperty("icon");
76 std::string Config_WidgetAPI::widgetLabel()
78 return getProperty("label");
81 bool Config_WidgetAPI::isNode(xmlNodePtr theNode, const char* theNodeName, ...)
84 const xmlChar* aName = theNode->name;
85 if (!aName || theNode->type != XML_ELEMENT_NODE)
88 if (!xmlStrcmp(aName, (const xmlChar *) theNodeName))
91 va_list args; // define argument list variable
92 va_start(args, theNodeName); // init list; point to last defined argument
94 char *anArg = va_arg (args, char*); // get next argument
97 if (!xmlStrcmp(aName, (const xmlChar *) anArg)) {
98 va_end(args); // cleanup the system stack
102 va_end(args); // cleanup the system stack