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>
17 Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml)
19 myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str());
20 myCurrentNode = xmlDocGetRootElement(myDoc);
23 Config_WidgetAPI::~Config_WidgetAPI()
28 bool Config_WidgetAPI::toNextWidget()
30 //Skip all non-element node, stop if next node is null
31 xmlNodePtr aNextNode = myCurrentNode;
33 aNextNode = aNextNode->next;
34 } while (aNextNode && !isElementNode(aNextNode));
40 myCurrentNode = aNextNode;
44 bool Config_WidgetAPI::toChildWidget()
46 if (myCurrentNode && hasChild(myCurrentNode)) {
47 myCurrentNode = myCurrentNode->children;
48 while (!isElementNode(myCurrentNode)) {
49 myCurrentNode = myCurrentNode->next;
56 bool Config_WidgetAPI::toParentWidget()
59 myCurrentNode = myCurrentNode->parent;
61 return myCurrentNode != NULL;
64 std::string Config_WidgetAPI::widgetType() const
66 std::string result = "";
68 result = std::string((char *) myCurrentNode->name);
73 bool Config_WidgetAPI::isContainerWidget() const
75 return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
79 bool Config_WidgetAPI::isPagedWidget() const
81 return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
85 std::string Config_WidgetAPI::getProperty(const char* thePropName) const
87 return ::getProperty(myCurrentNode, thePropName);
90 bool Config_WidgetAPI::getBooleanAttribute(const char* theAttributeName, bool theDefault) const
92 return ::getBooleanAttribute(myCurrentNode, theAttributeName, theDefault);
95 std::string Config_WidgetAPI::widgetId() const
97 return getProperty(_ID);
100 std::string Config_WidgetAPI::widgetIcon() const
102 return getProperty(ANY_WDG_ICON);
105 std::string Config_WidgetAPI::widgetLabel() const
107 return getProperty(ANY_WDG_LABEL);
110 std::string Config_WidgetAPI::widgetTooltip() const
112 return getProperty(ANY_WDG_TOOLTIP);