A stack-based expression evaluator class, for dynamically created expressions. More...
#include <cdynamicexpression.h>
Classes | |
| class | Elem |
| One element in a (reverse Polish) expression. More... | |
| class | Functor |
| Function object base class. More... | |
Public Types | |
| enum | OpType |
Public Member Functions | |
Constructors, destructor, assignment. | |
| cDynamicExpression () | |
| cDynamicExpression (const cDynamicExpression &other) | |
| virtual | ~cDynamicExpression () |
| cDynamicExpression & | operator= (const cDynamicExpression &other) |
Redefined cObject functions | |
| virtual cDynamicExpression * | dup () const |
| virtual std::string | info () const |
Setter and evaluator methods. | |
| virtual void | setExpression (Elem e[], int size) |
| virtual cNEDValue | evaluate (cComponent *context) const |
| virtual bool | boolValue (cComponent *context) |
| virtual long | longValue (cComponent *context, const char *expectedUnit=NULL) |
| virtual double | doubleValue (cComponent *context, const char *expectedUnit=NULL) |
| virtual std::string | stringValue (cComponent *context) |
| virtual cXMLElement * | xmlValue (cComponent *context) |
Miscellaneous utility functions. | |
|
| |
| virtual std::string | str () const |
| virtual void | parse (const char *text) |
| virtual int | compare (const cExpression *other) const |
| virtual bool | isAConstant () const |
| virtual bool | containsConstSubexpressions () const |
| virtual void | evaluateConstSubexpressions (cComponent *context) |
| static double | convertUnit (double d, const char *unit, const char *targetUnit) |
A stack-based expression evaluator class, for dynamically created expressions.
NOTE: Experimental class -- API is subject to change.
| static double cDynamicExpression::convertUnit | ( | double | d, | |
| const char * | unit, | |||
| const char * | targetUnit | |||
| ) | [static] |
Convert the given number into the target unit (e.g.
milliwatt to watt). Throws an exception if conversion is not possible (unknown/unrelated units).
Referenced by cNEDValue::doubleValueInUnit().
| virtual cNEDValue cDynamicExpression::evaluate | ( | cComponent * | context | ) | const [virtual] |
Evaluate the expression, and return the results as a cNEDValue.
Throws an error if the expression has some problem (i.e. stack overflow/underflow, "cannot cast", "function not found", etc.)
Reimplemented from cExpression.
| virtual void cDynamicExpression::evaluateConstSubexpressions | ( | cComponent * | context | ) | [virtual] |
Evaluates const subexpressions, and replaces them with their values.
See cDynamicExpression::Elem::CONSTSUBEXPR.
Implements cExpression.
| virtual std::string cDynamicExpression::info | ( | ) | const [virtual] |
Produces a one-line description of the object's contents.
See cObject for more details.
Reimplemented from cExpression.
| virtual void cDynamicExpression::setExpression | ( | Elem | e[], | |
| int | size | |||
| ) | [virtual] |
Sets the Reverse Polish expression to evaluate.
The array must be a dynamically allocated one, and will be deleted by this object. No verification is performed on the expression at this time.
1.6.3