EvalExpr

 

class EvalExpr

 

It implements a simple expression evaluator including variable handling.

 

Constructor Detail

 

EvalExpr()

EvalExpr constructor.

 

 

Public Member List

 

double Eval(String line)

Evals line expression using declared constants and variables with previously assigned values returning numerical result.

Eval() can be called as many times as needed.

For example:

EvalExpr expr;

double res1 = expr.Eval("x = 2");        // Returns 2

double res2 = expr.Eval("23 + x^2");    // Returns 27

double res3 = expr.Eval("y = 2 + x");/    // Returns 4

 


 

String EvalStr(String line, int numDigits = 3)

Evals line expression using declared variables previously assigned values. It returns an expression including variable values with numDigits number of digits. If numDigits is Null, variables will not be replaced by its numerical value

 


 

VectorMap<String, doubleconstants

constants VectorMap includes all constants. Instead of with variables, the value of a constant is not shown with EvalStr(). It  will be converted private soon.

 


 

VectorMap<String, doublevariables

variables VectorMap includes all variables.