4 * Created on: Apr 1, 2014
8 #include <Config_WidgetAPI.h>
9 #include <Config_Keywords.h>
10 #include <Config_Common.h>
12 #include <libxml/parser.h>
13 #include <libxml/tree.h>
15 Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml)
17 myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str());
18 myCurrentNode = xmlDocGetRootElement(myDoc);
21 Config_WidgetAPI::~Config_WidgetAPI()
26 bool Config_WidgetAPI::toNextWidget()
28 //Skip all non-element node, stop if next node is null
29 xmlNodePtr aNextNode = myCurrentNode;
31 aNextNode = aNextNode->next;
32 } while (aNextNode && !isElementNode(aNextNode));
38 myCurrentNode = aNextNode;
42 bool Config_WidgetAPI::toChildWidget()
44 if (myCurrentNode && hasChild(myCurrentNode)) {
45 myCurrentNode = myCurrentNode->children;
46 while (!isElementNode(myCurrentNode)) {
47 myCurrentNode = myCurrentNode->next;
54 bool Config_WidgetAPI::toParentWidget()
57 myCurrentNode = myCurrentNode->parent;
59 return myCurrentNode != NULL;
62 std::string Config_WidgetAPI::widgetType() const
64 std::string result = "";
66 result = std::string((char *) myCurrentNode->name);
71 bool Config_WidgetAPI::isContainerWidget() const
73 return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
77 bool Config_WidgetAPI::isPagedWidget() const
79 return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
83 std::string Config_WidgetAPI::getProperty(const char* thePropName) const
85 std::string result = "";
86 char* aPropChars = (char*) xmlGetProp(myCurrentNode, BAD_CAST thePropName);
87 if (!aPropChars || aPropChars[0] == 0)
89 result = std::string(aPropChars);
93 std::string Config_WidgetAPI::widgetId() const
95 return getProperty(_ID);
98 std::string Config_WidgetAPI::widgetIcon() const
100 return getProperty(ANY_WDG_ICON);
103 std::string Config_WidgetAPI::widgetLabel() const
105 return getProperty(ANY_WDG_LABEL);
108 std::string Config_WidgetAPI::widgetTooltip() const
110 return getProperty(ANY_WDG_TOOLTIP);