Inheritance diagram for util::ariel::Expression:
|Create an expression without a string to be parsed.|
|Expression (std::string expression)|
|Create an expression with a string to be parsed.|
|void||setExpression (std::string expression)|
|Computable &||parse (std::string expression) throw (ParseException&, ComputationException&)|
|Parse an expression. |
|Computable &||parse () throw (ParseException&, ComputationException&)|
|Parse a stored expression.|
|virtual Computable &||evaluate () throw (ComputationException&)|
|Evaluate a parsed expression. |
|Computable &||getValue ()|
|Get the current value of the expression. |
|operator Computable & ()|
|Typecast to Computable. |
Static Public Methods
|Initialize the expression evaluator. |
|void||setVariableManager (VariableManager *mgr)|
|VariableManager *||getVariableManager (VariableManager *mgr)|
|Expression (SmartPtr< Computable > value, List< UnaryFunction * > funcs) throw (ComputationException&)|
|Expression (Expression *value)|
|SmartPtr< Computable >||_currentValue|
Static Protected Attributes
|VariableManager *||_pVariableManager = NULL|
Evaluate a parsed expression.
The prebuild evaluation tree is evaluated recursively, and the result value is returned. This method is needed when variable values have changed but the expression itself has not.
Get the current value of the expression.
Neither parsing nor evaluation will occur, but the last evaluated value is returned.
Initialize the expression evaluator.
The init() method needs to be called only once per session (though it makes no harm to call it many times). It initializes the operator table.
Typecast to Computable.
Parse an expression.
The given expression string is parsed, and a calculation tree is built into memory for fast access afterwards. The expression string is a composition of numbers, strings, variables, function calls and operators. One may use (almost) any valid C statements. There are also certain enhancements as shown by the following examples.
The return value is a reference to an object derived from Computable. It may be a number, a string or a list storing other computable objects.