OpcUaCanOpen
CANopen OPC-UA server
mu::ParserInt Class Reference

Mathematical expressions parser. More...

#include <muParserInt.h>

Inherits mu::ParserBase.

Classes

class  change_dec_sep
 A facet class used to change decimal and thousands separator. More...
 

Public Member Functions

 ParserInt ()
 Constructor. More...
 
virtual void InitFun ()
 Initialize the default functions. More...
 
virtual void InitOprt ()
 Initialize operators. More...
 
virtual void InitConst ()
 
virtual void InitCharSets ()
 
- Public Member Functions inherited from mu::ParserBase
 ParserBase ()
 Constructor. More...
 
 ParserBase (const ParserBase &a_Parser)
 Copy constructor. More...
 
ParserBaseoperator= (const ParserBase &a_Parser)
 Assignment operator. More...
 
virtual ~ParserBase ()
 
value_type Eval () const
 Calculate the result. More...
 
value_typeEval (int &nStackSize) const
 Evaluate an expression containing comma separated subexpressions. More...
 
void Eval (value_type *results, int nBulkSize)
 
int GetNumResults () const
 Return the number of results on the calculation stack. More...
 
void SetExpr (const string_type &a_sExpr)
 Set the formula. More...
 
void SetVarFactory (facfun_type a_pFactory, void *pUserData=NULL)
 Set a function that can create variable pointer for unknown expression variables. More...
 
void SetDecSep (char_type cDecSep)
 Set the decimal separator. More...
 
void SetThousandsSep (char_type cThousandsSep=0)
 Sets the thousands operator. More...
 
void ResetLocale ()
 Resets the locale. More...
 
void EnableOptimizer (bool a_bIsOn=true)
 Enable or disable the formula optimization feature. More...
 
void EnableBuiltInOprt (bool a_bIsOn=true)
 Enable or disable the built in binary operators. More...
 
bool HasBuiltInOprt () const
 Query status of built in variables. More...
 
void AddValIdent (identfun_type a_pCallback)
 Add a value parsing function. More...
 
template<typename T >
void DefineFun (const string_type &a_strName, T a_pFun, bool a_bAllowOpt=true)
 Define a parser function without arguments. More...
 
void DefineOprt (const string_type &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, EOprtAssociativity a_eAssociativity=oaLEFT, bool a_bAllowOpt=false)
 Define a binary operator. More...
 
void DefineConst (const string_type &a_sName, value_type a_fVal)
 Add a user defined constant. More...
 
void DefineStrConst (const string_type &a_sName, const string_type &a_strVal)
 Define a new string constant. More...
 
void DefineVar (const string_type &a_sName, value_type *a_fVar)
 Add a user defined variable. More...
 
void DefinePostfixOprt (const string_type &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true)
 Add a user defined operator. More...
 
void DefineInfixOprt (const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true)
 Add a user defined operator. More...
 
void ClearVar ()
 Clear all user defined variables. More...
 
void ClearFun ()
 Clear all functions. More...
 
void ClearConst ()
 Clear all user defined constants. More...
 
void ClearInfixOprt ()
 Clear the user defined Prefix operators. More...
 
void ClearPostfixOprt ()
 Clear all user defined postfix operators. More...
 
void ClearOprt ()
 Clear all user defined binary operators. More...
 
void RemoveVar (const string_type &a_strVarName)
 Remove a variable from internal storage. More...
 
const varmap_typeGetUsedVar () const
 Return a map containing the used variables only. More...
 
const varmap_typeGetVar () const
 Return a map containing the used variables only. More...
 
const valmap_typeGetConst () const
 Return a map containing all parser constants. More...
 
const string_typeGetExpr () const
 Retrieve the formula. More...
 
const funmap_typeGetFunDef () const
 Return prototypes of all parser functions. More...
 
string_type GetVersion (EParserVersionInfo eInfo=pviFULL) const
 Returns the version of muparser. More...
 
const char_type ** GetOprtDef () const
 Get the default symbols used for the built in operators. More...
 
void DefineNameChars (const char_type *a_szCharset)
 Define the set of valid characters to be used in names of functions, variables, constants. More...
 
void DefineOprtChars (const char_type *a_szCharset)
 Define the set of valid characters to be used in names of binary operators and postfix operators. More...
 
void DefineInfixOprtChars (const char_type *a_szCharset)
 Define the set of valid characters to be used in names of infix operators. More...
 
const char_typeValidNameChars () const
 Virtual function that defines the characters allowed in name identifiers. More...
 
const char_typeValidOprtChars () const
 Virtual function that defines the characters allowed in operator definitions. More...
 
const char_typeValidInfixOprtChars () const
 Virtual function that defines the characters allowed in infix operator definitions. More...
 
void SetArgSep (char_type cArgSep)
 Set argument separator. More...
 
char_type GetArgSep () const
 Get the argument separator character. More...
 
void Error (EErrorCodes a_iErrc, int a_iPos=(int) mu::string_type::npos, const string_type &a_strTok=string_type()) const
 Create an error containing the parse error position. More...
 

Static Private Member Functions

static int Round (value_type v)
 
static value_type Abs (value_type)
 
static value_type Sign (value_type)
 
static value_type Ite (value_type, value_type, value_type)
 
static value_type UnaryMinus (value_type)
 
static value_type Sum (const value_type *a_afArg, int a_iArgc)
 
static value_type Min (const value_type *a_afArg, int a_iArgc)
 
static value_type Max (const value_type *a_afArg, int a_iArgc)
 
static value_type Add (value_type v1, value_type v2)
 
static value_type Sub (value_type v1, value_type v2)
 
static value_type Mul (value_type v1, value_type v2)
 
static value_type Div (value_type v1, value_type v2)
 
static value_type Mod (value_type v1, value_type v2)
 
static value_type Pow (value_type v1, value_type v2)
 
static value_type Shr (value_type v1, value_type v2)
 
static value_type Shl (value_type v1, value_type v2)
 
static value_type LogAnd (value_type v1, value_type v2)
 
static value_type LogOr (value_type v1, value_type v2)
 
static value_type And (value_type v1, value_type v2)
 
static value_type Or (value_type v1, value_type v2)
 
static value_type Xor (value_type v1, value_type v2)
 
static value_type Less (value_type v1, value_type v2)
 
static value_type Greater (value_type v1, value_type v2)
 
static value_type LessEq (value_type v1, value_type v2)
 
static value_type GreaterEq (value_type v1, value_type v2)
 
static value_type Equal (value_type v1, value_type v2)
 
static value_type NotEqual (value_type v1, value_type v2)
 
static value_type Not (value_type v1)
 
static int IsHexVal (const char_type *a_szExpr, int *a_iPos, value_type *a_iVal)
 Check a given position in the expression for the presence of a hex value. More...
 
static int IsBinVal (const char_type *a_szExpr, int *a_iPos, value_type *a_iVal)
 
static int IsVal (const char_type *a_szExpr, int *a_iPos, value_type *a_iVal)
 

Additional Inherited Members

- Public Types inherited from mu::ParserBase
typedef ParserError exception_type
 Type of the error class. More...
 
- Static Public Member Functions inherited from mu::ParserBase
static void EnableDebugDump (bool bDumpCmd, bool bDumpStack)
 Enable the dumping of bytecode and stack content on the console. More...
 
- Protected Member Functions inherited from mu::ParserBase
void Init ()
 Initialize user defined functions. More...
 
virtual void OnDetectVar (string_type *pExpr, int &nStart, int &nEnd)
 
- Static Protected Attributes inherited from mu::ParserBase
static const char_typec_DefaultOprt []
 Identifiers for built in binary operators. More...
 
static std::locale s_locale = std::locale(std::locale::classic(), new change_dec_sep<char_type>('.'))
 The locale used by the parser. More...
 
static bool g_DbgDumpCmdCode = false
 
static bool g_DbgDumpStack = false
 

Detailed Description

Mathematical expressions parser.

This version of the parser handles only integer numbers. It disables the built in operators thus it is slower than muParser. Integer values are stored in the double value_type and converted if needed.

Definition at line 46 of file muParserInt.h.

Constructor & Destructor Documentation

◆ ParserInt()

mu::ParserInt::ParserInt ( )

Constructor.

Call ParserBase class constructor and trigger Function, Operator and Constant initialization.

Definition at line 206 of file muParserInt.cpp.

Member Function Documentation

◆ Abs()

value_type mu::ParserInt::Abs ( value_type  v)
staticprivate

Definition at line 41 of file muParserInt.cpp.

◆ Add()

value_type mu::ParserInt::Add ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 46 of file muParserInt.cpp.

◆ And()

value_type mu::ParserInt::And ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 55 of file muParserInt.cpp.

◆ Div()

value_type mu::ParserInt::Div ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 49 of file muParserInt.cpp.

◆ Equal()

value_type mu::ParserInt::Equal ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 61 of file muParserInt.cpp.

◆ Greater()

value_type mu::ParserInt::Greater ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 58 of file muParserInt.cpp.

◆ GreaterEq()

value_type mu::ParserInt::GreaterEq ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 60 of file muParserInt.cpp.

◆ InitCharSets()

void mu::ParserInt::InitCharSets ( )
virtual

Implements mu::ParserBase.

Definition at line 224 of file muParserInt.cpp.

◆ InitConst()

void mu::ParserInt::InitConst ( )
virtual

Implements mu::ParserBase.

Definition at line 219 of file muParserInt.cpp.

◆ InitFun()

void mu::ParserInt::InitFun ( )
virtual

Initialize the default functions.

Implements mu::ParserBase.

Definition at line 233 of file muParserInt.cpp.

◆ InitOprt()

void mu::ParserInt::InitOprt ( )
virtual

Initialize operators.

Implements mu::ParserBase.

Definition at line 245 of file muParserInt.cpp.

◆ IsBinVal()

int mu::ParserInt::IsBinVal ( const char_type a_szExpr,
int *  a_iPos,
value_type a_iVal 
)
staticprivate

Definition at line 177 of file muParserInt.cpp.

◆ IsHexVal()

int mu::ParserInt::IsHexVal ( const char_type a_szExpr,
int *  a_iPos,
value_type a_fVal 
)
staticprivate

Check a given position in the expression for the presence of a hex value.

Parameters
a_szExprPointer to the expression string
[in/out]a_iPos Pointer to an integer value holding the current parsing position in the expression.
[out]a_fValPointer to the position where the detected value shall be stored.

Hey values must be prefixed with "0x" in order to be detected properly.

Definition at line 155 of file muParserInt.cpp.

◆ IsVal()

int mu::ParserInt::IsVal ( const char_type a_szExpr,
int *  a_iPos,
value_type a_iVal 
)
staticprivate

Definition at line 118 of file muParserInt.cpp.

◆ Ite()

value_type mu::ParserInt::Ite ( value_type  v1,
value_type  v2,
value_type  v3 
)
staticprivate

Definition at line 43 of file muParserInt.cpp.

◆ Less()

value_type mu::ParserInt::Less ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 57 of file muParserInt.cpp.

◆ LessEq()

value_type mu::ParserInt::LessEq ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 59 of file muParserInt.cpp.

◆ LogAnd()

value_type mu::ParserInt::LogAnd ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 53 of file muParserInt.cpp.

◆ LogOr()

value_type mu::ParserInt::LogOr ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 54 of file muParserInt.cpp.

◆ Max()

value_type mu::ParserInt::Max ( const value_type a_afArg,
int  a_iArgc 
)
staticprivate

Definition at line 104 of file muParserInt.cpp.

◆ Min()

value_type mu::ParserInt::Min ( const value_type a_afArg,
int  a_iArgc 
)
staticprivate

Definition at line 91 of file muParserInt.cpp.

◆ Mod()

value_type mu::ParserInt::Mod ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 50 of file muParserInt.cpp.

◆ Mul()

value_type mu::ParserInt::Mul ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 48 of file muParserInt.cpp.

◆ Not()

value_type mu::ParserInt::Not ( value_type  v1)
staticprivate

Definition at line 63 of file muParserInt.cpp.

◆ NotEqual()

value_type mu::ParserInt::NotEqual ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 62 of file muParserInt.cpp.

◆ Or()

value_type mu::ParserInt::Or ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 56 of file muParserInt.cpp.

◆ Pow()

value_type mu::ParserInt::Pow ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 65 of file muParserInt.cpp.

◆ Round()

static int mu::ParserInt::Round ( value_type  v)
inlinestaticprivate

Definition at line 49 of file muParserInt.h.

◆ Shl()

value_type mu::ParserInt::Shl ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 52 of file muParserInt.cpp.

◆ Shr()

value_type mu::ParserInt::Shr ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 51 of file muParserInt.cpp.

◆ Sign()

value_type mu::ParserInt::Sign ( value_type  v)
staticprivate

Definition at line 42 of file muParserInt.cpp.

◆ Sub()

value_type mu::ParserInt::Sub ( value_type  v1,
value_type  v2 
)
staticprivate

Definition at line 47 of file muParserInt.cpp.

◆ Sum()

value_type mu::ParserInt::Sum ( const value_type a_afArg,
int  a_iArgc 
)
staticprivate

Definition at line 78 of file muParserInt.cpp.

◆ UnaryMinus()

value_type mu::ParserInt::UnaryMinus ( value_type  v)
staticprivate

Definition at line 72 of file muParserInt.cpp.

◆ Xor()

static value_type mu::ParserInt::Xor ( value_type  v1,
value_type  v2 
)
staticprivate

The documentation for this class was generated from the following files: