Salome HOME
Boost has been removed from code
[modules/shaper.git] / src / Config / Config_XMLReader.cpp
index 8d618b102f0731f9e5d424808d8e67f0aab52719..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,9 +118,9 @@ 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)) {
+    if (!isElementNode(aNode)) {
       continue;
     }
     processNode(aNode);
@@ -141,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);
@@ -158,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);
+  aMessage->setValidatorId(aValidatorId);
+  aMessage->setValidatorParameters(aValidatorParameters);
   xmlNodePtr aFeatureOrWdgNode = theNode->parent;
-  if(isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
-    aMessage.setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
+  if (isNode(aFeatureOrWdgNode, NODE_FEATURE, NULL)) {
+    aMessage->setFeatureId(getProperty(aFeatureOrWdgNode, _ID));
   } else {
-    aMessage.setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
-    aMessage.setFeatureId(myCurrentFeature);
+    aMessage->setAttributeId(getProperty(aFeatureOrWdgNode, _ID));
+    aMessage->setFeatureId(myCurrentFeature);
   }
   aEvLoop->send(aMessage);
 }