]> SALOME platform Git repositories - modules/superv.git/commitdiff
Salome HOME
NPAL16955: syntax storage in a python supervisiongraph.
authorjfa <jfa@opencascade.com>
Mon, 17 Sep 2007 10:18:48 +0000 (10:18 +0000)
committerjfa <jfa@opencascade.com>
Mon, 17 Sep 2007 10:18:48 +0000 (10:18 +0000)
src/GraphBase/DataFlowBase_ComputingNode.cxx

index 264719f47584dbd8ab1287948d167fae212950a7..51b902ff13614e438aaccdf2da1e60d5272b0a89 100644 (file)
@@ -31,6 +31,18 @@ using namespace std;
 #include "DataFlowBase_StreamGraph.hxx"
 //#include "DataFlowBase_LoopNode.hxx"
 
+// Screen single quotes
+static string protectQuotes (const string theText)
+{
+  string aRes (theText);
+  for (unsigned int pos = 0; pos < aRes.size(); pos+=2) {
+    pos = aRes.find("'", pos);
+    if (pos < 0 || pos > aRes.size()) break;
+    aRes.replace(pos, 1, "\\\'");
+  }
+  return aRes;
+}
+
 static void InitFields( //SUPERV::KindOfNode &_Kind ,
                         SUPERV::SDate      &_FirstCreation ,
                         SUPERV::SDate      &_LastModification ,
@@ -1612,7 +1624,7 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
     if ( PythonFunctions.size() ) {
       aPyFunc = *PythonFunctions[0] ;
       for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
-        f << "    " << "Py" << Name() << ".append( '" << aPyFunc[i] << "' )" << endl ;
+        f << "    " << "Py" << Name() << ".append( '" << protectQuotes(aPyFunc[i].in()) << "' )" << endl;
       }
     }
     if ( IsInLineNode() ) {
@@ -1652,12 +1664,15 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
         SUPERV::ListOfStrings aPyMore = *PythonFunctions[1] ;
         SUPERV::ListOfStrings aPyNext = *PythonFunctions[2] ;
         f << "    " << "PyMore" << Name() << " = []" << endl ;
+
         for ( i = 0 ; i < (int ) aPyMore.length() ; i++ ) {
-          f << "    " << "PyMore" << Name() << ".append( '" << aPyMore[i] << "' )" << endl ;
+          f << "    " << "PyMore" << Name() << ".append( '"
+            << protectQuotes(aPyMore[i].in()) << "' )" << endl;
         }
         f << "    " << "PyNext" << Name() << " = []" << endl ;
         for ( i = 0 ; i < (int ) aPyNext.length() ; i++ ) {
-          f << "    " << "PyNext" << Name() << ".append( '" << aPyNext[i] << "' )" << endl ;
+          f << "    " << "PyNext" << Name() << ".append( '"
+            << protectQuotes(aPyNext[i].in()) << "' )" << endl ;
         }
         f << "    " << Name() << "," << EndName << " = " << aGraphName << ".LNode( '"
           << FuncNames[0].c_str() << "' , Py" << Name() << " , '"
@@ -1672,8 +1687,8 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
-          f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
-            << endl ;
+          f << "    " << "Py" << aCoupledNode->Name() << ".append( '"
+            << protectQuotes(aPyFunc[i].in()) << "' )" << endl;
         }
         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
         for ( i = 0 ; i < GetNodeInPortsSize() ; i++ ) {
@@ -1782,8 +1797,8 @@ bool GraphBase::ComputingNode::SavePY( ostream &f , const char * aGraphName ,
         SUPERV::ListOfStrings aPyFunc = *aCoupledNode->PythonFunction() ;
         f << "    " << "Py" << aCoupledNode->Name() << " = []" << endl ;
         for ( i = 0 ; i < (int ) aPyFunc.length() ; i++ ) {
-          f << "    " << "Py" << aCoupledNode->Name() << ".append( '" << aPyFunc[i] << "' )"
-            << endl ;
+          f << "    " << "Py" << aCoupledNode->Name() << ".append( '"
+            << protectQuotes(aPyFunc[i].in()) << "' )" << endl;
         }
         f << "    " << EndName << ".SetPyFunction( '" << aCoupledNode->PyFuncName() << "' , Py" << aCoupledNode->Name() << " )" << endl ;
         for ( i = 0 ; i < aCoupledNode->GetNodeInPortsSize() ; i++ ) {