Salome HOME
Manage initnode and finalizenode in the foreachloop progress bar.
[modules/yacs.git] / src / yacsloader / loopParsers.hxx
old mode 100755 (executable)
new mode 100644 (file)
index 2d38fc8..7e2f989
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2014  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2015  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -84,6 +84,8 @@ namespace YACS
 template <class T>
 void looptypeParser<T>::buildAttr(const XML_Char** attr)
     {
+      if (!attr)
+        return;
       this->required("name",attr);
       for (int i = 0; attr[i]; i += 2) 
         {
@@ -308,7 +310,7 @@ T whilelooptypeParser<T>::post()
       T b=this->_cnode;
       this->_cnodes.pop_back();
       currentProc->names.pop_back();
-      this->_cnode=this->_cnodes.back();
+      this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back();
       return b;
     }
 }
@@ -336,6 +338,8 @@ template <class T> forlooptypeParser<T> forlooptypeParser<T>::forloopParser;
 template <class T>
 void forlooptypeParser<T>::buildAttr(const XML_Char** attr)
     {
+      if (!attr)
+        return;
       this->required("name",attr);
       for (int i = 0; attr[i]; i += 2) 
         {
@@ -374,7 +378,7 @@ template <class T>
       T b=this->_cnode;
       this->_cnodes.pop_back();
       currentProc->names.pop_back();
-      this->_cnode=this->_cnodes.back();
+      this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back();
       return b;
     }
 
@@ -414,10 +418,7 @@ struct pseudocomposednodetypeParser:looptypeParser<T>
       DEBTRACE("pseudocomposednode_post" << this->_cnode->getNode()->getName())
       T b = this->_cnode;
       this->_cnodes.pop_back();
-      if(this->_cnodes.size() == 0)
-        this->_cnode = 0;
-      else
-        this->_cnode = this->_cnodes.back();
+      this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back();
       return b;
     }
 
@@ -496,6 +497,8 @@ struct foreachlooptypeParser:dynparalooptypeParser<T>
 
   virtual void buildAttr(const XML_Char** attr)
     {
+      if (!attr)
+        return;
       this->required("name",attr);
       this->required("type",attr);
       for (int i = 0; attr[i]; i += 2) 
@@ -558,10 +561,7 @@ struct foreachlooptypeParser:dynparalooptypeParser<T>
       T b=this->_cnode;
       this->_cnodes.pop_back();
       currentProc->names.pop_back();
-      if(this->_cnodes.size() == 0)
-        this->_cnode=0;
-      else
-        this->_cnode=this->_cnodes.back();
+      this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back();
       return b;
     }
   int _nbranch;
@@ -585,6 +585,8 @@ struct optimizerlooptypeParser:dynparalooptypeParser<T>
 
   virtual void buildAttr(const XML_Char** attr)
     {
+      if (!attr)
+        return;
       this->required("name",attr);
       this->required("lib",attr);
       this->required("entry",attr);
@@ -641,10 +643,7 @@ struct optimizerlooptypeParser:dynparalooptypeParser<T>
       T b=this->_cnode;
       this->_cnodes.pop_back();
       currentProc->names.pop_back();
-      if(this->_cnodes.size() == 0)
-        this->_cnode=0;
-      else
-        this->_cnode=this->_cnodes.back();
+      this->_cnode=this->_cnodes.empty() ? 0 : this->_cnodes.back();
       return b;
     }