From: ouv Date: Mon, 24 Nov 2008 12:42:19 +0000 (+0000) Subject: Dump Python extension X-Git-Tag: TG_DumpPython_Extension_3~3 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f1ae8e4642aeb249ad8ef8b5a78821b7de16e483;p=modules%2Fkernel.git Dump Python extension --- diff --git a/idl/SALOMEDS.idl b/idl/SALOMEDS.idl index a52fbbda1..c0a3aaae3 100644 --- a/idl/SALOMEDS.idl +++ b/idl/SALOMEDS.idl @@ -72,6 +72,9 @@ during each working session. /*! An unbounded sequence of strings */ typedef sequence ListOfStrings ; +/*! An unbounded sequence of sequence of strings +*/ + typedef sequence ListOfListOfStrings ; /*! A byte stream which is used for binary data transfer between different components */ typedef sequence 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 ); }; diff --git a/src/SALOMEDS/SALOMEDS_Study.cxx b/src/SALOMEDS/SALOMEDS_Study.cxx index 044722d2f..823751571 100644 --- a/src/SALOMEDS/SALOMEDS_Study.cxx +++ b/src/SALOMEDS/SALOMEDS_Study.cxx @@ -856,18 +856,23 @@ bool SALOMEDS_Study::IsVariableUsed(const string& theVarName) return aResult; } -vector SALOMEDS_Study::ParseVariables(const string& theVars) +vector< vector > SALOMEDS_Study::ParseVariables(const string& theVars) { - vector aResult; + vector< vector > 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 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; } diff --git a/src/SALOMEDS/SALOMEDS_Study.hxx b/src/SALOMEDS/SALOMEDS_Study.hxx index 6c5a5ba9c..3bb7d83fa 100644 --- a/src/SALOMEDS/SALOMEDS_Study.hxx +++ b/src/SALOMEDS/SALOMEDS_Study.hxx @@ -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 ParseVariables(const std::string& theVars); + virtual std::vector< std::vector > ParseVariables(const std::string& theVars); std::string ConvertObjectToIOR(CORBA::Object_ptr theObject); CORBA::Object_ptr ConvertIORToObject(const std::string& theIOR); diff --git a/src/SALOMEDS/SALOMEDS_Study_i.cxx b/src/SALOMEDS/SALOMEDS_Study_i.cxx index e8e908809..2dd8c93ff 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.cxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.cxx @@ -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 aVarNames = _impl->ParseVariables(string(theVarName)); - SALOMEDS::ListOfStrings_var aResult = new SALOMEDS::ListOfStrings; + vector< vector > 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 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(); } diff --git a/src/SALOMEDS/SALOMEDS_Study_i.hxx b/src/SALOMEDS/SALOMEDS_Study_i.hxx index 6ee2028d7..31cb50455 100644 --- a/src/SALOMEDS/SALOMEDS_Study_i.hxx +++ b/src/SALOMEDS/SALOMEDS_Study_i.hxx @@ -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); diff --git a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx index 338b8f17c..8b3737b95 100644 --- a/src/SALOMEDSClient/SALOMEDSClient_Study.hxx +++ b/src/SALOMEDSClient/SALOMEDSClient_Study.hxx @@ -112,7 +112,7 @@ public: const std::string& theNewVarName) = 0; virtual bool IsVariableUsed(const std::string& theVarName) = 0; - virtual std::vector ParseVariables(const std::string& theVars) = 0; + virtual std::vector< std::vector > ParseVariables(const std::string& theVars) = 0; }; diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx index 8b4a1fd40..7f63db567 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.cxx @@ -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 aVector = SALOMEDSImpl_Tool::splitStringWithEmpty( aString, VARIABLE_SEPARATOR ); - for( int i = 0, len = aVector.size(); i < len; i++ ) + vector< vector > 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 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 aVector = SALOMEDSImpl_Tool::splitStringWithEmpty( aCurrentString, VARIABLE_SEPARATOR ); - for( int i = 0, len = aVector.size(); i < len; i++ ) + vector< vector > aSections = ParseVariables( aCurrentString ); + for( int i = 0, n = aSections.size(); i < n; i++ ) { - string aStr = aVector[i]; - if( aStr.compare( theSource ) == 0 ) + vector 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 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 ); } //============================================================================ diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx index 32f465bc8..bc73e4ea6 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Study.hxx @@ -293,7 +293,7 @@ public: const std::string& theDest); void ReplaceVariableAttribute(const std::string& theSource, const std::string& theDest); - std::vector ParseVariables(const std::string& theVariables) const; + std::vector< std::vector > ParseVariables(const std::string& theVariables) const; //Returns a callback SALOMEDSImpl_Callback* GetCallback() { return _cb; } diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx index fcc481455..6ec8e8134 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.cxx @@ -264,6 +264,20 @@ vector 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 > SALOMEDSImpl_Tool::splitStringWithEmpty(const string& theValue, char sep1, char sep2) +{ + vector< vector > aResult; + vector 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) { diff --git a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx index ea53539fa..678b21295 100644 --- a/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx +++ b/src/SALOMEDSImpl/SALOMEDSImpl_Tool.hxx @@ -65,6 +65,12 @@ public: //include empty strings static std::vector 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 > 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);