OpendTect  6.3
Protected Member Functions | Protected Attributes | Private Member Functions | Static Private Member Functions | List of all members
Math::ExpressionParser Class Reference

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

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_
 
uiString errmsg_
 
bool abswarn_
 

Private Member Functions

 mODTextTranslationClass (ExpressionParser) public
 
void setInput (const char *s)
 
Expressionparse () const
 
const uiString errMsg () const
 
bool foundOldAbs () const
 
uiString sParse2ArgStr () const
 

Static Private Member Functions

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

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.

Member Function Documentation

static int Math::ExpressionParser::constIdxOf ( const char *  )
staticprivate
const uiString Math::ExpressionParser::errMsg ( ) const
inlineprivate
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
inlineprivate
Math::ExpressionParser::mODTextTranslationClass ( ExpressionParser  )
inlineprivate
Expression* Math::ExpressionParser::parse ( ) const
private
Expression* Math::ExpressionParser::parse ( const char *  ) const
protected
void Math::ExpressionParser::setInput ( const char *  s)
inlineprivate
uiString Math::ExpressionParser::sParse2ArgStr ( ) const
inlineprivate
static BufferString Math::ExpressionParser::varNameOf ( const char *  fullvarnm,
int *  shift = 0 
)
staticprivate
static Expression::VarType Math::ExpressionParser::varTypeOf ( const char *  )
staticprivate

Member Data Documentation

bool Math::ExpressionParser::abswarn_
mutableprotected
uiString 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. 2017