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 xmlNodePtr aChildNode = myCurrentNode->children;
50 // it is possible that among child nodes, there is no an element node, so
51 // we should not change the current node until not-zero node is found
52 // otherwise, it may happens that the current node is null and the node tree information
54 while (aChildNode && !isElementNode(aChildNode)) {
55 aChildNode = aChildNode->next;
57 if (aChildNode != NULL) {
58 myCurrentNode = aChildNode;
65 bool Config_WidgetAPI::toParentWidget()
68 myCurrentNode = myCurrentNode->parent;
70 return myCurrentNode != NULL;
73 std::string Config_WidgetAPI::widgetType() const
75 std::string result = "";
77 result = std::string((char *) myCurrentNode->name);
82 bool Config_WidgetAPI::isGroupBoxWidget() const
84 return isNode(myCurrentNode, WDG_GROUP, WDG_OPTIONALBOX,
88 bool Config_WidgetAPI::isPagedWidget() const
90 return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
94 std::string Config_WidgetAPI::getProperty(const char* thePropName) const
96 return ::getProperty(myCurrentNode, thePropName);
99 bool Config_WidgetAPI::getBooleanAttribute(const char* theAttributeName, bool theDefault) const
101 return ::getBooleanAttribute(myCurrentNode, theAttributeName, theDefault);
104 std::string Config_WidgetAPI::widgetId() const
106 return getProperty(_ID);
109 std::string Config_WidgetAPI::widgetIcon() const
111 return getProperty(ATTR_ICON);
114 std::string Config_WidgetAPI::widgetLabel() const
116 return getProperty(ATTR_LABEL);
119 std::string Config_WidgetAPI::widgetTooltip() const
121 return getProperty(ATTR_TOOLTIP);