String expression evaluator. More...
#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. More... | |
| QtxEvalExpr (const bool, const QString &=QString()) | |
| Constructor. More... | |
| ~QtxEvalExpr () | |
| Destructor. More... | |
| QVariant | calculate (const QString &=QString()) |
| Evaluate the expression. More... | |
| QString | expression () const |
| Get the expression. More... | |
| void | setExpression (const QString &) |
| Set the expression. More... | |
| Error | error () const |
| Get the code of latest parsing error. More... | |
| QtxEvalParser * | parser () const |
| Get the expression parser. More... | |
| bool | autoDeleteOperationSets () const |
| Get the 'auto-delete operations' flag value. More... | |
| void | setAutoDeleteOperationSets (const bool) |
| Set the 'auto-delete operations' flag value. More... | |
| QList< QtxEvalSet * > | operationSets () const |
| Get current set of operations. More... | |
| QtxEvalSet * | operationSet (const QString &) const |
| Get the operation by name. More... | |
| void | removeOperationSet (QtxEvalSet *) |
| Remove the operation. More... | |
| void | insertOperationSet (QtxEvalSet *, const int=-1) |
| Install the operation. More... | |
Private Member Functions | |
| void | intialize (const bool, const QString &) |
| Initialize the evaluator. More... | |
Private Attributes | |
| QString | myExpr |
| QtxEvalParser * | myParser |
String expression evaluator.
| enum QtxEvalExpr::Error |
Parsing error type.
| QtxEvalExpr::QtxEvalExpr | ( | const QString & | expr = QString() | ) |
Constructor.
The evaluator is initalized by standard operations. Use another constructor with parameter stdSets = false to avoid initialization of evaluator with standard operations.
| expr | expression to be evaluated |
References intialize().
| QtxEvalExpr::QtxEvalExpr | ( | const bool | stdSets, |
| const QString & | expr = QString() |
||
| ) |
Constructor.
| stdSets | if true, the evaluator is initalized by standard operations |
| expr | expression to be evaluated |
References intialize().
| QtxEvalExpr::~QtxEvalExpr | ( | ) |
Destructor.
References myParser.
| bool QtxEvalExpr::autoDeleteOperationSets | ( | ) | const |
Get the 'auto-delete operations' flag value.
true if all operations shoud be automatically deleted when the evaluator is destroyed References QtxEvalParser::autoDeleteOperationSets(), and myParser.
| QVariant QtxEvalExpr::calculate | ( | const QString & | expr = QString() | ) |
Evaluate the expression.
| expr | expression to be evaluated |
References QtxEvalParser::calculate(), myParser, and setExpression().
| QtxEvalExpr::Error QtxEvalExpr::error | ( | ) | const |
Get the code of latest parsing error.
References QtxEvalParser::error(), and myParser.
| QString QtxEvalExpr::expression | ( | ) | const |
| void QtxEvalExpr::insertOperationSet | ( | QtxEvalSet * | set, |
| const int | idx = -1 |
||
| ) |
Install the operation.
| operation | to be added |
| idx | index in the list at which the operation shoud be inserted |
References QtxEvalParser::insertOperationSet(), and myParser.
|
private |
Initialize the evaluator.
| stdSets | if true, the evaluator is initalized by standard operations |
| expr | expression to be evaluated |
References QtxEvalParser::insertOperationSet(), myParser, QtxEvalParser::setAutoDeleteOperationSets(), and setExpression().
| QtxEvalSet * QtxEvalExpr::operationSet | ( | const QString & | name | ) | const |
Get the operation by name.
| name | operation name |
References myParser, and QtxEvalParser::operationSet().
| QList< QtxEvalSet * > QtxEvalExpr::operationSets | ( | ) | const |
Get current set of operations.
References myParser, and QtxEvalParser::operationSets().
| QtxEvalParser * QtxEvalExpr::parser | ( | ) | const |
| void QtxEvalExpr::removeOperationSet | ( | QtxEvalSet * | set | ) |
Remove the operation.
| operation | to be removed |
References myParser, and QtxEvalParser::removeOperationSet().
| void QtxEvalExpr::setAutoDeleteOperationSets | ( | const bool | on | ) |
Set the 'auto-delete operations' flag value.
| on | if true, all operations shoud be automatically deleted when the evaluator is destroyed |
References myParser, and QtxEvalParser::setAutoDeleteOperationSets().
| void QtxEvalExpr::setExpression | ( | const QString & | expr | ) |
Set the expression.
| expr | expression string |
References expression(), myExpr, myParser, and QtxEvalParser::setExpression().
|
private |
|
private |