25 #ifndef MU_PARSER_BASE_H
26 #define MU_PARSER_BASE_H
78 typedef std::vector<string_type> stringbuf_type;
118 return (this->*m_pParseFormula)();
131 #define MUP_DEFINE_FUNC(TYPE) \
132 inline void DefineFun(const string_type &a_strName, TYPE a_pFun, bool a_bAllowOpt = true) \
134 AddCallback( a_strName, ParserCallback(a_pFun, a_bAllowOpt), \
135 m_FunDef, ValidNameChars() ); \
148 #undef MUP_DEFINE_FUNC
185 int a_iPos = (
int)mu::string_type::npos,
202 void InitTokenReader();
215 int iArgCount)
const;
217 token_type ApplyNumFunc(
const token_type &a_FunTok,
218 const std::vector<token_type> &a_vArg)
const;
220 token_type ApplyStrFunc(
const token_type &a_FunTok,
221 const std::vector<token_type> &a_vArg)
const;
223 int GetOprtPri(
const token_type &a_Tok)
const;
232 #if defined(MUP_DUMP_STACK) | defined(MUP_DUMP_CMDCODE)
241 mutable ParseFunction m_pParseFormula;
244 mutable stringbuf_type m_vStringBuf;
245 stringbuf_type m_vStringVarBuf;
247 std::auto_ptr<token_reader_type> m_pTokenReader;
void DefinePostfixOprt(const string_type &a_strFun, fun_type1 a_pOprt, bool a_bAllowOpt=true)
Add a user defined operator.
Definition: muParserBase.cpp:348
void DefineInfixOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of infix operators.
Definition: muParserBase.cpp:309
const muChar_t cArgSep
Definition: muParserDLL.h:148
Definition of the parser bytecode class.
void DefineNameChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of functions, variables, constants.
Definition: muParserBase.cpp:291
void DefineVar(const string_type &a_sName, value_type *a_fVar)
Add a user defined variable.
Definition: muParserBase.cpp:441
virtual void InitCharSets()=0
const funmap_type & GetFunDef() const
Return prototypes of all parser functions.
Definition: muParserBase.cpp:559
std::map< string_type, std::size_t > strmap_type
Type for assigning a string name to an index in the internal string table.
Definition: muParserDef.h:256
std::map< string_type, value_type * > varmap_type
Type used for storing variables.
Definition: muParserDef.h:250
value_type(* strfun_type3)(const char_type *, value_type, value_type)
Callback type used for functions taking a string and two values as arguments.
Definition: muParserDef.h:288
value_type(* fun_type3)(value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:270
static const char_type * c_DefaultOprt[]
Identifiers for built in binary operators.
Definition: muParserBase.h:197
void ClearConst()
Clear all user defined constants.
Definition: muParserBase.cpp:1317
const muChar_t muFloat_t a_fVal
Definition: muParserDLL.h:107
const char_type * ValidInfixOprtChars() const
Virtual function that defines the characters allowed in infix operator definitions.
Definition: muParserBase.cpp:338
void ClearOprt()
Clear all user defined binary operators.
Definition: muParserBase.cpp:1340
void SetArgSep(char_type cArgSep)
Set argument separator.
Definition: muParserBase.cpp:1419
const char_type * ValidOprtChars() const
Virtual function that defines the characters allowed in operator definitions.
Definition: muParserBase.cpp:328
void AddValIdent(identfun_type a_pCallback)
Definition: muParserBase.cpp:196
Signs have a higher priority than ADD_SUB, but lower than power operator.
Definition: muParserDef.h:211
muFacFun_t a_pFactory
Definition: muParserDLL.h:79
value_type Eval() const
Calculate the result.
Definition: muParserBase.h:116
Parser stack implementation.
Definition: muParserStack.h:53
bool HasBuiltInOprt() const
Query status of built in variables.
Definition: muParserBase.cpp:1402
std::map< string_type, ParserCallback > funmap_type
Container for Callback objects.
Definition: muParserCallback.h:93
const muChar_t muFun0_t a_pFun
Definition: muParserDLL.h:84
bytecode_type map_type
Underlying type of the container.
Definition: muParserBytecode.h:65
void ClearVar()
Clear all user defined variables.
Definition: muParserBase.cpp:1262
void EnableOptimizer(bool a_bIsOn=true)
Enable or disable the formula optimization feature.
Definition: muParserBase.cpp:1362
void DefineInfixOprt(const string_type &a_strName, fun_type1 a_pOprt, int a_iPrec=prINFIX, bool a_bAllowOpt=true)
Add a user defined operator.
Definition: muParserBase.cpp:380
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.
Definition: muParserBase.cpp:1251
void SetVarFactory(facfun_type a_pFactory, void *pUserData=NULL)
Definition: muParserBase.cpp:202
const string_type & GetExpr() const
Retrieve the formula.
Definition: muParserBase.cpp:566
void DefineOprtChars(const char_type *a_szCharset)
Define the set of valid characters to be used in names of binary operators and postfix operators...
Definition: muParserBase.cpp:300
const char_type * ValidNameChars() const
Virtual function that defines the characters allowed in name identifiers.
Definition: muParserBase.cpp:318
void EnableByteCode(bool a_bIsOn=true)
Enable or disable parsing from Bytecode.
Definition: muParserBase.cpp:1374
This file contains the parser token reader definition.
value_type(* strfun_type1)(const char_type *)
Callback type used for functions taking a string as an argument.
Definition: muParserDef.h:282
std::map< string_type, value_type > valmap_type
Type used for storing constants.
Definition: muParserDef.h:253
void ClearPostfixOprt()
Clear all user defined postfix operators.
Definition: muParserBase.cpp:1329
value_type(* strfun_type2)(const char_type *, value_type)
Callback type used for functions taking a string and a value as arguments.
Definition: muParserDef.h:285
const valmap_type & GetConst() const
Return a map containing all parser constants.
Definition: muParserBase.cpp:543
virtual void InitOprt()=0
const muChar_t muFun1_t a_pOprt
Definition: muParserDLL.h:119
Error class of the parser.
Definition: muParserError.h:119
const varmap_type & GetVar() const
Return a map containing the used variables only.
Definition: muParserBase.cpp:536
MUP_BASETYPE value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:222
void SetExpr(const string_type &a_sExpr)
Set the formula.
Definition: muParserBase.cpp:261
Namespace for mathematical applications.
Definition: muParser.cpp:47
void RemoveVar(const string_type &a_strVarName)
Remove a variable from internal storage.
Definition: muParserBase.cpp:1274
const char_type ** GetOprtDef() const
Get the default symbols used for the built in operators.
Definition: muParserBase.cpp:282
This file defines the stack used by muparser.
virtual ~ParserBase()
Definition: muParserBase.cpp:112
string_type::value_type char_type
The character type used by the parser.
Definition: muParserDef.h:240
value_type(* fun_type0)()
Callback type used for functions without arguments.
Definition: muParserDef.h:261
Token reader for the ParserBase class.
Definition: muParserTokenReader.h:53
ParserBase & operator=(const ParserBase &a_Parser)
Assignement operator.
Definition: muParserBase.cpp:123
void DefineConst(const string_type &a_sName, value_type a_fVal)
Add a user defined constant.
Definition: muParserBase.cpp:465
void EnableBuiltInOprt(bool a_bIsOn=true)
Enable or disable the built in binary operators.
Definition: muParserBase.cpp:1391
value_type(* fun_type4)(value_type, value_type, value_type, value_type)
Callback type used for functions with four arguments.
Definition: muParserDef.h:273
const muChar_t muFloat_t * a_fVar
Definition: muParserDLL.h:115
void DefineOprt(const string_type &a_strName, fun_type2 a_pFun, unsigned a_iPri=0, bool a_bAllowOpt=false)
Define a binary operator.
Definition: muParserBase.cpp:398
const muChar_t * a_szCharset
Definition: muParserDLL.h:130
Bytecode implementation of the Math Parser.
Definition: muParserBytecode.h:56
MUP_STRING_TYPE string_type
The stringtype used by the parser.
Definition: muParserDef.h:228
ParserBase()
Constructor.
Definition: muParserBase.cpp:66
value_type(* fun_type1)(value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:264
ParserError exception_type
Type of the error class.
Definition: muParserBase.h:92
int(* identfun_type)(const char_type *sExpr, int *nPos, value_type *fVal)
Callback used for functions that identify values in a string.
Definition: muParserDef.h:291
void ClearFun()
Clear all functions.
Definition: muParserBase.cpp:1304
void DefineStrConst(const string_type &a_sName, const string_type &a_strVal)
Define a new string constant.
Definition: muParserBase.cpp:419
char_type GetArgSep() const
Get the argument separator character.
Definition: muParserBase.cpp:1410
value_type *(* facfun_type)(const char_type *, void *)
Callback used for variable creation factory functions.
Definition: muParserDef.h:294
value_type(* fun_type5)(value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:276
muFacFun_t void * pUserData
Definition: muParserDLL.h:79
value_type(* fun_type2)(value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:267
EErrorCodes
Error codes.
Definition: muParserError.h:46
void Init()
Initialize user defined functions.
Definition: muParserBase.cpp:363
Encapsulation of prototypes for a numerical parser function.
Definition: muParserCallback.h:51
virtual void InitConst()=0
#define MUP_DEFINE_FUNC(TYPE)
Definition: muParserBase.h:131
void ClearInfixOprt()
Clear the user defined Prefix operators.
Definition: muParserBase.cpp:1351
Mathematical expressions parser (base parser engine).
Definition: muParserBase.h:63
value_type(* multfun_type)(const value_type *, int)
Callback type used for functions with a variable argument list.
Definition: muParserDef.h:279
const varmap_type & GetUsedVar() const
Return a map containing the used variables only.
Definition: muParserBase.cpp:512
This file defines the error class used by the parser.
This file contains standard definitions used by the parser.