Salome HOME
Loading of SketchSolver plugin example.
[modules/shaper.git] / src / Config / Config_WidgetReader.cpp
index 3558c659652307e27ab1bf6ac314cc1d31bc8121..7ba92f9961f5f6b7a5d7e08f4e2fd54ff1e8b29d 100644 (file)
@@ -7,11 +7,12 @@
 
 #include <Config_WidgetReader.h>
 #include <Config_Keywords.h>
+#include <Config_Common.h>
 
-#include <libxml\parser.h>
-#include <libxml\tree.h>
-#include <libxml\xpath.h>
-#include <libxml\xmlstring.h>
+#include <libxml/parser.h>
+#include <libxml/tree.h>
+#include <libxml/xpath.h>
+#include <libxml/xmlstring.h>
 
 #ifdef _DEBUG
 #include <iostream>
@@ -28,22 +29,49 @@ Config_WidgetReader::~Config_WidgetReader()
 {
 }
 
-std::string Config_WidgetReader::featureWidgetCfg(std::string theFeatureName)
+std::string Config_WidgetReader::featureWidgetCfg(const std::string& theFeatureName)
 {
   return myWidgetCache[theFeatureName];
 }
 
+std::string Config_WidgetReader::featureDescription(const std::string& theFeatureName)
+{
+  return myDescriptionCache[theFeatureName];
+}
+
+
 void Config_WidgetReader::processNode(xmlNodePtr theNode)
 {
   if (isNode(theNode, NODE_FEATURE, NULL)) {
-    xmlBufferPtr buffer = xmlBufferCreate();
-    int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
     std::string aNodeName = getProperty(theNode, _ID);
-    myWidgetCache[aNodeName] = std::string((char*) buffer->content);
+    myWidgetCache[aNodeName] = dumpNode(theNode);;
+    myDescriptionCache[aNodeName] = getProperty(theNode, FEATURE_TEXT);
   }
+  //Process SOURCE nodes.
+  Config_XMLReader::processNode(theNode);
 }
 
 bool Config_WidgetReader::processChildren(xmlNodePtr theNode)
 {
   return isNode(theNode, NODE_WORKBENCH, NODE_GROUP, NULL);
 }
+
+std::string Config_WidgetReader::dumpNode(xmlNodePtr theNode)
+{
+  std::string result = "";
+  if (!hasChild(theNode)) {
+    return result;
+  }
+  xmlNodePtr aChildrenNode = xmlFirstElementChild(theNode);
+  xmlBufferPtr buffer = xmlBufferCreate();
+  if (isNode(aChildrenNode, NODE_SOURCE, NULL)) {
+    Config_XMLReader aSourceReader = 
+      Config_XMLReader(getProperty(aChildrenNode, SOURCE_FILE));
+    xmlNodePtr aSourceRoot = aSourceReader.findRoot();
+    int size = xmlNodeDump(buffer, aSourceRoot->doc, aSourceRoot, 0, 1);
+  } else {
+    int size = xmlNodeDump(buffer, theNode->doc, theNode, 0, 1);
+  }
+  result = std::string((char*) (buffer->content));
+  return result;
+}