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);
23 myFeatureId = getProperty(_ID);
26 Config_WidgetAPI::~Config_WidgetAPI()
31 bool Config_WidgetAPI::toNextWidget()
33 //Skip all non-element node, stop if next node is null
34 xmlNodePtr aNextNode = myCurrentNode;
36 aNextNode = aNextNode->next;
37 } while (aNextNode && !isElementNode(aNextNode));
43 myCurrentNode = aNextNode;
47 bool Config_WidgetAPI::toChildWidget()
49 if (myCurrentNode && hasChild(myCurrentNode)) {
50 xmlNodePtr aChildNode = myCurrentNode->children;
51 // it is possible that among child nodes, there is no an element node, so
52 // we should not change the current node until not-zero node is found
53 // otherwise, it may happens that the current node is null and the node tree information
55 while (aChildNode && !isElementNode(aChildNode)) {
56 aChildNode = aChildNode->next;
58 if (aChildNode != NULL) {
59 myCurrentNode = aChildNode;
66 bool Config_WidgetAPI::toParentWidget()
69 myCurrentNode = myCurrentNode->parent;
71 return myCurrentNode != NULL;
74 std::string Config_WidgetAPI::widgetType() const
76 std::string result = "";
78 result = std::string((char *) myCurrentNode->name);
83 bool Config_WidgetAPI::isGroupBoxWidget() const
85 return isNode(myCurrentNode, WDG_GROUP, WDG_OPTIONALBOX,
89 bool Config_WidgetAPI::isPagedWidget() const
91 return isNode(myCurrentNode, WDG_TOOLBOX, WDG_SWITCH,
95 std::string Config_WidgetAPI::getProperty(const char* thePropName) const
97 return ::getProperty(myCurrentNode, thePropName);
100 bool Config_WidgetAPI::getBooleanAttribute(const char* theAttributeName, bool theDefault) const
102 return ::getBooleanAttribute(myCurrentNode, theAttributeName, theDefault);
105 std::string Config_WidgetAPI::featureId() const
110 std::string Config_WidgetAPI::widgetId() const
112 return getProperty(_ID);
115 std::string Config_WidgetAPI::widgetIcon() const
117 return getProperty(ATTR_ICON);
120 std::string Config_WidgetAPI::widgetLabel() const
122 return getProperty(ATTR_LABEL);
125 std::string Config_WidgetAPI::widgetTooltip() const
127 return getProperty(ATTR_TOOLTIP);