1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // File : SALOME_EvalParser.cxx
23 // Author : Peter KURNEV
26 #include <SALOME_EvalParser.hxx>
31 bool contains(const SALOME_StringList& aLS, const SALOME_String& aS);
32 SALOME_String trimmed(const SALOME_String& str);
33 SALOME_String trimmed(const SALOME_String& str, const char aWhat);
34 bool isSpace(const char aC);
35 int indexOf(const SALOME_StringList& aLS, const SALOME_String& aS);
37 //=======================================================================
40 //=======================================================================
41 SALOME_EvalParser::SALOME_EvalParser()
44 setError( EvalExpr_OK );
46 //=======================================================================
49 //=======================================================================
50 SALOME_EvalParser::~SALOME_EvalParser()
52 if (autoDeleteOperationSets()) {
53 //qDeleteAll( mySets );// !!!
54 SALOME_ListOfEvalSet::const_iterator aIt = mySets.begin();
55 for (; aIt != mySets.end() ; ++aIt ) {
56 SALOME_EvalSet* pEvalSet=*aIt;
64 //=======================================================================
65 //function : operationSets
67 //=======================================================================
68 SALOME_ListOfEvalSet SALOME_EvalParser::operationSets() const
72 //=======================================================================
73 //function : operationSet
75 //=======================================================================
76 SALOME_EvalSet* SALOME_EvalParser::operationSet(const SALOME_String& theName) const
81 SALOME_ListOfEvalSet::const_iterator it = mySets.begin();
82 for (; it != mySets.end() && !pSet; ++it ) {
83 if ( (*it)->name()==theName ) {
89 //=======================================================================
90 //function : insertOperationSet
92 //=======================================================================
93 void SALOME_EvalParser::insertOperationSet(SALOME_EvalSet* theSet,
96 if (SALOME_EvalSet::contains(mySets, theSet)) {
100 int iSize=(int)mySets.size();
101 int index = idx < 0 ? iSize : idx;
105 SALOME_EvalSet::insert(mySets, index, theSet);
107 //=======================================================================
108 //function : removeOperationSet
110 //=======================================================================
111 void SALOME_EvalParser::removeOperationSet(SALOME_EvalSet* theSet)
113 //mySets.removeAll( theSet );
114 mySets.remove(theSet);
116 //=======================================================================
117 //function : autoDeleteOperationSets
119 //=======================================================================
120 bool SALOME_EvalParser::autoDeleteOperationSets() const
124 //=======================================================================
125 //function : setAutoDeleteOperationSets
127 //=======================================================================
128 void SALOME_EvalParser::setAutoDeleteOperationSets( const bool theOn )
132 //=======================================================================
135 //=======================================================================
136 int SALOME_EvalParser::search(const SALOME_StringList& aList, const SALOME_String& aStr, int offset, int& matchLen, int& listind )
141 //static const basic_string <char>::size_type npos = -1;
143 SALOME_StringList::const_iterator aIt = aList.begin(), aLast = aList.end();
144 for (ind = 0; aIt != aLast; aIt++, ind++ )
146 const SALOME_String& aStrX=*aIt;
148 pos=(int)aStr.find(aStrX, offset);
150 ( min < 0 || min > pos ||
151 ( min == pos && matchLen < (int)aStrX.length())
156 matchLen = (int)aStrX.length();
165 //=======================================================================
168 //=======================================================================
169 SALOME_String SALOME_EvalParser::note(const SALOME_String& aStr, int pos, int len )
173 aStr1=aStr.substr(pos, len);
174 aStr1=trimmed(aStr1);
179 //=======================================================================
182 //=======================================================================
183 bool SALOME_EvalParser::prepare(const SALOME_String& expr, Postfix& post)
186 int len =(int)expr.length();
187 stack<int> aBracketStack;
188 SALOME_StringList anOpers, anOpenBr, aCloseBr;
189 if ( !checkOperations() )
192 bracketsList( anOpenBr, true );
193 bracketsList( aCloseBr, false );
194 operationList( anOpers );
196 while ( pos < len && error() == EvalExpr_OK ) {
200 while ( pos < len && isSpace(aC) ) {
208 int mBrLen = 0, mLen = 0, br_ind = -1, op_ind = -1;
209 int oPos = search( anOpenBr, expr, pos, mBrLen, br_ind );
210 int cPos = oPos == pos ? -1 : search( aCloseBr, expr, pos, mBrLen, br_ind );
211 int opPos = search( anOpers, expr, pos, mLen, op_ind );
215 while ( vpos < (int)expr.length() && expr[vpos] != '\'' ) {
219 mLen = vpos - pos + 1;
221 int res = createValue( note( expr, pos, mLen ), item.myValue );
222 item.myType = res ? Value : Param;
223 post.push_back( item );
229 aBracketStack.push( br_ind );
230 item.myValue = note( expr, pos, mBrLen );
232 post.push_back( item );
234 else if ( cPos == pos ) {
235 if ( aBracketStack.size() == 0 ) {
236 setError( EvalExpr_ExcessClose );
239 if ( br_ind != aBracketStack.top() ) {
240 setError( EvalExpr_BracketsNotMatch );
245 item.myValue = note( expr, pos, mBrLen );
247 post.push_back( item );
254 if ( opPos == pos ) {
256 item.myValue = note( expr, pos, mLen );
257 item.myType = Binary;
260 insert(post, (int)(post.size()-1), item);
263 post.push_back( item );
267 if ( oPos != pos && cPos != pos ) {
269 for ( i = pos + 1; i < (int)expr.length(); i++ ) {
270 if ( isSpace(expr[i]) ) {
276 if ( oPos >= 0 && oPos < vpos ) {
279 if ( cPos >= 0 && cPos < vpos ){
282 if ( opPos >= 0 && opPos < vpos ){
286 while( vpos < (int)expr.length() &&
287 ( isalpha(expr[vpos]) ||
288 isdigit(expr[vpos]) ||
295 bool res = createValue( note( expr, pos, mLen ), item.myValue );
296 item.myType = res ? Value : Param;
297 post.push_back( item );
300 pos += mBrLen + mLen;
305 for ( Postfix::iterator anIt = post.begin(); anIt != post.end(); ++anIt ) {
306 if ( (*anIt).myType == Open ){
309 else if ( (*anIt).myType == Close ) {
314 setError( EvalExpr_ExcessClose );
322 setError( EvalExpr_CloseExpected );
325 return error() == EvalExpr_OK;
327 //=======================================================================
328 //function : setOperationTypes
330 //=======================================================================
331 bool SALOME_EvalParser::setOperationTypes( Postfix& post )
333 if ( !checkOperations() )
336 SALOME_StringList anOpen, aClose;
338 bracketsList( anOpen, true );
339 bracketsList( aClose, false );
341 Postfix::iterator aPrev, aNext;
342 Postfix::iterator anIt = post.begin();
343 for (; anIt != post.end(); ++anIt ) {
348 if ( (*anIt).myType != Binary ){
352 if ( ( anIt == post.begin() || (*aPrev).myType == Open ||
353 (*aPrev).myType == Pre || (*aPrev).myType == Binary ) && aNext != post.end() &&
354 ( (*aNext).myType == Value || (*aNext).myType == Param ||
355 (*aNext).myType == Open || (*aNext).myType == Binary ) )
356 (*anIt).myType = Pre;
358 else if ( anIt != post.begin() && ( (*aPrev).myType == Close || (*aPrev).myType == Param ||
359 (*aPrev).myType == Value || (*aPrev).myType == Pre ||
360 (*aPrev).myType == Post || (*aPrev).myType == Binary ) &&
361 ( aNext == post.end() || (*aNext).myType == Close ) )
362 (*anIt).myType = Post;
364 SALOME_EvalVariant& aRV=(*anIt).myValue;
365 SALOME_String aRVS=aRV.toString();
367 if ( contains(anOpen, aRVS) ) {
368 (*anIt).myType = Pre;
370 else if ( contains(aClose, aRVS) ) {
371 (*anIt).myType = Post;
375 return error() == EvalExpr_OK;
377 //=======================================================================
378 //function : globalBrackets
380 //=======================================================================
381 int SALOME_EvalParser::globalBrackets(const Postfix& post,
390 int min_br_num = (l-f+1)*5;
393 pPost=new PostfixItem[post.size()];
395 Postfix::const_iterator aIt = post.begin();
396 for (i=0; aIt != post.end(); ++aIt, ++i) {
397 const PostfixItem& aPostfixItem=*aIt;
398 pPost[i]=aPostfixItem;
401 for( i=f; i<=l; i++ )
402 if( pPost[ i ].myType==SALOME_EvalParser::Open )
406 for( i=l; i>=f; i-- )
407 if( pPost[ i ].myType==SALOME_EvalParser::Close )
412 br = start_br<fin_br ? start_br : fin_br;
413 for( i=f+br; i<=l-br; i++ )
415 if( pPost[i].myType==SALOME_EvalParser::Open )
417 else if( pPost[i].myType==SALOME_EvalParser::Close )
419 if( br_num<min_br_num )
424 delete [] (PostfixItem *)pPost;
425 return br+min_br_num;
427 //=======================================================================
430 //=======================================================================
431 bool SALOME_EvalParser::sort( const Postfix& post, Postfix& res, const SALOME_StringList& anOpen,
432 const SALOME_StringList& aClose, int f, int l )
441 l = (int)(post.size() - 1);
444 int br = globalBrackets( post, f, l );
448 if ( f == l && f >= 0 ) {
449 res.push_back(at(post,f));
455 if ( !checkOperations() ) {
461 list<PostfixItemType> min_types;
463 for ( int i = 0, j = f; j <= l; i++, j++ ) {
464 const PostfixItem& item = at(post,j);//!!!
465 PostfixItemType tt = item.myType;
466 if ( tt == Binary || tt == Pre || tt == Post ) {
467 int cur_pr = priority( item.myValue.toString(), tt == Binary );
469 if ( min < 0 || min >= cur_pr ) {
470 if ( min == cur_pr ) {
471 argmin.push_back( f + i );
472 min_types.push_back( tt );
477 argmin.push_back( f + i );
479 min_types.push_back( tt );
484 setError( EvalExpr_InvalidOperation );
488 else if ( tt == Open ){
489 SALOME_String opBr = item.myValue.toString();
490 int ind, brValue = 0;
491 ind = indexOf(anOpen, opBr );
493 const PostfixItem& anItem = at(post,j);
494 if ( anItem.myType == Open )
497 if ( anItem.myType == Close ) {
499 SALOME_String clBr = anItem.myValue.toString();
500 if ( indexOf(aClose, clBr ) == ind && brValue == 0 ){
508 setError( EvalExpr_CloseExpected );
514 if ( error() == EvalExpr_OK ) {
518 list<int>::const_iterator anIt = argmin.begin(), aLast = argmin.end();
519 bool ok = sort( post, one, anOpen, aClose, f, *anIt - 1 );
520 parts.push_back( one );
522 for ( ; anIt != aLast && ok; anIt++ ) {
523 list<int>::const_iterator aNext = anIt; aNext++;
524 ok = sort( post, one, anOpen, aClose, *anIt + 1, aNext == aLast ? l : *aNext - 1 );
525 parts.push_back( one );
533 stack<PostfixItem> aStack;
534 list<Postfix>::const_iterator aPIt = parts.begin();
535 list<PostfixItemType>::const_iterator aTIt = min_types.begin();
539 anIt = argmin.begin();
540 for ( ; anIt != aLast; anIt++, aPIt++, aTIt++ ) {
541 if ( *aTIt == Pre ) {
542 if (!contains(anOpen, at(post,*anIt).myValue.toString())) {
544 aStack.push( at(post, *anIt) );
547 res.push_back( at(post, *anIt) );
553 while (!aStack.empty() ) {
554 res.push_back( aStack.top() );
557 res.push_back( at(post, *anIt) );
560 while ( !aStack.empty() ) {
561 res.push_back( aStack.top() );
565 else { //there are no operations
566 for ( int k = f; k <= l; k++ ) {
567 const PostfixItem& aItem=at(post, k);
568 if ( aItem.myType==Value || aItem.myType == Param ){
569 res.push_back( aItem );
574 return error() == EvalExpr_OK;
576 //=======================================================================
579 //=======================================================================
580 bool SALOME_EvalParser::parse( const SALOME_String& expr )
584 if ( !checkOperations() )
588 SALOME_StringList opens, closes;
590 setError( EvalExpr_OK );
591 bracketsList( opens, true );
592 bracketsList( closes, false );
594 return prepare( expr, p ) && setOperationTypes( p ) && sort( p, myPostfix, opens, closes );
596 //=======================================================================
597 //function : calculate
599 //=======================================================================
600 bool SALOME_EvalParser::calculate(const SALOME_String& op, SALOME_EvalVariant& v1, SALOME_EvalVariant& v2 )
602 SALOME_EvalExprError aErr;
603 SALOME_EvalVariantType aType1, aType2;
608 aErr = isValid( op, aType1, aType2 );
609 if ( aErr == EvalExpr_OK ){
610 aErr=calculation( op, v1, v2 );
616 return error() == EvalExpr_OK;
618 //=======================================================================
619 //function : calculate
621 //=======================================================================
622 SALOME_EvalVariant SALOME_EvalParser::calculate()
624 if ( !checkOperations() )
625 return SALOME_EvalVariant();
627 setError( EvalExpr_OK );
629 SALOME_StringList anOpen, aClose;
630 PostfixItemType aType;
632 bracketsList( anOpen, true );
633 bracketsList( aClose, false );
635 stack<SALOME_EvalVariant> aStack;
636 Postfix::iterator anIt = myPostfix.begin(), aLast = myPostfix.end();
637 for ( ; anIt != aLast && error() == EvalExpr_OK; anIt++ ) {
638 const PostfixItem& aPostfixItem=*anIt;
639 aType=aPostfixItem.myType;
640 SALOME_String nn = aPostfixItem.myValue.toString();
642 if ( aType == Param ) {
643 if ( hasParameter( nn ) ) {
644 SALOME_EvalVariant& v = myParams[nn];
649 setError( EvalExpr_InvalidToken );
653 setError( EvalExpr_InvalidToken );
657 else if ( aType == Value ) {
658 aStack.push( (*anIt).myValue );
661 else if ( aType == Pre || aType == Post ) {
662 if ( contains(anOpen, nn ) ) {
663 SALOME_EvalVariant inv;
664 if ( calculate( nn, inv, inv ) ) {
665 aStack.push( SALOME_EvalVariant() );
668 else if ( contains(aClose, nn ) ) {
669 SALOME_ListOfEvalVariant aSet;
671 if ( aStack.empty() ) {
672 setError( EvalExpr_StackUnderflow );
675 if ( aStack.top().isValid() ) {
676 aSet.push_back( aStack.top() );
685 SALOME_EvalVariant qSet = aSet, inv;
686 if ( calculate( nn, qSet, inv ) ) {
690 else if ( aStack.size() >= 1 ) {
691 SALOME_EvalVariant inv;
692 SALOME_EvalVariant *v1, *v2;
694 v2 = &inv; //"post-" case
695 if ( aType == Pre ) {
699 calculate( nn, *v1, *v2 );
702 setError( EvalExpr_StackUnderflow );
704 }//else if ( aType== Pre || aType == Post ) {
705 else if ( aType == Binary ) {
706 if ( aStack.size() >= 2 ) {
707 SALOME_EvalVariant v2= aStack.top();
709 calculate( nn, aStack.top(), v2 );
712 setError( EvalExpr_StackUnderflow );
717 SALOME_EvalVariant res;
718 if ( error() == EvalExpr_OK ) {
721 count = (int)aStack.size();
723 setError( EvalExpr_StackUnderflow );
725 else if( count == 1 ) {
729 setError( EvalExpr_ExcessData );
734 //=======================================================================
735 //function : calculate
737 //=======================================================================
738 SALOME_EvalVariant SALOME_EvalParser::calculate( const SALOME_String& expr )
740 setExpression( expr );
743 //=======================================================================
744 //function : setExpression
746 //=======================================================================
747 bool SALOME_EvalParser::setExpression( const SALOME_String& expr )
749 return parse( expr );
751 //=======================================================================
752 //function : hasParameter
754 //=======================================================================
755 bool SALOME_EvalParser::hasParameter( const SALOME_String& name ) const
759 ParamMap::const_iterator aIt;
761 aIt=myParams.find(aStr);
762 bRet=(aIt!=myParams.end());
765 //=======================================================================
766 //function : setParameter
768 //=======================================================================
769 void SALOME_EvalParser::setParameter( const SALOME_String& name, const SALOME_EvalVariant& value )
774 myParams[aStr] = value;
776 //=======================================================================
777 //function : removeParameter
779 //=======================================================================
780 bool SALOME_EvalParser::removeParameter( const SALOME_String& name )
786 iRet=(int)myParams.erase(aStr);
787 return iRet? true : false;
790 //=======================================================================
791 //function : parameter
793 //=======================================================================
794 SALOME_EvalVariant SALOME_EvalParser::parameter( const SALOME_String& theName ) const
796 SALOME_EvalVariant res;
797 ParamMap::const_iterator aIt;
799 aStr=trimmed(theName);
800 aIt=myParams.find(theName);
801 if (aIt!=myParams.end()) {
802 const PairParamMap& aVT=*aIt;
803 const SALOME_EvalVariant& aRV=aVT.second;
808 //=======================================================================
809 //function : firstInvalid
811 //=======================================================================
812 bool SALOME_EvalParser::firstInvalid( SALOME_String& name ) const
814 ParamMap::const_iterator aIt = myParams.begin();
815 for (; aIt != myParams.end(); aIt++ ) {
816 const PairParamMap& aVT=*aIt;
817 const SALOME_EvalVariant& aRV=aVT.second;
818 if ( !aRV.isValid() ) {
825 //=======================================================================
826 //function : removeInvalids
828 //=======================================================================
829 void SALOME_EvalParser::removeInvalids()
833 ParamMap::const_iterator aIt = myParams.begin();
834 for (; aIt != myParams.end(); aIt++ ) {
835 const PairParamMap& aVT=*aIt;
836 const SALOME_EvalVariant& aRV=aVT.second;
837 if (aRV.isValid() ) {
844 //=======================================================================
847 //=======================================================================
848 SALOME_EvalExprError SALOME_EvalParser::error() const
852 //=======================================================================
853 //function : setError
855 //=======================================================================
857 void SALOME_EvalParser::setError(SALOME_EvalExprError err)
861 //=======================================================================
864 //=======================================================================
865 SALOME_String SALOME_EvalParser::dump() const
867 return dump( myPostfix );
869 //=======================================================================
872 //=======================================================================
873 SALOME_String SALOME_EvalParser::dump( const Postfix& post ) const
877 if ( !checkOperations() ) {
881 Postfix::const_iterator anIt = post.begin();
882 for (; anIt != post.end(); anIt++ ) {
883 if ((*anIt).myType == Value &&
884 (*anIt).myValue.type() == SALOME_EvalVariant_String ) {
885 res += "'" + (*anIt).myValue.toString() + "'";
888 res += (*anIt).myValue.toString();
890 if ( (*anIt).myType == Pre ){
893 else if ( (*anIt).myType == Post ){
896 else if ( (*anIt).myType == Binary ){
905 //=======================================================================
906 //function : parameters
908 //=======================================================================
909 SALOME_StringList SALOME_EvalParser::parameters() const
911 SALOME_StringList lst;
912 Postfix::const_iterator anIt = myPostfix.begin();
913 for (; anIt != myPostfix.end(); anIt++ ) {
914 if ( (*anIt).myType == Param ) {
915 SALOME_String name = (*anIt).myValue.toString();
916 if ( !contains(lst, name ) ) {
917 lst.push_back( name );
923 //=======================================================================
924 //function : clearParameters
926 //=======================================================================
927 void SALOME_EvalParser::clearParameters()
931 //=======================================================================
932 //function : toString
934 //=======================================================================
935 SALOME_String SALOME_EvalParser::toString( const SALOME_ListOfEvalVariant& theList )
937 SALOME_String res = "set : [ ";
938 SALOME_ListOfEvalVariant::const_iterator aIt = theList.begin();
939 for ( ; aIt != theList.end(); aIt++ )
940 res += (*aIt).toString() + " ";
944 //=======================================================================
945 //function : operationList
947 //=======================================================================
948 void SALOME_EvalParser::operationList( SALOME_StringList& theList ) const
950 SALOME_ListOfEvalSet::const_iterator aIt = mySets.begin();
951 for (; aIt != mySets.end(); ++aIt ) {
952 SALOME_StringList custom;
953 SALOME_EvalSet* aSet = *aIt;
954 aSet->operationList( custom );
955 SALOME_StringList::const_iterator sIt = custom.begin();
956 for ( ; sIt != custom.end(); ++sIt ) {
957 if ( !contains(theList, *sIt ) ) {
958 theList.push_back( *sIt );
963 //=======================================================================
964 //function : operationList
966 //=======================================================================
967 void SALOME_EvalParser::bracketsList( SALOME_StringList& theList, bool open ) const
969 SALOME_ListOfEvalSet::const_iterator it = mySets.begin();
970 for (; it != mySets.end(); ++it ) {
971 SALOME_StringList custom;
972 SALOME_EvalSet* aSet = *it;
973 aSet->bracketsList( custom, open );
974 SALOME_StringList::const_iterator sIt = custom.begin();
975 for (; sIt != custom.end(); ++sIt ) {
976 if ( !contains(theList, *sIt ) )
977 theList.push_back( *sIt );
981 //=======================================================================
982 //function : createValue
984 //=======================================================================
985 bool SALOME_EvalParser::createValue( const SALOME_String& str, SALOME_EvalVariant& val ) const
989 SALOME_ListOfEvalSet::const_iterator it = mySets.begin();
990 for (; it != mySets.end() && !ok; ++it ) {
991 ok = (*it)->createValue( str, val );
995 //=======================================================================
996 //function : priority
998 //=======================================================================
999 int SALOME_EvalParser::priority( const SALOME_String& op, bool isBin ) const
1003 SALOME_ListOfEvalSet::const_iterator it = mySets.begin();
1004 for (; it != mySets.end() && priority <= 0; ++it, i++ ){
1005 priority = (*it)->priority( op, isBin );
1007 return priority > 0 ? priority + i * 50 : 0;
1009 //=======================================================================
1010 //function : isValid
1012 //=======================================================================
1013 SALOME_EvalExprError SALOME_EvalParser::isValid( const SALOME_String& op, const SALOME_EvalVariantType t1,
1014 const SALOME_EvalVariantType t2 ) const
1016 SALOME_EvalExprError err = EvalExpr_OK;
1018 SALOME_ListOfEvalSet::const_iterator it = mySets.begin();
1019 for (; it != mySets.end(); ++it ) {
1020 SALOME_EvalSet *pSet=*it;
1021 err = pSet->isValid( op, t1, t2 );
1022 if ( err == EvalExpr_OK ){
1028 //=======================================================================
1029 //function : calculation
1031 //=======================================================================
1032 SALOME_EvalExprError SALOME_EvalParser::calculation( const SALOME_String& op, SALOME_EvalVariant& v1, SALOME_EvalVariant& v2 ) const
1034 SALOME_EvalVariant nv1, nv2;
1035 SALOME_EvalSet *pSet;
1036 SALOME_EvalVariantType aType1, aType2;
1037 SALOME_EvalExprError aErr;
1042 SALOME_ListOfEvalSet::const_iterator aIt = mySets.begin();
1043 for (; aIt != mySets.end(); ++aIt ) {
1047 aErr=pSet->isValid( op, aType1, aType2);
1048 if ( aErr == EvalExpr_OK ) {
1049 aErr = pSet->calculate( op, nv1, nv2 );
1050 if ( aErr == EvalExpr_OK || aErr == EvalExpr_InvalidResult ) {
1058 return EvalExpr_InvalidOperation;
1060 //=======================================================================
1061 //function : checkOperations
1063 //=======================================================================
1064 bool SALOME_EvalParser::checkOperations() const
1066 if ( mySets.size() )
1069 SALOME_EvalParser* that = (SALOME_EvalParser*)this;
1070 that->setError( EvalExpr_OperationsNull );
1073 //=======================================================================
1076 //=======================================================================
1077 void SALOME_EvalParser::append(Postfix& aL,
1080 Postfix::const_iterator aIt=aL1.begin();
1081 for(; aIt!=aL1.end(); ++aIt) {
1085 //=======================================================================
1088 //=======================================================================
1089 const SALOME_EvalParser::PostfixItem& SALOME_EvalParser::at(const Postfix& aL,
1093 Postfix::const_iterator aIt=aL.begin();
1094 for(i=0; aIt!=aL.end(); ++aIt, ++i) {
1101 //=======================================================================
1104 //=======================================================================
1105 void SALOME_EvalParser::insert(Postfix& aL,
1114 else if (aIndex==aL.size()) {
1118 Postfix::iterator aIt=aL.begin();
1119 for(i=0; aIt!=aL.end(); ++aIt, ++i) {
1121 aL.insert( aIt, pS );
1127 //=======================================================================
1128 //function : indexOf
1130 //=======================================================================
1131 int indexOf( const SALOME_StringList& aLS, const SALOME_String& aS )
1134 SALOME_StringList::const_iterator aIt;
1139 for (i=0; aIt!=aLS.end(); ++aIt, ++i)
1141 const SALOME_String aSx=*aIt;
1149 //=======================================================================
1150 //function : contains
1152 //=======================================================================
1153 bool contains( const SALOME_StringList& aLS, const SALOME_String& aS )
1158 SALOME_StringList::const_iterator aIt;
1161 for (; aIt!=aLS.end(); ++aIt) {
1162 const SALOME_String aSx=*aIt;
1172 //=======================================================================
1173 //function : isSpace
1175 //=======================================================================
1176 bool isSpace(const char aC)
1180 '\t', '\n', '\v', '\f', '\r', ' '
1185 aNb=sizeof(aWhat)/sizeof(aWhat[0]);
1186 for (i=0; i<aNb; ++i) {
1187 bRet=(aC==aWhat[i]);
1194 //=======================================================================
1195 //function : trimmed
1197 //=======================================================================
1198 SALOME_String trimmed(const SALOME_String& str)
1201 '\t', '\n', '\v', '\f', '\r', ' '
1207 aNb=sizeof(aWhat)/sizeof(aWhat[0]);
1208 for (i=0; i<aNb; ++i) {
1209 aRet=trimmed(aRet, aWhat[i]);
1213 //=======================================================================
1214 //function : trimmed
1216 //=======================================================================
1217 SALOME_String trimmed(const SALOME_String& str, const char aWhat)
1223 const char* mystring=str.c_str();
1228 mylength=strlen(mystring);
1234 for (i=0; i<mylength; ++i) {
1235 char aC=mystring[i];