Salome HOME
Improve swig generation process on Windows platform.
[tools/medcoupling.git] / src / INTERP_KERNEL / ExprEval / InterpKernelExprParser.cxx
index e1cce1a91d9c6c897162626e46116740d35b2f35..782d756e5fcc8b27dcf889e953e1ef3283ad9c96 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2007-2015  CEA/DEN, EDF R&D
+// Copyright (C) 2007-2016  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
@@ -81,11 +81,11 @@ void LeafExprVal::replaceValues(const std::vector<double>& valuesInExpr)
   int pos=(int)_value;
   int lgth=(int)valuesInExpr.size();
   if(pos>=lgth || pos<0)
-    throw INTERP_KERNEL::Exception("LeafExprVal::replaceValues : Big Problem detected ! Send expression to Salome support with expression !");
+    throw INTERP_KERNEL::Exception("LeafExprVal::replaceValues : Big Problem detected! Send a mail to Salome support with expression.");
   _value=valuesInExpr[pos];
 }
 
-LeafExprVal *LeafExprVal::deepCpy() const
+LeafExprVal *LeafExprVal::deepCopy() const
 {
   return new LeafExprVal(*this);
 }
@@ -171,7 +171,7 @@ bool LeafExprVar::isRecognizedKeyVar(const std::string& var, int& pos)
   return true;
 }
 
-LeafExprVar *LeafExprVar::deepCpy() const
+LeafExprVar *LeafExprVar::deepCopy() const
 {
   return new LeafExprVar(*this);
 }
@@ -201,10 +201,10 @@ void ExprParserOfEval::sortMemory()
   for(std::vector<ExprParserOfEval>::iterator it=_sub_parts.begin();it!=_sub_parts.end();it++)
     (*it).sortMemory();
   if(_leaf)
-    _leaf=_leaf->deepCpy();
+    _leaf=_leaf->deepCopy();
   for(std::vector<Function *>::iterator it=_funcs.begin();it!=_funcs.end();it++)
     if(*it)
-      *it=(*it)->deepCpy();
+      *it=(*it)->deepCopy();
 }
 
 ExprParser::ExprParser(const std::string& expr, ExprParser *father):_father(father),_is_parsed(false),_leaf(0),_is_parsing_ok(false),_expr(expr)
@@ -459,22 +459,49 @@ Value *ExprParser::evaluateLowLev(Value *valGen) const
   return stackOfVal.back();
 }
 
+#if __cplusplus >= 201103L
+
+ExprParser::ExprParser(ExprParser&& other):_father(other._father),_leaf(other._leaf),_is_parsing_ok(std::move(other._is_parsing_ok)),_expr(std::move(other._expr)),_sub_expr(std::move(other._sub_expr)),_func_btw_sub_expr(std::move(other._func_btw_sub_expr))
+{
+  other._leaf=0;
+}
+
+ExprParser& ExprParser::operator=(ExprParser&& other)
+{
+  _father=other._father;
+  _is_parsing_ok=std::move(other._is_parsing_ok);
+  _leaf=other._leaf;
+  _expr=std::move(other._expr);
+  _sub_expr=std::move(other._sub_expr);
+  _func_btw_sub_expr=std::move(other._func_btw_sub_expr);
+  other._leaf=other._leaf;
+  other._leaf=0;
+  return *this;
+}
+
+#endif
+
 void ExprParser::reverseThis()
 {
   if(_leaf)
     return ;
   for(std::vector<ExprParser>::iterator iter=_sub_expr.begin();iter!=_sub_expr.end();iter++)
     (*iter).reverseThis();
-  AutoPtr<char> buf(new char[sizeof(ExprParser)]);
-  char *loc(reinterpret_cast<char *>(&_sub_expr[0])),*bufPtr(buf);
   std::size_t sz(_sub_expr.size());
   std::size_t nbOfTurn(sz/2);
+#if __cplusplus >= 201103L
+  for(std::size_t i=0;i<nbOfTurn;i++)
+    std::swap(_sub_expr[i],_sub_expr[sz-i-1]);
+#else
+  AutoPtr<char> buf(new char[sizeof(ExprParser)]);
+  char *loc(reinterpret_cast<char *>(&_sub_expr[0])),*bufPtr(buf);
   for(std::size_t i=0;i<nbOfTurn;i++)
     {
       std::copy(loc+i*sizeof(ExprParser),loc+(i+1)*sizeof(ExprParser),bufPtr);
       std::copy(loc+(sz-i-1)*sizeof(ExprParser),loc+(sz-i)*sizeof(ExprParser),loc+i*sizeof(ExprParser));
       std::copy(bufPtr,bufPtr+sizeof(ExprParser),loc+(sz-i-1)*sizeof(ExprParser));
     }
+#endif
 }
 
 ExprParserOfEval ExprParser::convertMeTo() const
@@ -528,7 +555,7 @@ void ExprParser::parseUnaryFunc()
 {
   if(_expr[_expr.length()-1]!=')')
     return ;
-  //at this level of code _expr 
+  //at this level of code _expr
   std::size_t pos1=_expr.find_first_of('(');
   std::size_t pos4=FindCorrespondingOpenBracket(_expr,_expr.length()-1);
   if(pos4!=pos1)
@@ -569,7 +596,7 @@ void ExprParser::parseUnaryFunc()
 /*!
  *  This method has the responsability to see if this->_expr is interpretable without any recursion.
  * \return true if no recursion needed, false if this->_expr is too complex to be interpreted at this level.
- * \throw exception if this->_expr is simple enough to try to interprate this and this expression contains an error.  
+ * \throw exception if this->_expr is simple enough to try to interprate this and this expression contains an error.
  */
 bool ExprParser::tryToInterpALeaf()
 {