2 * Config_WidgetReader.cpp
4 * Created on: Apr 2, 2014
8 #include <Config_WidgetReader.h>
9 #include <Config_Keywords.h>
10 #include <Config_Common.h>
12 #include <libxml/parser.h>
13 #include <libxml/tree.h>
14 #include <libxml/xpath.h>
15 #include <libxml/xmlstring.h>
22 Config_WidgetReader::Config_WidgetReader(const std::string& theXmlFile)
23 : Config_XMLReader(theXmlFile)
28 Config_WidgetReader::~Config_WidgetReader()
32 std::string Config_WidgetReader::featureWidgetCfg(const std::string& theFeatureName)
34 return myWidgetCache[theFeatureName];
37 std::string Config_WidgetReader::featureDescription(const std::string& theFeatureName)
39 return myDescriptionCache[theFeatureName];
43 void Config_WidgetReader::processNode(xmlNodePtr theNode)
45 if (isNode(theNode, NODE_FEATURE, NULL)) {
46 std::string aNodeName = getProperty(theNode, _ID);
47 myWidgetCache[aNodeName] = dumpNode(theNode);;
48 myDescriptionCache[aNodeName] = getProperty(theNode, FEATURE_TEXT);
50 //Process SOURCE nodes.
51 Config_XMLReader::processNode(theNode);
54 bool Config_WidgetReader::processChildren(xmlNodePtr theNode)
56 return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
59 std::string Config_WidgetReader::dumpNode(xmlNodePtr theNode)
61 std::string result = "";
62 if (!hasChild(theNode)) {
65 xmlNodePtr aChildrenNode = xmlFirstElementChild(theNode);
66 xmlBufferPtr buffer = xmlBufferCreate();
67 if (isNode(aChildrenNode, NODE_SOURCE, NULL)) {
68 Config_XMLReader aSourceReader =
69 Config_XMLReader(getProperty(aChildrenNode, SOURCE_FILE));
70 xmlNodePtr aSourceRoot = aSourceReader.findRoot();
71 int size = xmlNodeDump(buffer, aSourceRoot->doc, aSourceRoot, 0, 1);
73 int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
75 result = std::string((char*) (buffer->content));