muParser API -  1.35
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
muParserCallback.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2004-2011 Ingo Berg
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy of this
11  software and associated documentation files (the "Software"), to deal in the Software
12  without restriction, including without limitation the rights to use, copy, modify,
13  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14  permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in all copies or
17  substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 
26 #ifndef MU_PARSER_CALLBACK_H
27 #define MU_PARSER_CALLBACK_H
28 
29 #include "muParserDef.h"
30 
31 /** \file
32  \brief Definition of the parser callback class.
33 */
34 
35 namespace mu
36 {
37 
38 /** \brief Encapsulation of prototypes for a numerical parser function.
39 
40  Encapsulates the prototyp for numerical parser functions. The class
41  stores the number of arguments for parser functions as well
42  as additional flags indication the function is non optimizeable.
43  The pointer to the callback function pointer is stored as void*
44  and needs to be casted according to the argument count.
45  Negative argument counts indicate a parser function with a variable number
46  of arguments.
47 
48  \author (C) 2004-2011 Ingo Berg
49 */
51 {
52 public:
53  ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti);
54  ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC);
55  ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity);
56  ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti);
57  ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti);
58  ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti);
59  ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti);
60  ParserCallback(fun_type6 a_pFun, bool a_bAllowOpti);
61  ParserCallback(fun_type7 a_pFun, bool a_bAllowOpti);
62  ParserCallback(fun_type8 a_pFun, bool a_bAllowOpti);
63  ParserCallback(fun_type9 a_pFun, bool a_bAllowOpti);
64  ParserCallback(fun_type10 a_pFun, bool a_bAllowOpti);
65 
66  ParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti);
67  ParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti);
68  ParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti);
69  ParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti);
70  ParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti);
71  ParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti);
72  ParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti);
73  ParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti);
74  ParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti);
75  ParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti);
76  ParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti);
77 
78  ParserCallback(multfun_type a_pFun, bool a_bAllowOpti);
79  ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti);
80  ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti);
81  ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti);
83  ParserCallback(const ParserCallback &a_Fun);
84 
85  ParserCallback* Clone() const;
86 
87  bool IsOptimizable() const;
88  void* GetAddr() const;
89  ECmdCode GetCode() const;
90  ETypeCode GetType() const;
91  int GetPri() const;
93  int GetArgc() const;
94 
95 private:
96  void *m_pFun; ///< Pointer to the callback function, casted to void
97 
98  /** \brief Number of numeric function arguments
99 
100  This number is negative for functions with variable number of arguments. in this cases
101  they represent the actual number of arguments found.
102  */
103  int m_iArgc;
104  int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
105  EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
106  ECmdCode m_iCode;
107  ETypeCode m_iType;
108  bool m_bAllowOpti; ///< Flag indication optimizeability
109 };
110 
111 //------------------------------------------------------------------------------
112 /** \brief Container for Callback objects. */
113 typedef std::map<string_type, ParserCallback> funmap_type;
114 
115 } // namespace mu
116 
117 #endif
118 
ParserCallback()
Default constructor.
value_type(* bulkfun_type6)(int, int, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:334
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:358
value_type(* fun_type3)(value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:292
value_type(* bulkfun_type2)(int, int, value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:322
value_type(* bulkfun_type9)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:343
value_type(* bulkfun_type0)(int, int)
Callback type used for functions without arguments.
Definition: muParserDef.h:316
value_type(* fun_type6)(value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:301
value_type(* bulkfun_type7)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:337
std::map< string_type, ParserCallback > funmap_type
Container for Callback objects.
ECmdCode GetCode() const
Return the callback code.
bool IsOptimizable() const
Return tru if the function is conservative.
Code for a generic function item.
Definition: muParserDef.h:185
EOprtAssociativity
Parser operator precedence values.
Definition: muParserDef.h:215
ParserCallback * Clone() const
Clone this instance and return a pointer to the new instance.
value_type(* strfun_type1)(const char_type *)
Callback type used for functions taking a string as an argument.
Definition: muParserDef.h:352
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:355
EOprtAssociativity GetAssociativity() const
Return the operators associativity.
ETypeCode
Types internally used by the parser.
Definition: muParserDef.h:199
value_type(* bulkfun_type1)(int, int, value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:319
ECmdCode
Bytecode values.
Definition: muParserDef.h:149
value_type(* bulkfun_type4)(int, int, value_type, value_type, value_type, value_type)
Callback type used for functions with four arguments.
Definition: muParserDef.h:328
value_type(* bulkfun_type10)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:346
Namespace for mathematical applications.
Definition: muParser.cpp:49
value_type(* fun_type8)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:307
value_type(* fun_type7)(value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:304
value_type(* fun_type0)()
Callback type used for functions without arguments.
Definition: muParserDef.h:283
void * GetAddr() const
Get the callback address for the parser function.
value_type(* fun_type4)(value_type, value_type, value_type, value_type)
Callback type used for functions with four arguments.
Definition: muParserDef.h:295
value_type(* fun_type1)(value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:286
value_type(* bulkfun_type3)(int, int, value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:325
int GetArgc() const
Returns the number of function Arguments.
value_type(* bulkfun_type8)(int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:340
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:298
value_type(* fun_type2)(value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:289
value_type(* fun_type10)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:313
Encapsulation of prototypes for a numerical parser function.
int GetPri() const
Return the operator precedence.
value_type(* bulkfun_type5)(int, int, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:331
value_type(* fun_type9)(value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with five arguments.
Definition: muParserDef.h:310
value_type(* multfun_type)(const value_type *, int)
Callback type used for functions with a variable argument list.
Definition: muParserDef.h:349
This file contains standard definitions used by the parser.