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>
16 Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml)
18 myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str());
19 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 std::string result = "";
88 char* aPropChars = (char*) xmlGetProp(myCurrentNode, BAD_CAST thePropName);
89 if (!aPropChars || aPropChars[0] == 0)
91 result = std::string(aPropChars);
95 std::string Config_WidgetAPI::widgetId() const
97 return getProperty("id");
100 std::string Config_WidgetAPI::widgetTooltip() const
102 return getProperty("tooltip");
105 std::string Config_WidgetAPI::widgetIcon() const
107 return getProperty("icon");
110 std::string Config_WidgetAPI::widgetLabel() const
112 return getProperty("label");