From 076e917444d263e7c641fedc4fd895e0a3c6222a Mon Sep 17 00:00:00 2001 From: asl Date: Mon, 7 Dec 2009 11:18:07 +0000 Subject: [PATCH] Correct specification of permitted prefix/postfix operations --- src/Notebook/SALOME_EvalSet.cxx | 110 ++++++++++++++++++++++++++++++++ src/Notebook/SALOME_EvalSet.hxx | 18 +++++- 2 files changed, 126 insertions(+), 2 deletions(-) diff --git a/src/Notebook/SALOME_EvalSet.cxx b/src/Notebook/SALOME_EvalSet.cxx index 92c032049..9d5ce2d22 100755 --- a/src/Notebook/SALOME_EvalSet.cxx +++ b/src/Notebook/SALOME_EvalSet.cxx @@ -442,6 +442,24 @@ SALOME_EvalExprError SALOME_EvalSetArithmetic::calculate(const SALOME_String& op } return err; } +//======================================================================= +//function : SALOME_EvalSetArithmetic::canBePrefix +//purpose : +//======================================================================= +bool SALOME_EvalSetArithmetic::canBePrefix( const SALOME_String& theOp ) const +{ + return theOp=="+" || theOp=="-"; +} +//======================================================================= +//function : SALOME_EvalSetArithmetic::canBePostfix +//purpose : +//======================================================================= +bool SALOME_EvalSetArithmetic::canBePostfix( const SALOME_String& ) const +{ + return false; +} + + ///////////////////////////////////////////////////////////////////////// //======================================================================= //function : SALOME_EvalSetLogic::SALOME_EvalSetLogic @@ -591,6 +609,23 @@ int SALOME_EvalSetLogic::intValue(const SALOME_EvalVariant& v) const } return res; } +//======================================================================= +//function : SALOME_EvalSetLogic::canBePrefix +//purpose : +//======================================================================= +bool SALOME_EvalSetLogic::canBePrefix( const SALOME_String& theOp ) const +{ + return theOp=="!"; +} +//======================================================================= +//function : SALOME_EvalSetLogic::canBePostfix +//purpose : +//======================================================================= +bool SALOME_EvalSetLogic::canBePostfix( const SALOME_String& ) const +{ + return false; +} + ///////////////////////////////////////////////////////////////////////// //======================================================================= //function : SALOME_EvalSetMath::SALOME_EvalSetMath @@ -716,6 +751,26 @@ SALOME_EvalExprError SALOME_EvalSetMath::calculate(const SALOME_String& op, SALO return err; } +//======================================================================= +//function : SALOME_EvalSetMath::canBePrefix +//purpose : +//======================================================================= +bool SALOME_EvalSetMath::canBePrefix( const SALOME_String& theOp ) const +{ + return theOp=="sqrt" || theOp=="abs" || theOp=="sin" || theOp=="cos" || theOp=="rad2grad" || theOp=="grad2rad"; +} +//======================================================================= +//function : SALOME_EvalSetMath::canBePostfix +//purpose : +//======================================================================= +bool SALOME_EvalSetMath::canBePostfix( const SALOME_String& ) const +{ + return false; +} + + + + ///////////////////////////////////////////////////////////////////////// //======================================================================= //function : SALOME_EvalSetString::SALOME_EvalSetString @@ -866,6 +921,24 @@ SALOME_EvalExprError SALOME_EvalSetString::calculate(const SALOME_String& op, SA } return err; } +//======================================================================= +//function : SALOME_EvalSetString::canBePrefix +//purpose : +//======================================================================= +bool SALOME_EvalSetString::canBePrefix( const SALOME_String& theOp ) const +{ + return theOp=="length" || theOp=="lower" || theOp=="upper"; +} +//======================================================================= +//function : SALOME_EvalSetString::canBePostfix +//purpose : +//======================================================================= +bool SALOME_EvalSetString::canBePostfix( const SALOME_String& ) const +{ + return false; +} + + ///////////////////////////////////////////////////////////////////////// //======================================================================= //function : SALOME_EvalSetSets::SALOME_EvalSetSets @@ -1075,6 +1148,24 @@ SALOME_EvalExprError SALOME_EvalSetSets::calculate(const SALOME_String& op, return err; } +//======================================================================= +//function : SALOME_EvalSetSets::canBePrefix +//purpose : +//======================================================================= +bool SALOME_EvalSetSets::canBePrefix( const SALOME_String& theOp ) const +{ + return theOp=="{" || theOp=="count"; +} +//======================================================================= +//function : SALOME_EvalSetSets::canBePostfix +//purpose : +//======================================================================= +bool SALOME_EvalSetSets::canBePostfix( const SALOME_String& theOp ) const +{ + return theOp=="}"; +} + + ///////////////////////////////////////////////////////////////////////// //======================================================================= //function : SALOME_EvalSetConst::SALOME_EvalSetConst @@ -1167,6 +1258,25 @@ SALOME_EvalExprError SALOME_EvalSetConst::calculate(const SALOME_String&, { return EvalExpr_InvalidOperation; } +//======================================================================= +//function : SALOME_EvalSetConst::canBePrefix +//purpose : +//======================================================================= +bool SALOME_EvalSetConst::canBePrefix( const SALOME_String& theOp ) const +{ + return false; +} +//======================================================================= +//function : SALOME_EvalSetConst::canBePostfix +//purpose : +//======================================================================= +bool SALOME_EvalSetConst::canBePostfix( const SALOME_String& theOp ) const +{ + return false; +} + + + ///////////////////////////////////////////////////////////////////////// //======================================================================= diff --git a/src/Notebook/SALOME_EvalSet.hxx b/src/Notebook/SALOME_EvalSet.hxx index 70356caa7..14aa7c217 100755 --- a/src/Notebook/SALOME_EvalSet.hxx +++ b/src/Notebook/SALOME_EvalSet.hxx @@ -56,8 +56,10 @@ public: virtual void bracketsList( SALOME_StringList&, bool open ) const = 0; virtual bool createValue( const SALOME_String&, SALOME_EvalVariant& ) const; virtual int priority( const SALOME_String&, bool isBin ) const = 0; - virtual SALOME_EvalExprError isValid(const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType) const = 0; - virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant&) const = 0; + virtual SALOME_EvalExprError isValid( const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType ) const = 0; + virtual SALOME_EvalExprError calculate( const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const = 0; + virtual bool canBePrefix( const SALOME_String& ) const = 0; + virtual bool canBePostfix( const SALOME_String& ) const = 0; static bool contains( const SALOME_ListOfEvalSet&, const SALOME_EvalSet* ); static void insert( SALOME_ListOfEvalSet& aL, const int aIndex, SALOME_EvalSet* pS ); @@ -100,6 +102,8 @@ public: virtual bool createValue( const SALOME_String&, SALOME_EvalVariant& ) const; virtual int priority( const SALOME_String&, bool isBin ) const; virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const; + virtual bool canBePrefix( const SALOME_String& ) const; + virtual bool canBePostfix( const SALOME_String& ) const; static SALOME_String Name(); virtual SALOME_String name() const; @@ -119,6 +123,8 @@ public: virtual bool createValue( const SALOME_String&, SALOME_EvalVariant& ) const; virtual int priority( const SALOME_String&, bool isBin ) const; virtual SALOME_EvalExprError calculate( const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const; + virtual bool canBePrefix( const SALOME_String& ) const; + virtual bool canBePostfix( const SALOME_String& ) const; static SALOME_String Name(); virtual SALOME_String name() const; @@ -140,6 +146,8 @@ public: virtual bool createValue( const SALOME_String&, SALOME_EvalVariant& ) const; virtual int priority( const SALOME_String&, bool isBin ) const; virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const; + virtual bool canBePrefix( const SALOME_String& ) const; + virtual bool canBePostfix( const SALOME_String& ) const; static SALOME_String Name(); virtual SALOME_String name() const; @@ -158,6 +166,8 @@ public: virtual bool createValue( const SALOME_String&, SALOME_EvalVariant& ) const; virtual int priority( const SALOME_String&, bool isBin ) const; virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const; + virtual bool canBePrefix( const SALOME_String& ) const; + virtual bool canBePostfix( const SALOME_String& ) const; static SALOME_String Name(); virtual SALOME_String name() const; @@ -180,6 +190,8 @@ public: virtual SALOME_EvalExprError calculate(const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const; virtual SALOME_EvalExprError isValid( const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType ) const; virtual void bracketsList( SALOME_StringList&, bool open ) const; + virtual bool canBePrefix( const SALOME_String& ) const; + virtual bool canBePostfix( const SALOME_String& ) const; static SALOME_String Name(); virtual SALOME_String name() const; @@ -209,6 +221,8 @@ public: virtual int priority( const SALOME_String&, bool isBin ) const; virtual SALOME_EvalExprError isValid( const SALOME_String&, const SALOME_EvalVariantType, const SALOME_EvalVariantType ) const; virtual SALOME_EvalExprError calculate( const SALOME_String&, SALOME_EvalVariant&, SALOME_EvalVariant& ) const; + virtual bool canBePrefix( const SALOME_String& ) const; + virtual bool canBePostfix( const SALOME_String& ) const; }; #endif -- 2.39.2