Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

MathExpressionParser Class Reference

parses a string with a mathematical expression. More...

List of all members.

Public Member Functions

 MathExpressionParser (const char *str=0)
void setInput (const char *s)
MathExpressionparse () const
const char * errMsg () const

Static Public Member Functions

static BufferString varNameOf (const char *fullvarnm, int *shift=0)
static MathExpression::VarType varTypeOf (const char *)
static int constIdxOf (const char *)

Protected Member Functions

MathExpressionparse (const char *) const

Protected Attributes

BufferString inp_
BufferString errmsg_

Detailed Description

parses a string with a mathematical expression.

The expression can consist of constants, variables, operators and standard mathematical functions. A constant can be any number like 3, -5, 3e-5, or pi. Everything that does not start with a digit and is not an operator is treated as a variable. An operator can be either:

+, -, *, /, ^, >, <, <=, >=, ==, !=, &&, ||, cond ? true stat : false stat, or |abs|

A mathematical function can be either:

sin(), cos(), tan(), ln(), log(), exp() or sqrt().

If the parser returns null, it couldn't parse the expression. Then, errmsg_ should contain info.


Constructor & Destructor Documentation

MathExpressionParser::MathExpressionParser ( const char *  str = 0  )  [inline]

Member Function Documentation

static int MathExpressionParser::constIdxOf ( const char *   )  [static]
const char* MathExpressionParser::errMsg (  )  const [inline]
MathExpression* MathExpressionParser::parse (  )  const
MathExpression* MathExpressionParser::parse ( const char *   )  const [protected]
void MathExpressionParser::setInput ( const char *  s  )  [inline]
static BufferString MathExpressionParser::varNameOf ( const char *  fullvarnm,
int *  shift = 0 
) [static]
static MathExpression::VarType MathExpressionParser::varTypeOf ( const char *   )  [static]

Member Data Documentation