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.
|
| QtxEvalParser * | parser () 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.
|
| QtxEvalSet * | operationSet (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 |
| QtxEvalParser * | myParser |
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:
-
| expr | expression to be evaluated |
References intialize().
| QtxEvalExpr::QtxEvalExpr |
( |
const bool |
stdSets, |
|
|
const QString & |
expr = QString() |
|
) |
| |
- Parameters:
-
| stdSets | if true, the evaluator is initalized by standard operations |
| expr | expression to be evaluated |
References intialize().
| QtxEvalExpr::~QtxEvalExpr |
( |
| ) |
|
Member Function Documentation
| QVariant QtxEvalExpr::calculate |
( |
const QString & |
expr = QString() | ) |
|
| QString QtxEvalExpr::expression |
( |
| ) |
const |
- Returns:
- expression string
References myExpr.
| void QtxEvalExpr::setExpression |
( |
const QString & |
expr | ) |
|
- Returns:
- expression parser
References myParser.
| bool QtxEvalExpr::autoDeleteOperationSets |
( |
| ) |
const |
| void QtxEvalExpr::setAutoDeleteOperationSets |
( |
const bool |
on | ) |
|
| QtxEvalSet * QtxEvalExpr::operationSet |
( |
const QString & |
name | ) |
const |
| void QtxEvalExpr::removeOperationSet |
( |
QtxEvalSet * |
set | ) |
|
| void QtxEvalExpr::insertOperationSet |
( |
QtxEvalSet * |
set, |
|
|
const int |
idx = -1 |
|
) |
| |
| void QtxEvalExpr::intialize |
( |
const bool |
stdSets, |
|
|
const QString & |
expr |
|
) |
| [private] |
Field Documentation