Class implementing an infix expression. More...

#include <ExpressionParser.h>

Public Types

enum  Operator {
  NONE , ADD , SUB , MUL ,
  DIV , MOD , POW , EQ ,
  NEQ , LT , GT , LTE ,
  GTE , UNIT , NEG , POS
}
 
- Public Types inherited from App::Expression
typedef std::vector< Component * > ComponentList
 

Public Member Functions

ExpressiongetLeft () const
 
Operator getOperator () const
 
ExpressiongetRight () const
 
virtual bool isTouched () const override
 Determine whether the expression is touched or not, i.e relies on properties that are touched. More...
 
 OperatorExpression (const App::DocumentObject *_owner=0, Expression *_left=0, Operator _op=NONE, Expression *_right=0)
 
virtual int priority () const override
 Return the operators priority. More...
 
virtual Expressionsimplify () const override
 Simplify the expression. More...
 
virtual ~OperatorExpression ()
 
- Public Member Functions inherited from App::UnitExpression
const Base::QuantitygetQuantity () const
 
double getScaler () const
 
const Base::UnitgetUnit () const
 
const std::string getUnitString () const
 
double getValue () const
 
void setQuantity (const Base::Quantity &_quantity)
 
void setUnit (const Base::Quantity &_quantity)
 Set unit information. More...
 
 UnitExpression (const App::DocumentObject *_owner=0, const Base::Quantity &_quantity=Base::Quantity(), const std::string &_unitStr=std::string())
 
 ~UnitExpression ()
 
- Public Member Functions inherited from App::Expression
virtual void addComponent (Component *component)
 
bool adjustLinks (const std::set< App::DocumentObject * > &inList)
 
Expressioncopy () const
 
Expressioneval () const
 
 Expression (const App::DocumentObject *_owner)
 
void getDepObjects (std::set< App::DocumentObject * > &, std::vector< std::string > *labels=0) const
 
std::set< App::DocumentObject * > getDepObjects (std::vector< std::string > *labels=0) const
 
ExpressionDeps getDeps () const
 
void getDeps (ExpressionDeps &deps) const
 
std::set< App::ObjectIdentifiergetIdentifiers () const
 
void getIdentifiers (std::set< App::ObjectIdentifier > &) const
 
App::DocumentObjectgetOwner () const
 
Py::Object getPyValue () const
 
boost::any getValueAsAny () const
 
bool hasComponent () const
 
ExpressionPtr importSubNames (const std::map< std::string, std::string > &nameMap) const
 
bool isSame (const Expression &other) const
 
ExpressionPtr replaceObject (const App::DocumentObject *parent, App::DocumentObject *oldObj, App::DocumentObject *newObj) const
 
std::string toString (bool persistent=false, bool checkPriority=false, int indent=0) const
 
void toString (std::ostream &os, bool persistent=false, bool checkPriority=false, int indent=0) const
 
ExpressionPtr updateLabelReference (App::DocumentObject *obj, const std::string &ref, const char *newLabel) const
 
void visit (ExpressionVisitor &v)
 
virtual ~Expression ()
 
- Public Member Functions inherited from Base::BaseClass
 BaseClass ()
 Construction. More...
 
virtual PyObjectgetPyObject (void)
 This method returns the Python wrapper for a C++ object. More...
 
virtual Type getTypeId (void) const
 
bool isDerivedFrom (const Type type) const
 
virtual void setPyObject (PyObject *)
 
virtual ~BaseClass ()
 Destruction. More...
 

Protected Member Functions

virtual bool isCommutative () const
 
virtual bool isLeftAssociative () const
 
virtual bool isRightAssociative () const
 

Protected Attributes

Expressionleft
 Left operand. More...
 
Operator op
 Operator working on left and right. More...
 
Expressionright
 Right operand. More...
 
- Protected Attributes inherited from App::UnitExpression
PyObjectcache = 0
 
- Protected Attributes inherited from App::Expression
ComponentList components
 
App::DocumentObjectowner
 The document object used to access unqualified variables (i.e local scope) More...
 

Additional Inherited Members

- Static Public Member Functions inherited from App::Expression
static ComponentcreateComponent (const std::string &n)
 
static ComponentcreateComponent (Expression *e1, Expression *e2=0, Expression *e3=0, bool isRange=false)
 
static Expressionparse (const App::DocumentObject *owner, const std::string &buffer)
 
- Static Public Member Functions inherited from Base::BaseClass
static void * create (void)
 
static Type getClassTypeId (void)
 
static void init (void)
 
- Public Attributes inherited from App::Expression
std::string comment
 
friend ExpressionVisitor
 
- Static Protected Member Functions inherited from Base::BaseClass
static void initSubclass (Base::Type &toInit, const char *ClassName, const char *ParentName, Type::instantiationMethod method=nullptr)
 

Detailed Description

Class implementing an infix expression.

Member Enumeration Documentation

◆ Operator

Enumerator
NONE 
ADD 
SUB 
MUL 
DIV 
MOD 
POW 
EQ 
NEQ 
LT 
GT 
LTE 
GTE 
UNIT 
NEG 
POS 

Constructor & Destructor Documentation

◆ OperatorExpression()

OperatorExpression::OperatorExpression ( const App::DocumentObject _owner = 0,
Expression _left = 0,
Operator  _op = NONE,
Expression _right = 0 
)

◆ ~OperatorExpression()

OperatorExpression::~OperatorExpression ( )
virtual

Member Function Documentation

◆ getLeft()

Expression* App::OperatorExpression::getLeft ( ) const

◆ getOperator()

Operator App::OperatorExpression::getOperator ( ) const

◆ getRight()

Expression* App::OperatorExpression::getRight ( ) const

◆ isCommutative()

bool OperatorExpression::isCommutative ( ) const
protectedvirtual

◆ isLeftAssociative()

bool OperatorExpression::isLeftAssociative ( ) const
protectedvirtual

◆ isRightAssociative()

bool OperatorExpression::isRightAssociative ( ) const
protectedvirtual

◆ isTouched()

bool OperatorExpression::isTouched ( void  ) const
overridevirtual

Determine whether the expression is touched or not, i.e relies on properties that are touched.

Reimplemented from App::Expression.

◆ priority()

int OperatorExpression::priority ( ) const
overridevirtual

Return the operators priority.

This is used to add parentheses where needed when creating a string representation of the expression.

Returns
The operator's priority.

Reimplemented from App::Expression.

◆ simplify()

Expression * OperatorExpression::simplify ( ) const
overridevirtual

Simplify the expression.

For OperatorExpressions, we return a NumberExpression if both the left and right side can be simplified to NumberExpressions. In this case we can calculate the final value of the expression.

Returns
Simplified expression.

Reimplemented from App::UnitExpression.

References App::Expression::eval(), App::Expression::owner, App::Expression::simplify(), and draftgeoutils.general::v1().

Member Data Documentation

◆ left

Expression* App::OperatorExpression::left
protected

Left operand.

◆ op

Operator App::OperatorExpression::op
protected

Operator working on left and right.

◆ right

Expression* App::OperatorExpression::right
protected

Right operand.


The documentation for this class was generated from the following files:
  • Sources/FreeCAD/src/App/ExpressionParser.h
  • Sources/FreeCAD/src/App/Expression.cpp