From 82d77994ee1981809cb599b663b5b117285f2d90 Mon Sep 17 00:00:00 2001 From: asl Date: Wed, 25 Nov 2009 08:21:35 +0000 Subject: [PATCH] minor formatting --- src/Notebook/SALOME_EvalExpr.cxx | 84 +++-- src/Notebook/SALOME_EvalExpr.hxx | 25 +- src/Notebook/SALOME_EvalParser.cxx | 536 ++++++++++++++--------------- src/Notebook/SALOME_EvalParser.hxx | 99 +++--- src/Notebook/SALOME_EvalSet.hxx | 5 +- src/Notebook/SALOME_Parameter.cxx | 2 +- src/Notebook/SALOME_Parameter.hxx | 1 + 7 files changed, 355 insertions(+), 397 deletions(-) diff --git a/src/Notebook/SALOME_EvalExpr.cxx b/src/Notebook/SALOME_EvalExpr.cxx index e52fd0857..667f91044 100755 --- a/src/Notebook/SALOME_EvalExpr.cxx +++ b/src/Notebook/SALOME_EvalExpr.cxx @@ -23,58 +23,48 @@ // Author : Peter KURNEV // Module : SALOME - - #include +#include //======================================================================= -//function : -//purpose : -//======================================================================= -SALOME_EvalExpr::SALOME_EvalExpr( const SALOME_String& expr ) -{ - myParser=NULL; - initialize( true, expr ); -} -//======================================================================= -//function : +//function : Constructor //purpose : //======================================================================= -SALOME_EvalExpr::SALOME_EvalExpr( const bool stdSets, const SALOME_String& expr ) +SALOME_EvalExpr::SALOME_EvalExpr( const SALOME_String& theExpr, const bool isStdSets ) { - myParser=NULL; - initialize( stdSets, expr ); + myParser = 0; + initialize( theExpr, isStdSets ); } + //======================================================================= -//function : ~ +//function : Destructor //purpose : //======================================================================= SALOME_EvalExpr::~SALOME_EvalExpr() { - if (myParser) { - delete myParser; - } + delete myParser; } + //======================================================================= //function : error //purpose : //======================================================================= SALOME_EvalExprError SALOME_EvalExpr::error() const { - return myParser->error(); + return myParser ? myParser->error() : EvalExpr_OK; } + //======================================================================= //function : initialize //purpose : //======================================================================= -void SALOME_EvalExpr::initialize( const bool stdSets, const SALOME_String& expr ) +void SALOME_EvalExpr::initialize( const SALOME_String& theExpr, const bool isStdSets ) { - if (myParser) { - delete myParser; - } + delete myParser; myParser = new SALOME_EvalParser(); - if ( stdSets ) { + if( isStdSets ) + { myParser->setAutoDeleteOperationSets( true ); myParser->insertOperationSet( new SALOME_EvalSetLogic() ); myParser->insertOperationSet( new SALOME_EvalSetArithmetic() ); @@ -83,19 +73,19 @@ void SALOME_EvalExpr::initialize( const bool stdSets, const SALOME_String& expr myParser->insertOperationSet( new SALOME_EvalSetSets() ); myParser->insertOperationSet( new SALOME_EvalSetConst() ); } - setExpression( expr ); + setExpression( theExpr ); } + //======================================================================= //function : calculate //purpose : //======================================================================= -SALOME_EvalVariant SALOME_EvalExpr::calculate(const SALOME_String& expr) +SALOME_EvalVariant SALOME_EvalExpr::calculate( const SALOME_String& theExpr ) { - if ( !expr.empty() ) { - setExpression( expr ); - } + setExpression( theExpr ); return myParser->calculate(); } + //======================================================================= //function : expression //purpose : @@ -104,18 +94,20 @@ SALOME_String SALOME_EvalExpr::expression() const { return myExpr; } + //======================================================================= //function : setExpression //purpose : //======================================================================= -void SALOME_EvalExpr::setExpression(const SALOME_String& expr) +void SALOME_EvalExpr::setExpression( const SALOME_String& theExpr ) { - if ( expr == expression() ){ + if( theExpr == expression() ) return; - } - myExpr = expr; + + myExpr = theExpr; myParser->setExpression( myExpr ); } + //======================================================================= //function : parser //purpose : @@ -131,32 +123,36 @@ SALOME_EvalParser* SALOME_EvalExpr::parser() const //======================================================================= SALOME_ListOfEvalSet SALOME_EvalExpr::operationSets() const { - return myParser->operationSets(); + return myParser ? myParser->operationSets() : SALOME_ListOfEvalSet(); } + //======================================================================= //function : insertOperationSet //purpose : //======================================================================= -void SALOME_EvalExpr::insertOperationSet(SALOME_EvalSet* theSet, const int idx) +void SALOME_EvalExpr::insertOperationSet( SALOME_EvalSet* theSet, const int theIndex ) { - myParser->insertOperationSet(theSet, idx); + myParser->insertOperationSet( theSet, theIndex ); } + //======================================================================= //function : removeOperationSet //purpose : //======================================================================= -void SALOME_EvalExpr::removeOperationSet(SALOME_EvalSet* theSet) +void SALOME_EvalExpr::removeOperationSet( SALOME_EvalSet* theSet ) { - myParser->removeOperationSet(theSet); + myParser->removeOperationSet( theSet ); } + //======================================================================= //function : operationSet //purpose : //======================================================================= -SALOME_EvalSet* SALOME_EvalExpr::operationSet(const SALOME_String& name) const +SALOME_EvalSet* SALOME_EvalExpr::operationSet( const SALOME_String& theName ) const { - return myParser->operationSet( name ); + return myParser->operationSet( theName ); } + //======================================================================= //function : autoDeleteOperationSets //purpose : @@ -170,9 +166,9 @@ bool SALOME_EvalExpr::autoDeleteOperationSets() const //function : setAutoDeleteOperationSets //purpose : //======================================================================= -void SALOME_EvalExpr::setAutoDeleteOperationSets(const bool on) +void SALOME_EvalExpr::setAutoDeleteOperationSets( const bool isAutoDel ) { - myParser->setAutoDeleteOperationSets( on ); + myParser->setAutoDeleteOperationSets( isAutoDel ); } //======================================================================= @@ -182,5 +178,5 @@ void SALOME_EvalExpr::setAutoDeleteOperationSets(const bool on) void SALOME_EvalExpr::substitute( const SALOME_String& theParamName, const SALOME_EvalExpr& theExpr ) { myParser->substitute( theParamName, theExpr.parser() ); - myExpr = myParser->rebuildExpression(); + myExpr = myParser->reverseBuild(); } diff --git a/src/Notebook/SALOME_EvalExpr.hxx b/src/Notebook/SALOME_EvalExpr.hxx index 28c4c0d02..ac131c09c 100755 --- a/src/Notebook/SALOME_EvalExpr.hxx +++ b/src/Notebook/SALOME_EvalExpr.hxx @@ -27,37 +27,38 @@ #define SALOME_EvalExpr_Header_File #include -#include -#include -#include + +class SALOME_EvalVariant; +class SALOME_EvalParser; +class SALOME_EvalSet; +class SALOME_ListOfEvalSet; class SALOME_EvalExpr { public: - SALOME_EvalExpr( const SALOME_String& = SALOME_String() ); - SALOME_EvalExpr( const bool, const SALOME_String& = SALOME_String() ); + SALOME_EvalExpr( const SALOME_String& theExpr = SALOME_String(), const bool isStdSets = true ); ~SALOME_EvalExpr(); - SALOME_EvalVariant calculate( const SALOME_String& = SALOME_String() ); + SALOME_EvalVariant calculate( const SALOME_String& theExpr = SALOME_String() ); SALOME_String expression() const; - void setExpression( const SALOME_String& ); + void setExpression( const SALOME_String& theExpr ); SALOME_EvalExprError error() const; SALOME_EvalParser* parser() const; bool autoDeleteOperationSets() const; - void setAutoDeleteOperationSets( const bool ); + void setAutoDeleteOperationSets( const bool isAutoDel ); SALOME_ListOfEvalSet operationSets() const; - SALOME_EvalSet* operationSet( const SALOME_String& ) const; - void removeOperationSet( SALOME_EvalSet* ); - void insertOperationSet( SALOME_EvalSet*, const int = -1 ); + SALOME_EvalSet* operationSet( const SALOME_String& theName ) const; + void removeOperationSet( SALOME_EvalSet* theSet ); + void insertOperationSet( SALOME_EvalSet* theSet, const int theIndex = -1 ); void substitute( const SALOME_String& theParamName, const SALOME_EvalExpr& theExpr ); private: - void initialize( const bool, const SALOME_String& ); + void initialize( const SALOME_String& theExpr, const bool isStdSets ); private: SALOME_String myExpr; diff --git a/src/Notebook/SALOME_EvalParser.cxx b/src/Notebook/SALOME_EvalParser.cxx index f5fb86b06..a9340c426 100755 --- a/src/Notebook/SALOME_EvalParser.cxx +++ b/src/Notebook/SALOME_EvalParser.cxx @@ -28,14 +28,111 @@ #include #include -bool contains(const SALOME_StringList& aLS, const SALOME_String& aS); -SALOME_String trimmed(const SALOME_String& str); -SALOME_String trimmed(const SALOME_String& str, const char aWhat); -bool isSpace(const char aC); -int indexOf(const SALOME_StringList& aLS, const SALOME_String& aS); +//======================================================================= +//function : contains +//purpose : +//======================================================================= +bool contains( const SALOME_StringList& theList, const SALOME_String& theItem ) +{ + return find( theList.begin(), theList.end(), theItem ) != theList.end(); +} + +//======================================================================= +//function : trimmed +//purpose : +//======================================================================= +SALOME_String trimmed( const SALOME_String& theStr, const char theTrimmed ) +{ + char aX[2]; + size_t mylength, i; + SALOME_String aRet; + + const char* mystring=theStr.c_str(); + if(!mystring) { + return aRet; + } + + mylength=strlen(mystring); + if (!mylength) { + return aRet; + } + + aX[1]=0; + for (i=0; iname()==theName ) { + SALOME_EvalSet* pSet = 0; + SALOME_ListOfEvalSet::const_iterator it = mySets.begin(), last = mySets.end(); + for( ; it!=last && !pSet; it++ ) + if( (*it)->name()==theName ) pSet = *it; - } - } return pSet; } + //======================================================================= //function : insertOperationSet //purpose : //======================================================================= -void SALOME_EvalParser::insertOperationSet(SALOME_EvalSet* theSet, - const int idx) +void SALOME_EvalParser::insertOperationSet( SALOME_EvalSet* theSet, const int theIndex ) { - if (SALOME_EvalSet::contains(mySets, theSet)) { + if( SALOME_EvalSet::contains( mySets, theSet ) ) return; - } - // - int iSize=(int)mySets.size(); - int index = idx < 0 ? iSize : idx; - if (index>iSize) { - index=iSize; - } - SALOME_EvalSet::insert(mySets, index, theSet); + + int aSize = (int)mySets.size(); + int anIndex = theIndex < 0 ? aSize : theIndex; + if( anIndex > aSize ) + anIndex = aSize; + SALOME_EvalSet::insert( mySets, anIndex, theSet ); } + //======================================================================= //function : removeOperationSet //purpose : //======================================================================= -void SALOME_EvalParser::removeOperationSet(SALOME_EvalSet* theSet) +void SALOME_EvalParser::removeOperationSet( SALOME_EvalSet* theSet ) { - //mySets.removeAll( theSet ); - mySets.remove(theSet); + mySets.remove( theSet ); } + //======================================================================= //function : autoDeleteOperationSets //purpose : @@ -121,19 +211,21 @@ bool SALOME_EvalParser::autoDeleteOperationSets() const { return myAutoDel; } + //======================================================================= //function : setAutoDeleteOperationSets //purpose : //======================================================================= -void SALOME_EvalParser::setAutoDeleteOperationSets( const bool theOn ) +void SALOME_EvalParser::setAutoDeleteOperationSets( const bool isAutoDel ) { - myAutoDel = theOn; + myAutoDel = isAutoDel; } + //======================================================================= //function : search //purpose : //======================================================================= -int SALOME_EvalParser::search(const SALOME_StringList& aList, const SALOME_String& aStr, int offset, int& matchLen, int& listind ) +int SALOME_EvalParser::search( const SALOME_StringList& aList, const SALOME_String& aStr, int offset, int& matchLen, int& listind ) { int min = -1; int ind = 0; @@ -180,150 +272,140 @@ SALOME_String SALOME_EvalParser::note(const SALOME_String& aStr, int pos, int le //function : prepare //purpose : //======================================================================= -bool SALOME_EvalParser::prepare(const SALOME_String& expr, Postfix& post) +bool SALOME_EvalParser::prepare( const SALOME_String& theExpr, Postfix& thePostfix ) { - int pos = 0; - int len =(int)expr.length(); + int aPos = 0; + int aLen = (int)theExpr.length(); stack aBracketStack; SALOME_StringList anOpers, anOpenBr, aCloseBr; + if ( !checkOperations() ) return false; - bracketsList( anOpenBr, true ); - bracketsList( aCloseBr, false ); + bracketsList( anOpenBr, aCloseBr ); operationList( anOpers ); - while ( pos < len && error() == EvalExpr_OK ) { - PostfixItem item; - char aC=expr[pos]; - // - while ( pos < len && isSpace(aC) ) { - pos++; - } - // - if ( pos >= len ) { + while( aPos < aLen && error() == EvalExpr_OK ) + { + PostfixItem anItem; + char aChar = theExpr[aPos]; + + while( aPos < aLen && isSpace( aChar ) ) + aPos++; + + if ( aPos >= aLen ) break; - } - // - int mBrLen = 0, mLen = 0, br_ind = -1, op_ind = -1; - int oPos = search( anOpenBr, expr, pos, mBrLen, br_ind ); - int cPos = oPos == pos ? -1 : search( aCloseBr, expr, pos, mBrLen, br_ind ); - int opPos = search( anOpers, expr, pos, mLen, op_ind ); - // - if ( aC=='\'') { - int vpos = pos + 1; - while ( vpos < (int)expr.length() && expr[vpos] != '\'' ) { + + int aBrLen = 0, mLen = 0, aBrInd = -1, anOpInd = -1; + int oPos = search( anOpenBr, theExpr, aPos, aBrLen, aBrInd ); + int cPos = oPos == aPos ? -1 : search( aCloseBr, theExpr, aPos, aBrLen, aBrInd ); + int opPos = search( anOpers, theExpr, aPos, mLen, anOpInd ); + + if( aChar=='\'') + { + int vpos = aPos + 1; + while ( vpos < aLen && theExpr[vpos] != '\'' ) vpos++; - } - // - mLen = vpos - pos + 1; - // - int res = createValue( note( expr, pos, mLen ), item.myValue ); - item.myType = res ? Value : Param; - post.push_back( item ); - pos = vpos + 1; + + mLen = vpos - aPos + 1; + bool ok = createValue( note( theExpr, aPos, mLen ), anItem.myValue ); + anItem.myType = ok ? Value : Param; + thePostfix.push_back( anItem ); + aPos = vpos + 1; continue; } - // - if ( oPos == pos ) { - aBracketStack.push( br_ind ); - item.myValue = note( expr, pos, mBrLen ); - item.myType = Open; - post.push_back( item ); + + if ( oPos == aPos ) + { + aBracketStack.push( aBrInd ); + anItem.myValue = note( theExpr, aPos, aBrLen ); + anItem.myType = Open; + thePostfix.push_back( anItem ); } - else if ( cPos == pos ) { - if ( aBracketStack.size() == 0 ) { + else if ( cPos == aPos ) + { + if ( aBracketStack.size() == 0 ) + { setError( EvalExpr_ExcessClose ); break; } - if ( br_ind != aBracketStack.top() ) { + if ( aBrInd != aBracketStack.top() ) + { setError( EvalExpr_BracketsNotMatch ); break; } - else { + else + { aBracketStack.pop(); - item.myValue = note( expr, pos, mBrLen ); - item.myType = Close; - post.push_back( item ); + anItem.myValue = note( theExpr, aPos, aBrLen ); + anItem.myType = Close; + thePostfix.push_back( anItem ); } } - else { - mBrLen = 0; - } - // - if ( opPos == pos ) { - mBrLen = 0; - item.myValue = note( expr, pos, mLen ); - item.myType = Binary; + else + aBrLen = 0; - if ( oPos == pos ) { - insert(post, (int)(post.size()-1), item); - } + if ( opPos == aPos ) + { + aBrLen = 0; + anItem.myValue = note( theExpr, aPos, mLen ); + anItem.myType = Binary; + + if( oPos == aPos ) + insert(thePostfix, (int)(thePostfix.size()-1), anItem); else - post.push_back( item ); + thePostfix.push_back( anItem ); } - else { + else + { mLen = 0; - if ( oPos != pos && cPos != pos ) { - int i; - for ( i = pos + 1; i < (int)expr.length(); i++ ) { - if ( isSpace(expr[i]) ) { + if( oPos != aPos && cPos != aPos ) + { + int i; + for( i = aPos + 1; i < aLen; i++ ) + if( isSpace( theExpr[i] ) ) break; - } - } - // + int vpos = i; - if ( oPos >= 0 && oPos < vpos ) { + if ( oPos >= 0 && oPos < vpos ) vpos = oPos; - } - if ( cPos >= 0 && cPos < vpos ){ + if ( cPos >= 0 && cPos < vpos ) vpos = cPos; - } - if ( opPos >= 0 && opPos < vpos ){ + if ( opPos >= 0 && opPos < vpos ) vpos = opPos; - } - while( vpos < (int)expr.length() && - ( isalpha(expr[vpos]) || - isdigit(expr[vpos]) || - expr[vpos]=='_' ) - ) { + while( vpos < aLen && ( isalpha( theExpr[vpos] ) || isdigit( theExpr[vpos] ) || theExpr[vpos]=='_' ) ) vpos++; - } - // - mLen = vpos - pos; - bool res = createValue( note( expr, pos, mLen ), item.myValue ); - item.myType = res ? Value : Param; - post.push_back( item ); + + mLen = vpos - aPos; + bool ok = createValue( note( theExpr, aPos, mLen ), anItem.myValue ); + anItem.myType = ok ? Value : Param; + thePostfix.push_back( anItem ); } } - pos += mBrLen + mLen; + aPos += aBrLen + mLen; } //Bracket checking - int brValue = 0; - for ( Postfix::iterator anIt = post.begin(); anIt != post.end(); ++anIt ) { - if ( (*anIt).myType == Open ){ - brValue++; - } - else if ( (*anIt).myType == Close ) { - if ( brValue > 0 ){ - brValue--; - } - else { + int aBrValue = 0; + for( Postfix::iterator it = thePostfix.begin(), last = thePostfix.end(); it != last; it++ ) + if( it->myType == Open ) + aBrValue++; + else if( it->myType == Close ) + if( aBrValue > 0 ) + aBrValue--; + else + { setError( EvalExpr_ExcessClose ); break; } - } - } - // - if ( brValue > 0 ) - { + + if( aBrValue > 0 ) setError( EvalExpr_CloseExpected ); - } - // + return error() == EvalExpr_OK; } + //======================================================================= //function : setOperationTypes //purpose : @@ -334,9 +416,7 @@ bool SALOME_EvalParser::setOperationTypes( Postfix& post ) return false; SALOME_StringList anOpen, aClose; - // - bracketsList( anOpen, true ); - bracketsList( aClose, false ); + bracketsList( anOpen, aClose ); Postfix::iterator aPrev, aNext; Postfix::iterator anIt = post.begin(); @@ -588,8 +668,7 @@ bool SALOME_EvalParser::parse( const SALOME_String& expr ) SALOME_StringList opens, closes; setError( EvalExpr_OK ); - bracketsList( opens, true ); - bracketsList( closes, false ); + bracketsList( opens, closes ); return prepare( expr, p ) && setOperationTypes( p ) && sort( p, myPostfix, opens, closes ); } @@ -625,12 +704,10 @@ SALOME_EvalVariant SALOME_EvalParser::calculate() return SALOME_EvalVariant(); setError( EvalExpr_OK ); - // - SALOME_StringList anOpen, aClose; + PostfixItemType aType; - // - bracketsList( anOpen, true ); - bracketsList( aClose, false ); + SALOME_StringList anOpen, aClose; + bracketsList( anOpen, aClose ); stack aStack; Postfix::iterator anIt = myPostfix.begin(), aLast = myPostfix.end(); @@ -950,7 +1027,7 @@ private: //function : rebuildExpression //purpose : //======================================================================= -SALOME_String SALOME_EvalParser::rebuildExpression() const +SALOME_String SALOME_EvalParser::reverseBuild() const { std::stack aStack; @@ -1096,18 +1173,25 @@ void SALOME_EvalParser::operationList( SALOME_StringList& theList ) const //function : operationList //purpose : //======================================================================= -void SALOME_EvalParser::bracketsList( SALOME_StringList& theList, bool open ) const +void SALOME_EvalParser::bracketsList( SALOME_StringList& theOpens, SALOME_StringList& theCloses ) const { - SALOME_ListOfEvalSet::const_iterator it = mySets.begin(); - for (; it != mySets.end(); ++it ) { - SALOME_StringList custom; - SALOME_EvalSet* aSet = *it; - aSet->bracketsList( custom, open ); - SALOME_StringList::const_iterator sIt = custom.begin(); - for (; sIt != custom.end(); ++sIt ) { - if ( !contains(theList, *sIt ) ) - theList.push_back( *sIt ); - } + SALOME_ListOfEvalSet::const_iterator it = mySets.begin(), last = mySets.end(); + for( ; it!=last; it++ ) + { + SALOME_StringList aCustom; + + (*it)->bracketsList( aCustom, true ); + SALOME_StringList::const_iterator sIt = aCustom.begin(), sLast = aCustom.end(); + for( ; sIt != sLast; sIt++ ) + if( !contains( theOpens, *sIt ) ) + theOpens.push_back( *sIt ); + + aCustom.clear(); + (*it)->bracketsList( aCustom, false ); + sIt = aCustom.begin(); sLast = aCustom.end(); + for( ; sIt != sLast; sIt++ ) + if( !contains( theCloses, *sIt ) ) + theCloses.push_back( *sIt ); } } //======================================================================= @@ -1234,9 +1318,7 @@ const SALOME_EvalParser::PostfixItem& SALOME_EvalParser::at(const Postfix& aL, //function : insert //purpose : //======================================================================= -void SALOME_EvalParser::insert(Postfix& aL, - const int aIndex, - PostfixItem& pS) +void SALOME_EvalParser::insert( Postfix& aL, const int aIndex, const PostfixItem& pS ) { int i; // @@ -1256,121 +1338,3 @@ void SALOME_EvalParser::insert(Postfix& aL, } } } -//======================================================================= -//function : indexOf -//purpose : -//======================================================================= -int indexOf( const SALOME_StringList& aLS, const SALOME_String& aS ) -{ - int i, iRet; - SALOME_StringList::const_iterator aIt; - // - iRet=-1; - // - aIt=aLS.begin(); - for (i=0; aIt!=aLS.end(); ++aIt, ++i) - { - const SALOME_String aSx=*aIt; - if (aSx==aS) { - iRet=i; - break; - } - } - return iRet; -} -//======================================================================= -//function : contains -//purpose : -//======================================================================= -bool contains( const SALOME_StringList& aLS, const SALOME_String& aS ) -{ - bool bRet; - // - bRet=false; - SALOME_StringList::const_iterator aIt; - // - aIt=aLS.begin(); - for (; aIt!=aLS.end(); ++aIt) { - const SALOME_String aSx=*aIt; - if (aSx==aS) { - bRet=!bRet; - break; - } - } - return bRet; -} - - -//======================================================================= -//function : isSpace -//purpose : -//======================================================================= -bool isSpace(const char aC) -{ - bool bRet; - char aWhat[]={ - '\t', '\n', '\v', '\f', '\r', ' ' - }; - int i, aNb; - // - bRet=false; - aNb=sizeof(aWhat)/sizeof(aWhat[0]); - for (i=0; i #include -// #include #include #include @@ -43,39 +42,33 @@ public: SALOME_EvalParser(); virtual ~SALOME_EvalParser(); - SALOME_EvalVariant calculate(); - SALOME_EvalVariant calculate( const SALOME_String& ); - bool setExpression( const SALOME_String& ); - - SALOME_ListOfEvalSet operationSets() const; - SALOME_EvalSet* operationSet( const SALOME_String& ) const; - void removeOperationSet( SALOME_EvalSet* ); - void insertOperationSet( SALOME_EvalSet*, const int = -1 ); - - bool autoDeleteOperationSets() const; - void setAutoDeleteOperationSets( const bool ); - - virtual void clearParameters(); - virtual bool removeParameter( const SALOME_String& name ); - virtual SALOME_EvalVariant parameter( const SALOME_String& name ) const; - virtual bool hasParameter( const SALOME_String& name ) const; - virtual void setParameter( const SALOME_String& name, const SALOME_EvalVariant& value ); - SALOME_StringList parameters() const; - - SALOME_EvalExprError error() const; - - bool firstInvalid( SALOME_String& ) const; + bool setExpression ( const SALOME_String& theExpr ); + SALOME_EvalExprError error () const; + SALOME_EvalVariant calculate (); + SALOME_EvalVariant calculate ( const SALOME_String& theExpr ); + void substitute ( const SALOME_String& theParamName, SALOME_EvalParser* theNewExpr ); + SALOME_String reverseBuild () const; + bool firstInvalid ( SALOME_String& theItem ) const; void removeInvalids(); - SALOME_String dump() const; - static SALOME_String toString( const SALOME_ListOfEvalVariant& ); + SALOME_ListOfEvalSet operationSets () const; + SALOME_EvalSet* operationSet ( const SALOME_String& theName ) const; + void removeOperationSet ( SALOME_EvalSet* theSet ); + void insertOperationSet ( SALOME_EvalSet* theSet, const int theIndex = -1 ); + bool autoDeleteOperationSets () const; + void setAutoDeleteOperationSets( const bool isAutoDel ); - bool isMonoParam() const; + SALOME_String dump() const; - void substitute( const SALOME_String& theParamName, - SALOME_EvalParser* theNewExpr ); + virtual void clearParameters(); + virtual bool removeParameter( const SALOME_String& theName ); + virtual SALOME_EvalVariant parameter ( const SALOME_String& theName ) const; + virtual bool hasParameter ( const SALOME_String& theName ) const; + virtual void setParameter ( const SALOME_String& theName, const SALOME_EvalVariant& theValue ); + SALOME_StringList parameters () const; + bool isMonoParam () const; - SALOME_String rebuildExpression() const; + static SALOME_String toString( const SALOME_ListOfEvalVariant& theList ); protected: //! Types of postfix representation elements @@ -105,31 +98,31 @@ protected: protected: SALOME_String dump( const Postfix& ) const; - virtual bool prepare( const SALOME_String&, Postfix& ); - virtual bool setOperationTypes( Postfix& ); - virtual bool sort( const Postfix&, Postfix&, const SALOME_StringList&, const SALOME_StringList&, int f = -1, int l = -1 ); - virtual bool parse( const SALOME_String& ); - virtual void setError( const SALOME_EvalExprError ); - - bool calculate( const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ); + virtual bool prepare ( const SALOME_String& theExpr, Postfix& thePostfix ); + virtual bool setOperationTypes( Postfix& thePostfix ); + virtual bool sort ( const Postfix& theInitPostfix, Postfix& theResPostfix, const SALOME_StringList& theOpen, + const SALOME_StringList& theClose, int theFirst = -1, int theLast = -1 ); + virtual bool parse ( const SALOME_String& theExpr ); + virtual void setError ( const SALOME_EvalExprError theErr ); - static int search( const SALOME_StringList&, const SALOME_String&, int offset, int& matchLen, int& listind ); - static SALOME_String note( const SALOME_String& str, int pos, int len ); - static int globalBrackets( const Postfix&, int, int ); + bool calculate ( const SALOME_String& theExpr, SALOME_EvalVariant& theArg1, SALOME_EvalVariant& theArg2 ); + static int search ( const SALOME_StringList& theList, const SALOME_String& theItem, int theOffset, + int& theMatchLen, int& theIndex ); + static SALOME_String note ( const SALOME_String& theStr, int thePos, int theLen ); + static int globalBrackets( const Postfix& thePostfix, int theFirst, int theLast ); private: - void operationList( SALOME_StringList& ) const; - void bracketsList( SALOME_StringList&, bool ) const; - bool createValue( const SALOME_String&, SALOME_EvalVariant& ) const; - int priority( const SALOME_String&, bool isBin ) const; - - SALOME_EvalExprError isValid( const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType ) const; - SALOME_EvalExprError calculation( const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const; - - bool checkOperations() const; - static void insert( Postfix& aL, const int aIndex, PostfixItem& aItem ); - static const PostfixItem& at( const Postfix& aL, const int aIndex ); - static void append( Postfix& aL, const Postfix& aL1 ); + void operationList ( SALOME_StringList& theRes ) const; + void bracketsList ( SALOME_StringList& theOpens, SALOME_StringList& theCloses ) const; + bool createValue ( const SALOME_String& theStr, SALOME_EvalVariant& theRes ) const; + int priority ( const SALOME_String& theOp, bool isBin ) const; + SALOME_EvalExprError isValid ( const SALOME_String& theOp, SALOME_EvalVariantType theArg1, SALOME_EvalVariantType theArg2 ) const; + SALOME_EvalExprError calculation ( const SALOME_String& theOp, SALOME_EvalVariant& theArg1, SALOME_EvalVariant& theArg2 ) const; + bool checkOperations() const; + + static void insert( Postfix& thePostfix, const int theIndex, const PostfixItem& theItem ); + static const PostfixItem& at ( const Postfix& thePostfix, const int theIndex ); + static void append( Postfix& thePostfix, const Postfix& theAppendedPostfix ); private: friend class RebultExprItem; diff --git a/src/Notebook/SALOME_EvalSet.hxx b/src/Notebook/SALOME_EvalSet.hxx index ce59ce54f..70356caa7 100755 --- a/src/Notebook/SALOME_EvalSet.hxx +++ b/src/Notebook/SALOME_EvalSet.hxx @@ -36,7 +36,10 @@ #endif class SALOME_EvalSet; -typedef std::list SALOME_ListOfEvalSet; + +class SALOME_ListOfEvalSet : public std::list +{ +}; //======================================================================= //class : SALOME_EvalSet diff --git a/src/Notebook/SALOME_Parameter.cxx b/src/Notebook/SALOME_Parameter.cxx index e516de222..39b461858 100644 --- a/src/Notebook/SALOME_Parameter.cxx +++ b/src/Notebook/SALOME_Parameter.cxx @@ -26,7 +26,7 @@ #include #include -#include +#include #include #include diff --git a/src/Notebook/SALOME_Parameter.hxx b/src/Notebook/SALOME_Parameter.hxx index 4c04ff97e..a4f96b629 100644 --- a/src/Notebook/SALOME_Parameter.hxx +++ b/src/Notebook/SALOME_Parameter.hxx @@ -28,6 +28,7 @@ #include #include +#include #include CORBA_SERVER_HEADER(SALOME_Notebook) #include #include -- 2.39.2