OpendTect-6_4  6.4
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Math::ExpressionParser Class Reference

Parses a string with a mathematical expression. More...

Public Member Functions

 ExpressionParser (const char *str=0, bool inputsareseries=true)
 
void setInput (const char *s)
 
Expressionparse () const
 
const char * errMsg () const
 
bool foundOldAbs () const
 

Static Public Member Functions

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

Protected Member Functions

Expressionparse (const char *) const
 
bool findOuterParens (char *, int, Expression *&) const
 
bool findOuterAbs (char *, int, Expression *&) const
 
bool findQMarkOper (char *, int, Expression *&) const
 
bool findAndOrOr (char *, int, Expression *&) const
 
bool findInequality (char *, int, Expression *&) const
 
bool findPlusAndMinus (char *, int, Expression *&) const
 
bool findOtherOper (BufferString &, int, Expression *&) const
 
bool findVariable (char *, int, Expression *&) const
 
bool findMathFunction (BufferString &, int, Expression *&) const
 
bool findStatsFunction (BufferString &, int, Expression *&) const
 

Protected Attributes

BufferString inp_
 
const bool inputsareseries_
 
BufferString errmsg_
 
bool abswarn_
 

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

Math::ExpressionParser::ExpressionParser ( const char *  str = 0,
bool  inputsareseries = true 
)
inline

Member Function Documentation

static int Math::ExpressionParser::constIdxOf ( const char *  )
static
const char* Math::ExpressionParser::errMsg ( ) const
inline
bool Math::ExpressionParser::findAndOrOr ( char *  ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findInequality ( char *  ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findMathFunction ( BufferString ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findOtherOper ( BufferString ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findOuterAbs ( char *  ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findOuterParens ( char *  ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findPlusAndMinus ( char *  ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findQMarkOper ( char *  ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findStatsFunction ( BufferString ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::findVariable ( char *  ,
int  ,
Expression *&   
) const
protected
bool Math::ExpressionParser::foundOldAbs ( ) const
inline
Expression* Math::ExpressionParser::parse ( ) const
Expression* Math::ExpressionParser::parse ( const char *  ) const
protected
void Math::ExpressionParser::setInput ( const char *  s)
inline
static BufferString Math::ExpressionParser::varNameOf ( const char *  fullvarnm,
int *  shift = 0 
)
static
static Expression::VarType Math::ExpressionParser::varTypeOf ( const char *  )
static

Member Data Documentation

bool Math::ExpressionParser::abswarn_
mutableprotected
BufferString Math::ExpressionParser::errmsg_
mutableprotected
BufferString Math::ExpressionParser::inp_
protected
const bool Math::ExpressionParser::inputsareseries_
protected

Generated at for the OpendTect seismic interpretation project. Copyright (C): dGB Beheer B. V. 2019