1 // Copyright (C) 2014-20xx CEA/DEN, EDF R&D
6 * Created on: Apr 1, 2014
10 #include <Config_WidgetAPI.h>
11 #include <Config_Keywords.h>
12 #include <Config_Common.h>
14 #include <libxml/parser.h>
15 #include <libxml/tree.h>
19 Config_WidgetAPI::Config_WidgetAPI(std::string theRawXml)
21 myDoc = xmlParseDoc(BAD_CAST theRawXml.c_str());
22 myCurrentNode = xmlDocGetRootElement(myDoc);
25 Config_WidgetAPI::~Config_WidgetAPI()
30 bool Config_WidgetAPI::toNextWidget()
32 //Skip all non-element node, stop if next node is null
33 xmlNodePtr aNextNode = myCurrentNode;
35 aNextNode = aNextNode->next;
36 } while (aNextNode && !isElementNode(aNextNode));
42 myCurrentNode = aNextNode;
46 bool Config_WidgetAPI::toChildWidget()
48 if (myCurrentNode && hasChild(myCurrentNode)) {
49 myCurrentNode = myCurrentNode->children;
50 while (myCurrentNode && !isElementNode(myCurrentNode)) {
51 myCurrentNode = myCurrentNode->next;
53 return myCurrentNode != NULL;
58 bool Config_WidgetAPI::toParentWidget()
61 myCurrentNode = myCurrentNode->parent;
63 return myCurrentNode != NULL;
66 std::string Config_WidgetAPI::widgetType() const
68 std::string result = "";
70 result = std::string((char *) myCurrentNode->name);
75 bool Config_WidgetAPI::isContainerWidget() const
77 return isNode(myCurrentNode, WDG_GROUP, WDG_CHECK_GROUP,
81 bool Config_WidgetAPI::isPagedWidget() const
83 return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
87 std::string Config_WidgetAPI::getProperty(const char* thePropName) const
89 return ::getProperty(myCurrentNode, thePropName);
92 bool Config_WidgetAPI::getBooleanAttribute(const char* theAttributeName, bool theDefault) const
94 return ::getBooleanAttribute(myCurrentNode, theAttributeName, theDefault);
97 std::string Config_WidgetAPI::widgetId() const
99 return getProperty(_ID);
102 std::string Config_WidgetAPI::widgetIcon() const
104 return getProperty(ATTR_ICON);
107 std::string Config_WidgetAPI::widgetLabel() const
109 return getProperty(ATTR_LABEL);
112 std::string Config_WidgetAPI::widgetTooltip() const
114 return getProperty(ATTR_TOOLTIP);