Salome HOME
Boost has been removed from code
[modules/shaper.git] / src / Config / Config_XMLReader.cpp
index a9bf87dc617c560383505840f9a2a9f5402cbaf1..44c806ce919faebbb6e70e7121e6ee6eecf0cd4c 100644 (file)
 #include <libxml/parser.h>
 #include <libxml/tree.h>
 
-/*
 #ifdef WIN32
-//For GetModuleFileNameW
-#include <windows.h>
+#pragma warning(disable : 4996) // for getenv
 #endif
-*/
 
 #ifdef _DEBUG
 #include <iostream>
@@ -70,9 +67,9 @@ void Config_XMLReader::processNode(xmlNodePtr theNode)
     std::string aSourceFile = getProperty(theNode, SOURCE_FILE);
     Config_XMLReader aSourceReader = Config_XMLReader(aSourceFile);
     readRecursively(aSourceReader.findRoot());
-    #ifdef _DEBUG
+#ifdef _DEBUG
     std::cout << "Config_XMLReader::sourced node: " << aSourceFile << std::endl;
-    #endif
+#endif
   } else if (isNode(theNode, NODE_VALIDATOR, NULL)) {
     processValidator(theNode);
   }
@@ -121,11 +118,12 @@ void Config_XMLReader::readRecursively(xmlNodePtr theParent)
   if (!theParent)
     return;
   xmlNodePtr aNode = theParent->xmlChildrenNode;
-  for(; aNode; aNode = aNode->next) {
+  for (; aNode; aNode = aNode->next) {
     //Still no text processing in features...
-    if(isElementNode(aNode)) {
-      processNode(aNode);
+    if (!isElementNode(aNode)) {
+      continue;
     }
+    processNode(aNode);
     if (processChildren(aNode)) {
       readRecursively(aNode);
     }
@@ -140,13 +138,10 @@ xmlNodePtr Config_XMLReader::node(void* theNode)
   return static_cast<xmlNodePtr>(theNode);
 }
 
-/*
- * Returns named property for a given node as std::string.
- */
-std::string Config_XMLReader::getProperty(xmlNodePtr theNode, const char* theName)
+std::string Config_XMLReader::getNodeName(xmlNodePtr theNode)
 {
   std::string result = "";
-  char* aPropChars = (char*) xmlGetProp(theNode, BAD_CAST theName);
+  char* aPropChars = (char*) theNode->name;
   if (!aPropChars || aPropChars[0] == 0)
     return result;
   result = std::string(aPropChars);
@@ -157,18 +152,19 @@ void Config_XMLReader::processValidator(xmlNodePtr theNode)
 {
   Events_ID aValidatoEvent = Events_Loop::eventByName(EVENT_VALIDATOR_LOADED);
   Events_Loop* aEvLoop = Events_Loop::loop();
-  Config_ValidatorMessage aMessage(aValidatoEvent, this);
+  std::shared_ptr<Config_ValidatorMessage> 
+    aMessage(new Config_ValidatorMessage(aValidatoEvent, this));
   std::string aValidatorId;
   std::list<std::string> aValidatorParameters;
   getValidatorInfo(theNode, aValidatorId, aValidatorParameters);
-  aMessage.setValidatorId(aValidatorId);
-  aMessage.setValidatorParameters(aValidatorParameters);
-  if(isNode(theNode->parent, NODE_FEATURE, NULL)) {
-    aMessage.setFeatureId(getProperty(theNode->parent, _ID));
+  aMessage->setValidatorId(aValidatorId);
+  aMessage->setValidatorParameters(aValidatorParameters);
+  xmlNodePtr aFeatureOrWdgNode = theNode->parent;
+  if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+    aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
   } else {
-    xmlNodePtr aWdgNode = theNode->parent;
-    aMessage.setAttributeId(getProperty(aWdgNode, _ID));
-    aMessage.setFeatureId(getProperty(aWdgNode->parent, _ID));
+    aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+    aMessage->setFeatureId(myCurrentFeature);
   }
   aEvLoop->send(aMessage);
 }