OpendTect 8.0
Loading...
Searching...
No Matches
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...

#include <mathexpression.h>

Public Member Functions

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

Static Public Member Functions

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

Protected Member Functions

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

Protected Attributes

bool abswarn_
 
uiString errmsg_
 
BufferString inp_
 
const bool inputsareseries_
 

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

◆ ExpressionParser()

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

Member Function Documentation

◆ constIdxOf()

static int Math::ExpressionParser::constIdxOf ( const char * )
static

◆ errMsg()

uiString Math::ExpressionParser::errMsg ( ) const
inline

◆ findAndOrOr()

bool Math::ExpressionParser::findAndOrOr ( char * ,
int ,
Expression *&  ) const
protected

◆ findInequality()

bool Math::ExpressionParser::findInequality ( char * ,
int ,
Expression *&  ) const
protected

◆ findMathFunction()

bool Math::ExpressionParser::findMathFunction ( BufferString & ,
int ,
Expression *&  ) const
protected

◆ findOtherOper()

bool Math::ExpressionParser::findOtherOper ( BufferString & ,
int ,
Expression *&  ) const
protected

◆ findOuterAbs()

bool Math::ExpressionParser::findOuterAbs ( char * ,
int ,
Expression *&  ) const
protected

◆ findOuterParens()

bool Math::ExpressionParser::findOuterParens ( char * ,
int ,
Expression *&  ) const
protected

◆ findPlusAndMinus()

bool Math::ExpressionParser::findPlusAndMinus ( char * ,
int ,
Expression *&  ) const
protected

◆ findQMarkOper()

bool Math::ExpressionParser::findQMarkOper ( char * ,
int ,
Expression *&  ) const
protected

◆ findStatsFunction()

bool Math::ExpressionParser::findStatsFunction ( BufferString & ,
int ,
Expression *&  ) const
protected

◆ findVariable()

bool Math::ExpressionParser::findVariable ( char * ,
int ,
Expression *&  ) const
protected

◆ foundOldAbs()

bool Math::ExpressionParser::foundOldAbs ( ) const
inline

◆ parse() [1/2]

Expression * Math::ExpressionParser::parse ( ) const

◆ parse() [2/2]

Expression * Math::ExpressionParser::parse ( const char * ) const
protected

◆ setInput()

void Math::ExpressionParser::setInput ( const char * s)
inline

◆ varNameOf()

static BufferString Math::ExpressionParser::varNameOf ( const char * fullvarnm,
int * shift = 0 )
static

◆ varTypeOf()

static Expression::VarType Math::ExpressionParser::varTypeOf ( const char * )
static

Member Data Documentation

◆ abswarn_

bool Math::ExpressionParser::abswarn_
mutableprotected

◆ errmsg_

uiString Math::ExpressionParser::errmsg_
mutableprotected

◆ inp_

BufferString Math::ExpressionParser::inp_
protected

◆ inputsareseries_

const bool Math::ExpressionParser::inputsareseries_
protected

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