Salome HOME
Dump Python extension
authorouv <ouv@opencascade.com>
Mon, 24 Nov 2008 12:42:19 +0000 (12:42 +0000)
committerouv <ouv@opencascade.com>
Mon, 24 Nov 2008 12:42:19 +0000 (12:42 +0000)
idl/SALOMEDS.idl
src/SALOMEDS/SALOMEDS_Study.cxx
src/SALOMEDS/SALOMEDS_Study.hxx
src/SALOMEDS/SALOMEDS_Study_i.cxx
src/SALOMEDS/SALOMEDS_Study_i.hxx
src/SALOMEDSClient/SALOMEDSClient_Study.hxx
src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx
src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx
src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx
src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx

index a52fbbda1eea12cdcfb37a364524e917745c67f7..c0a3aaae3358e5e3da1298e1260007fef317d2d4 100644 (file)
@@ -72,6 +72,9 @@ during each working session.
 /*! An unbounded sequence of strings
 */
   typedef sequence<string> ListOfStrings ;
+/*! An unbounded sequence of sequence of strings
+*/
+  typedef sequence<ListOfStrings> ListOfListOfStrings ;
 /*! A byte stream which is used for binary data transfer between different components
 */
   typedef sequence<octet> TMPFile;
@@ -510,7 +513,7 @@ during each working session.
    \param string with variables, separated by special symbol. 
    \return Variables list.
 */
-    ListOfStrings ParseVariables( in string theVars );
+    ListOfListOfStrings ParseVariables( in string theVars );
     
   };
 
index 044722d2f9e1734907443e3f27ae5cd93ece7f8e..8237515713ae4cbed3ec4dc21d99ee3294d622a5 100644 (file)
@@ -856,18 +856,23 @@ bool SALOMEDS_Study::IsVariableUsed(const string& theVarName)
   return aResult;
 }
 
-vector<string> SALOMEDS_Study::ParseVariables(const string& theVars)
+vector< vector<string> > SALOMEDS_Study::ParseVariables(const string& theVars)
 {
-  vector<string> aResult;
+  vector< vector<string> > aResult;
   if (_isLocal) {
     SALOMEDS::Locker lock;
     aResult = _local_impl->ParseVariables(theVars);
   }
   else {
-    SALOMEDS::ListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
-    int aLength = aSeq->length();
-    for (int i = 0; i < aLength; i++) 
-      aResult.push_back( string(aSeq[i].in()) );
+    SALOMEDS::ListOfListOfStrings_var aSeq = _corba_impl->ParseVariables(theVars.c_str());
+    for (int i = 0, n = aSeq->length(); i < n; i++) {
+      vector<string> aVector;
+      SALOMEDS::ListOfStrings aSection = aSeq[i];
+      for (int j = 0, m = aSection.length(); j < m; j++) {
+       aVector.push_back( string(aSection[j].in()) );
+      }
+      aResult.push_back( aVector );
+    }
   }
   return aResult;
 }
index 6c5a5ba9c248a816b91ecde1f6cb44f7801cec38..3bb7d83fa74abd542b1bff40a5feb536146f8057 100644 (file)
@@ -114,7 +114,7 @@ public:
   virtual bool RemoveVariable(const std::string& theVarName);
   virtual bool RenameVariable(const std::string& theVarName, const std::string& theNewVarName);
   virtual bool IsVariableUsed(const std::string& theVarName);
-  virtual std::vector<std::string> ParseVariables(const std::string& theVars);
+  virtual std::vector< std::vector<std::string> > ParseVariables(const std::string& theVars);
 
   std::string ConvertObjectToIOR(CORBA::Object_ptr theObject);
   CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR);     
index e8e90880915ecc9346fadcd8b3c8a48da58c9645..2dd8c93ff2f7d0cefab73cd1f1111a4dd13f0484 100644 (file)
@@ -1007,17 +1007,29 @@ CORBA::Boolean SALOMEDS_Study_i::IsVariableUsed(const char* theVarName)
  *  Purpose  : 
  */
 //============================================================================
-SALOMEDS::ListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
+SALOMEDS::ListOfListOfStrings* SALOMEDS_Study_i::ParseVariables(const char* theVarName)
 {
-  vector<string> aVarNames = _impl->ParseVariables(string(theVarName));
-  SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings;
+  vector< vector<string> > aSections = _impl->ParseVariables(string(theVarName));
 
-  int aLen = aVarNames.size();
-  aResult->length(aLen);
+  SALOMEDS::ListOfListOfStrings_var aResult = new SALOMEDS::ListOfListOfStrings;
+
+  int aSectionsLen = aSections.size();
+  aResult->length(aSectionsLen);
+
+  for (int aSectionInd = 0; aSectionInd < aSectionsLen; aSectionInd++) {
+    vector<string> aVarNames = aSections[aSectionInd];
+
+    SALOMEDS::ListOfStrings_var aList = new SALOMEDS::ListOfStrings;
+
+    int aLen = aVarNames.size();
+    aList->length(aLen);
+
+    for (int anInd = 0; anInd < aLen; anInd++)
+      aList[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
+
+    aResult[aSectionInd] = aList;
+  }
 
-  for (int anInd = 0; anInd < aLen; anInd++)
-    aResult[anInd] = CORBA::string_dup(aVarNames[anInd].c_str());
-  
   return aResult._retn();
 }
 
index 6ee2028d78e4af5deabe523c8370c8d8634ac0a4..31cb5045583fa4e781dbc19ceb7a8f5914a79412 100644 (file)
@@ -322,7 +322,7 @@ public:
 
   virtual CORBA::Boolean IsVariableUsed(const char* theVarName);
   
-  virtual SALOMEDS::ListOfStrings* ParseVariables(const char* theVars);
+  virtual SALOMEDS::ListOfListOfStrings* ParseVariables(const char* theVars);
 
   virtual char* GetDefaultScript(const char* theModuleName, const char* theShift);
 
index 338b8f17c3bca98067aad5871b176eda687bac93..8b3737b952ad3b6078776c3d4d1810095ecc90e7 100644 (file)
@@ -112,7 +112,7 @@ public:
                              const std::string& theNewVarName) = 0;
   virtual bool IsVariableUsed(const std::string& theVarName) = 0;
 
-  virtual std::vector<std::string> ParseVariables(const std::string& theVars) = 0;
+  virtual std::vector< std::vector<std::string> > ParseVariables(const std::string& theVars) = 0;
   
 };
 
index 8b4a1fd409891ee0a7e28e074203468ded711173..7f63db5672f25a8869e5bfefc54c83f1cd6dee12 100644 (file)
@@ -43,7 +43,8 @@ using namespace std;
 #define DIRECTORYID       16661
 #define FILELOCALID       26662
 #define FILEID            "FILE: "
-#define VARIABLE_SEPARATOR ':'
+#define VARIABLE_SEPARATOR  ':'
+#define OPERATION_SEPARATOR '|'
 
 
 //============================================================================
@@ -1749,12 +1750,16 @@ bool SALOMEDSImpl_Study::FindVariableAttribute(SALOMEDSImpl_StudyBuilder* theStu
     {
       string aString = aStringAttr->Value();
 
-      vector<string> aVector = SALOMEDSImpl_Tool::splitStringWithEmpty( aString, VARIABLE_SEPARATOR );
-      for( int i = 0, len = aVector.size(); i < len; i++ )
+      vector< vector<string> > aSections = ParseVariables( aString );
+      for( int i = 0, n = aSections.size(); i < n; i++ )
       {
-       string aStr = aVector[i];
-       if( aStr.compare( theName ) == 0 )
-         return true;
+       vector<string> aVector = aSections[i];
+       for( int j = 0, m = aVector.size(); j < m; j++ )
+       {
+         string aStr = aVector[j];
+         if( aStr.compare( theName ) == 0 )
+           return true;
+       }
       }
     }
   }
@@ -1801,19 +1806,25 @@ void SALOMEDSImpl_Study::ReplaceVariableAttribute(SALOMEDSImpl_StudyBuilder* the
       bool isChanged = false;
       string aNewString, aCurrentString = aStringAttr->Value();
 
-      vector<string> aVector = SALOMEDSImpl_Tool::splitStringWithEmpty( aCurrentString, VARIABLE_SEPARATOR );
-      for( int i = 0, len = aVector.size(); i < len; i++ )
+      vector< vector<string> > aSections = ParseVariables( aCurrentString );
+      for( int i = 0, n = aSections.size(); i < n; i++ )
       {
-       string aStr = aVector[i];
-       if( aStr.compare( theSource ) == 0 )
+       vector<string> aVector = aSections[i];
+       for( int j = 0, m = aVector.size(); j < m; j++ )
        {
-         isChanged = true;
-         aStr = theDest;
-       }
+         string aStr = aVector[j];
+         if( aStr.compare( theSource ) == 0 )
+         {
+           isChanged = true;
+           aStr = theDest;
+         }
 
-       aNewString.append( aStr );
-       if( i != len - 1 )
-         aNewString.append( ":" );
+         aNewString.append( aStr );
+         if( j != m - 1 )
+           aNewString.append( ":" );
+       }
+       if( i != n - 1 )
+         aNewString.append( "|" );
       }
 
       if( isChanged )
@@ -1839,13 +1850,13 @@ void SALOMEDSImpl_Study::ReplaceVariableAttribute(const std::string& theSource,
 }
 
 //============================================================================
-/*! Function : EnableUseCaseAutoFilling
+/*! Function : ParseVariables
  *  Purpose  :
  */
 //============================================================================
-vector<string> SALOMEDSImpl_Study::ParseVariables(const string& theVariables) const
+vector< vector< string > > SALOMEDSImpl_Study::ParseVariables(const string& theVariables) const
 {
-  return SALOMEDSImpl_Tool::splitStringWithEmpty( theVariables, VARIABLE_SEPARATOR );
+  return SALOMEDSImpl_Tool::splitStringWithEmpty( theVariables, OPERATION_SEPARATOR, VARIABLE_SEPARATOR );
 }
 
 //============================================================================
index 32f465bc818903d985176b13cfaf75d866726b64..bc73e4ea6308d3e1c58716b7e6cf6bd3e6ff2b35 100644 (file)
@@ -293,7 +293,7 @@ public:
                                const std::string& theDest);
   void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest);
 
-  std::vector<std::string> ParseVariables(const std::string& theVariables) const;
+  std::vector< std::vector<std::string> > ParseVariables(const std::string& theVariables) const;
 
   //Returns a callback 
   SALOMEDSImpl_Callback* GetCallback() { return _cb; }
index fcc481455f01506f85ffb7218071bf1b4427d271..6ec8e81348f9e2233b9d010df1dd8737557c438a 100644 (file)
@@ -264,6 +264,20 @@ vector<string> SALOMEDSImpl_Tool::splitStringWithEmpty(const string& theValue, c
   return aResult;
 }
 
+//============================================================================
+// function : 
+// purpose  : The functions returns a list of lists of substrings of initial string 
+//            divided by two given separators include empty strings
+//============================================================================
+vector< vector<string> > SALOMEDSImpl_Tool::splitStringWithEmpty(const string& theValue, char sep1, char sep2)
+{
+  vector< vector<string> > aResult;
+  vector<string> aSections = splitStringWithEmpty( theValue, sep1 );
+  for( int i = 0, n = aSections.size(); i < n; i++ )
+    aResult.push_back( splitStringWithEmpty( aSections[i], sep2 ) );
+  return aResult;
+}
+
 
 void SALOMEDSImpl_Tool::GetSystemDate(int& year, int& month, int& day, int& hours, int& minutes, int& seconds)
 {
index ea53539fa7161de506b5130e6d58f892d299b79d..678b21295c5c95597d132b3ca50137778d762d8c 100644 (file)
@@ -65,6 +65,12 @@ public:
   //include empty strings
   static std::vector<std::string> splitStringWithEmpty(const std::string& theValue, char separator);
   
+  //The functions returns a list of substring of initial string divided by given separator, 
+  //include empty strings
+  static std::vector< std::vector<std::string> > splitStringWithEmpty(const std::string& theValue,
+                                                                     char separator1,
+                                                                     char separator2);
+  
 
   //Returns a system date  
   static void GetSystemDate(int& year, int& month, int& day, int& hours, int& minutes, int& seconds);