Version: 6.3.1
Public Types | Public Member Functions | Private Member Functions | Private Attributes

QtxEvalExpr Class Reference

String expression evaluator.

#include <QtxEvalExpr.h>

Public Types

enum  Error {
  OK, OperandsNotMatch, InvalidResult, InvalidOperation,
  OperationsNull, InvalidToken, CloseExpected, ExcessClose,
  BracketsNotMatch, StackUnderflow, ExcessData
}
 

Parsing error type.

More...

Public Member Functions

 QtxEvalExpr (const QString &=QString())
 Constructor.
 QtxEvalExpr (const bool, const QString &=QString())
 Constructor.
 ~QtxEvalExpr ()
 Destructor.
QVariant calculate (const QString &=QString())
 Evaluate the expression.
QString expression () const
 Get the expression.
void setExpression (const QString &)
 Set the expression.
Error error () const
 Get the code of latest parsing error.
QtxEvalParserparser () const
 Get the expression parser.
bool autoDeleteOperationSets () const
 Get the 'auto-delete operations' flag value.
void setAutoDeleteOperationSets (const bool)
 Set the 'auto-delete operations' flag value.
QList< QtxEvalSet * > operationSets () const
 Get current set of operations.
QtxEvalSetoperationSet (const QString &) const
 Get the operation by name.
void removeOperationSet (QtxEvalSet *)
 Remove the operation.
void insertOperationSet (QtxEvalSet *, const int=-1)
 Install the operation.

Private Member Functions

void intialize (const bool, const QString &)
 Initialize the evaluator.

Private Attributes

QString myExpr
QtxEvalParsermyParser

Member Enumeration Documentation

Enumerator:
OK 

No errors found.

OperandsNotMatch 

Types of arguments are invalid for this operation.

InvalidResult 

Operation cannot find result (for example, division by zero)

InvalidOperation 

Unknown operation.

OperationsNull 

Internal operations pointer of parser is null.

InvalidToken 

Invalid token (neither operation, nor parameter of value)

CloseExpected 

Closing bracket is expected.

ExcessClose 

Extra closing bracket is found.

BracketsNotMatch 

Opening and closing brackets are of different type, e.g. [)

StackUnderflow 

There are no arguments in the stack for the operation.

ExcessData 

The parsing is finished, but there are more then one value in the stack.


Constructor & Destructor Documentation

QtxEvalExpr::QtxEvalExpr ( const QString &  expr = QString())

The evaluator is initalized by standard operations. Use another constructor with parameter stdSets = false to avoid initialization of evaluator with standard operations.

Parameters:
exprexpression to be evaluated

References intialize().

QtxEvalExpr::QtxEvalExpr ( const bool  stdSets,
const QString &  expr = QString() 
)
Parameters:
stdSetsif true, the evaluator is initalized by standard operations
exprexpression to be evaluated

References intialize().

QtxEvalExpr::~QtxEvalExpr ( )

References myParser.


Member Function Documentation

QVariant QtxEvalExpr::calculate ( const QString &  expr = QString())
Parameters:
exprexpression to be evaluated
Returns:
result of the evaluation

References QtxEvalParser.calculate(), myParser, and setExpression().

QString QtxEvalExpr::expression ( ) const
Returns:
expression string

References myExpr.

void QtxEvalExpr::setExpression ( const QString &  expr)
Parameters:
exprexpression string

References expression(), myExpr, myParser, and QtxEvalParser.setExpression().

QtxEvalExpr::Error QtxEvalExpr::error ( ) const
Returns:
the code of the last error

References QtxEvalParser.error(), and myParser.

QtxEvalParser * QtxEvalExpr::parser ( ) const
Returns:
expression parser

References myParser.

bool QtxEvalExpr::autoDeleteOperationSets ( ) const
Returns:
true if all operations shoud be automatically deleted when the evaluator is destroyed
See also:
setAutoDeleteOperationSets()

References QtxEvalParser.autoDeleteOperationSets(), and myParser.

void QtxEvalExpr::setAutoDeleteOperationSets ( const bool  on)
Parameters:
onif true, all operations shoud be automatically deleted when the evaluator is destroyed
See also:
autoDeleteOperationSets()

References myParser, and QtxEvalParser.setAutoDeleteOperationSets().

QList< QtxEvalSet * > QtxEvalExpr::operationSets ( ) const
QtxEvalSet * QtxEvalExpr::operationSet ( const QString &  name) const
Parameters:
nameoperation name
Returns:
operation of 0 if not found
See also:
operationSets(), insertOperationSet(), removeOperationSet()

References myParser, and QtxEvalParser.operationSet().

void QtxEvalExpr::removeOperationSet ( QtxEvalSet set)
Parameters:
operationto be removed
See also:
operationSets(), insertOperationSet(), operationSet()

References myParser, and QtxEvalParser.removeOperationSet().

void QtxEvalExpr::insertOperationSet ( QtxEvalSet set,
const int  idx = -1 
)
Parameters:
operationto be added
idxindex in the list at which the operation shoud be inserted
See also:
operationSets(), removeOperationSet(), operationSet()

References QtxEvalParser.insertOperationSet(), and myParser.

void QtxEvalExpr::intialize ( const bool  stdSets,
const QString &  expr 
) [private]
Parameters:
stdSetsif true, the evaluator is initalized by standard operations
exprexpression to be evaluated

References QtxEvalParser.insertOperationSet(), myParser, QtxEvalParser.setAutoDeleteOperationSets(), and setExpression().


Field Documentation

QString QtxEvalExpr.myExpr [private]
Copyright © 2007-2011 CEA/DEN, EDF R&D, OPEN CASCADE
Copyright © 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS