#include <cdynamicexpression.h>

NOTE: Experimental class -- API is subject to change.
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) |
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) |
Classes | |
| class | Elem |
| One element in a (reverse Polish) expression. More... | |
| class | Functor |
| Function object base class. More... | |
Operations supported by this class:
| cDynamicExpression::cDynamicExpression | ( | ) | [explicit] |
Constructor.
| cDynamicExpression::cDynamicExpression | ( | const cDynamicExpression & | other | ) | [inline] |
Copy constructor.
| virtual cDynamicExpression::~cDynamicExpression | ( | ) | [virtual] |
Destructor.
| cDynamicExpression& cDynamicExpression::operator= | ( | const cDynamicExpression & | other | ) |
Assignment operator.
| virtual cDynamicExpression* cDynamicExpression::dup | ( | ) | const [inline, virtual] |
| 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.
| 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.)
| virtual bool cDynamicExpression::boolValue | ( | cComponent * | context | ) | [virtual] |
Evaluate the expression and convert the result to bool if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
Referenced by cNEDValue::operator bool().
| virtual long cDynamicExpression::longValue | ( | cComponent * | context, | |
| const char * | expectedUnit = NULL | |||
| ) | [virtual] |
Evaluate the expression and convert the result to long if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
Referenced by cNEDValue::operator char(), cNEDValue::operator int(), cNEDValue::operator long(), cNEDValue::operator short(), cNEDValue::operator unsigned char(), cNEDValue::operator unsigned int(), cNEDValue::operator unsigned long(), and cNEDValue::operator unsigned short().
| virtual double cDynamicExpression::doubleValue | ( | cComponent * | context, | |
| const char * | expectedUnit = NULL | |||
| ) | [virtual] |
Evaluate the expression and convert the result to double if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
Referenced by cNEDValue::operator double(), and cNEDValue::operator long double().
| virtual std::string cDynamicExpression::stringValue | ( | cComponent * | context | ) | [virtual] |
Evaluate the expression and convert the result to string if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
Referenced by cNEDValue::operator const char *().
| virtual cXMLElement* cDynamicExpression::xmlValue | ( | cComponent * | context | ) | [virtual] |
Evaluate the expression and convert the result to an XML tree if possible; throw an error if conversion from that type is not supported.
Implements cExpression.
Referenced by cNEDValue::operator cXMLElement *().
| virtual std::string cDynamicExpression::str | ( | ) | const [virtual] |
| virtual void cDynamicExpression::parse | ( | const char * | text | ) | [virtual] |
| virtual int cDynamicExpression::compare | ( | const cExpression * | other | ) | const [virtual] |
| virtual bool cDynamicExpression::isAConstant | ( | ) | const [virtual] |
Returns true if the expression is just a literal (or equivalent to one, like "2+2").
| virtual bool cDynamicExpression::containsConstSubexpressions | ( | ) | const [virtual] |
| virtual void cDynamicExpression::evaluateConstSubexpressions | ( | cComponent * | context | ) | [virtual] |
Evaluates const subexpressions, and replaces them with their values.
See cDynamicExpression::Elem::CONSTSUBEXPR.
Implements cExpression.
| 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().
1.5.5