muParser API -  1.35
muParserCallback.h
Go to the documentation of this file.
1 /*
2 
3  _____ __ _____________ _______ ______ ___________
4  / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \
5  | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/
6  |__|_| /____/| __(____ /__| /____ >\___ >__|
7  \/ |__| \/ \/ \/
8  Copyright (C) 2022 Ingo Berg
9 
10  Redistribution and use in source and binary forms, with or without modification, are permitted
11  provided that the following conditions are met:
12 
13  * Redistributions of source code must retain the above copyright notice, this list of
14  conditions and the following disclaimer.
15  * Redistributions in binary form must reproduce the above copyright notice, this list of
16  conditions and the following disclaimer in the documentation and/or other materials provided
17  with the distribution.
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20  IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22  CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23  DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25  IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28 
29 
30 #ifndef MU_PARSER_CALLBACK_H
31 #define MU_PARSER_CALLBACK_H
32 
33 #include "muParserDef.h"
34 
35 /** \file
36  \brief Definition of the parser callback class.
37 */
38 
39 namespace mu
40 {
41 
42  /** \brief Encapsulation of prototypes for a numerical parser function.
43 
44  Encapsulates the prototyp for numerical parser functions. The class
45  stores the number of arguments for parser functions as well
46  as additional flags indication the function is non optimizeable.
47  The pointer to the callback function pointer is stored as void*
48  and needs to be casted according to the argument count.
49  Negative argument counts indicate a parser function with a variable number
50  of arguments.
51  */
52  class API_EXPORT_CXX ParserCallback final
53  {
54  public:
55  ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti);
56  ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec, ECmdCode a_iCode);
57  ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti);
58  ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity);
59  ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti);
60  ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti);
61  ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti);
62  ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti);
63  ParserCallback(fun_type6 a_pFun, bool a_bAllowOpti);
64  ParserCallback(fun_type7 a_pFun, bool a_bAllowOpti);
65  ParserCallback(fun_type8 a_pFun, bool a_bAllowOpti);
66  ParserCallback(fun_type9 a_pFun, bool a_bAllowOpti);
67  ParserCallback(fun_type10 a_pFun, bool a_bAllowOpti);
68 
69  ParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti);
70  ParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti);
71  ParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti);
72  ParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti);
73  ParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti);
74  ParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti);
75  ParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti);
76  ParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti);
77  ParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti);
78  ParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti);
79  ParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti);
80 
81  ParserCallback(multfun_type a_pFun, bool a_bAllowOpti);
82 
83  ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti);
84  ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti);
85  ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti);
86  ParserCallback(strfun_type4 a_pFun, bool a_bAllowOpti);
87  ParserCallback(strfun_type5 a_pFun, bool a_bAllowOpti);
88  ParserCallback(strfun_type6 a_pFun, bool a_bAllowOpti);
89 
90  // note: a_pUserData shall not be nullptr
91  ParserCallback(fun_userdata_type0 a_pFun, void* a_pUserData, bool a_bAllowOpti);
92  ParserCallback(fun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti);
93  ParserCallback(fun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti);
94  ParserCallback(fun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti);
95  ParserCallback(fun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti);
96  ParserCallback(fun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti);
97  ParserCallback(fun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti);
98  ParserCallback(fun_userdata_type7 a_pFun, void* a_pUserData, bool a_bAllowOpti);
99  ParserCallback(fun_userdata_type8 a_pFun, void* a_pUserData, bool a_bAllowOpti);
100  ParserCallback(fun_userdata_type9 a_pFun, void* a_pUserData, bool a_bAllowOpti);
101  ParserCallback(fun_userdata_type10 a_pFun, void* a_pUserData, bool a_bAllowOpti);
102 
103  ParserCallback(bulkfun_userdata_type0 a_pFun, void* a_pUserData, bool a_bAllowOpti);
104  ParserCallback(bulkfun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti);
105  ParserCallback(bulkfun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti);
106  ParserCallback(bulkfun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti);
107  ParserCallback(bulkfun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti);
108  ParserCallback(bulkfun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti);
109  ParserCallback(bulkfun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti);
110  ParserCallback(bulkfun_userdata_type7 a_pFun, void* a_pUserData, bool a_bAllowOpti);
111  ParserCallback(bulkfun_userdata_type8 a_pFun, void* a_pUserData, bool a_bAllowOpti);
112  ParserCallback(bulkfun_userdata_type9 a_pFun, void* a_pUserData, bool a_bAllowOpti);
113  ParserCallback(bulkfun_userdata_type10 a_pFun, void* a_pUserData, bool a_bAllowOpti);
114 
115  ParserCallback(multfun_userdata_type a_pFun, void* a_pUserData, bool a_bAllowOpti);
116 
117  ParserCallback(strfun_userdata_type1 a_pFun, void* a_pUserData, bool a_bAllowOpti);
118  ParserCallback(strfun_userdata_type2 a_pFun, void* a_pUserData, bool a_bAllowOpti);
119  ParserCallback(strfun_userdata_type3 a_pFun, void* a_pUserData, bool a_bAllowOpti);
120  ParserCallback(strfun_userdata_type4 a_pFun, void* a_pUserData, bool a_bAllowOpti);
121  ParserCallback(strfun_userdata_type5 a_pFun, void* a_pUserData, bool a_bAllowOpti);
122  ParserCallback(strfun_userdata_type6 a_pFun, void* a_pUserData, bool a_bAllowOpti);
123 
124  ParserCallback();
125  ParserCallback(const ParserCallback& a_Fun);
126  ParserCallback & operator=(const ParserCallback& a_Fun);
127  ~ParserCallback();
128 
129  ParserCallback* Clone() const;
130 
131  bool IsOptimizable() const;
132  bool IsValid() const;
133  void* GetAddr() const;
134  void* GetUserData() const;
135  ECmdCode GetCode() const;
136  ETypeCode GetType() const;
137  int GetPri() const;
138  EOprtAssociativity GetAssociativity() const;
139  int GetArgc() const;
140 
141  private:
142  void Assign(const ParserCallback& ref);
143 
144  void* m_pFun; ///< Pointer to the callback function or internal data, casted to void
145 
146  int m_iArgc; ///< Internal representation of number of numeric function arguments
147  int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
148  EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
149  ECmdCode m_iCode;
150  ETypeCode m_iType;
151  bool m_bAllowOpti; ///< Flag indication optimizeability
152  };
153 
154 
155  /** \brief Container for Callback objects. */
156  typedef std::map<string_type, ParserCallback> funmap_type;
157 
158 } // namespace mu
159 
160 #endif
161 
value_type(* multfun_userdata_type)(void *, const value_type *, int)
Callback type with user data (not null) used for functions and a variable argument list...
Definition: muParserDef.h:463
value_type(* strfun_type1)(const char_type *)
Callback type used for functions taking a string as an argument.
Definition: muParserDef.h:466
value_type(* bulkfun_type1)(int, int, value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:397
value_type(* strfun_type6)(const char_type *, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions taking a string and five values as arguments.
Definition: muParserDef.h:481
value_type(* bulkfun_userdata_type10)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with ten arguments.
Definition: muParserDef.h:457
value_type(* fun_userdata_type8)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with eight arguments.
Definition: muParserDef.h:385
value_type(* bulkfun_userdata_type0)(void *, int, int)
Callback type with user data (not null) used for functions without arguments.
Definition: muParserDef.h:427
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 eight arguments.
Definition: muParserDef.h:418
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:343
value_type(* fun_userdata_type7)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with seven arguments.
Definition: muParserDef.h:382
value_type(* bulkfun_type2)(int, int, value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:400
value_type(* fun_type1)(value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:331
value_type(* bulkfun_userdata_type9)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with nine arguments.
Definition: muParserDef.h:454
value_type(* strfun_type4)(const char_type *, value_type, value_type, value_type)
Callback type used for functions taking a string and three values as arguments.
Definition: muParserDef.h:475
value_type(* fun_userdata_type0)(void *)
Callback type with user data (not null) used for functions without arguments.
Definition: muParserDef.h:361
value_type(* strfun_userdata_type4)(void *, const char_type *, value_type, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and a value as arguments...
Definition: muParserDef.h:493
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 nine arguments.
Definition: muParserDef.h:421
std::map< string_type, ParserCallback > funmap_type
Container for Callback objects.
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:472
value_type(* bulkfun_userdata_type3)(void *, int, int, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with three arguments.
Definition: muParserDef.h:436
value_type(* fun_userdata_type6)(void *, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with six arguments.
Definition: muParserDef.h:379
value_type(* strfun_userdata_type2)(void *, const char_type *, value_type)
Callback type with user data (not null) used for functions taking a string and a value as arguments...
Definition: muParserDef.h:487
value_type(* multfun_type)(const value_type *, int)
Callback type used for functions with a variable argument list.
Definition: muParserDef.h:460
value_type(* fun_userdata_type9)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with nine arguments.
Definition: muParserDef.h:388
value_type(* bulkfun_userdata_type5)(void *, int, int, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with five arguments.
Definition: muParserDef.h:442
EOprtAssociativity
Parser operator precedence values.
Definition: muParserDef.h:199
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 eight arguments.
Definition: muParserDef.h:352
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:409
value_type(* bulkfun_type6)(int, int, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with six arguments.
Definition: muParserDef.h:412
value_type(* strfun_type5)(const char_type *, value_type, value_type, value_type, value_type)
Callback type used for functions taking a string and four values as arguments.
Definition: muParserDef.h:478
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 ten arguments.
Definition: muParserDef.h:358
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 nine arguments.
Definition: muParserDef.h:355
ETypeCode
Types internally used by the parser.
Definition: muParserDef.h:183
value_type(* bulkfun_userdata_type1)(void *, int, int, value_type)
Callback type with user data (not null) used for functions with a single arguments.
Definition: muParserDef.h:430
value_type(* fun_userdata_type5)(void *, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with five arguments.
Definition: muParserDef.h:376
value_type(* fun_type2)(value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:334
ECmdCode
Bytecode values.
Definition: muParserDef.h:135
value_type(* fun_userdata_type3)(void *, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with three arguments.
Definition: muParserDef.h:370
value_type(* fun_userdata_type1)(void *, value_type)
Callback type with user data (not null) used for functions with a single arguments.
Definition: muParserDef.h:364
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:469
value_type(* bulkfun_userdata_type6)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with six arguments.
Definition: muParserDef.h:445
Namespace for mathematical applications.
Definition: muParser.cpp:46
value_type(* fun_type3)(value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:337
value_type(* fun_type0)()
Callback type used for functions without arguments.
Definition: muParserDef.h:328
value_type(* bulkfun_userdata_type8)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with eight arguments.
Definition: muParserDef.h:451
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 seven arguments.
Definition: muParserDef.h:415
value_type(* fun_userdata_type4)(void *, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with four arguments.
Definition: muParserDef.h:373
value_type(* bulkfun_userdata_type2)(void *, int, int, value_type, value_type)
Callback type with user data (not null) used for functions with two arguments.
Definition: muParserDef.h:433
value_type(* strfun_userdata_type3)(void *, const char_type *, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and two values as argument...
Definition: muParserDef.h:490
value_type(* fun_type4)(value_type, value_type, value_type, value_type)
Callback type used for functions with four arguments.
Definition: muParserDef.h:340
value_type(* strfun_userdata_type1)(void *, const char_type *)
Callback type with user data (not null) used for functions taking a string as an argument.
Definition: muParserDef.h:484
value_type(* fun_type7)(value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with seven arguments.
Definition: muParserDef.h:349
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:406
value_type(* bulkfun_userdata_type4)(void *, int, int, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with four arguments.
Definition: muParserDef.h:439
value_type(* strfun_userdata_type5)(void *, const char_type *, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and two values as argument...
Definition: muParserDef.h:496
value_type(* fun_userdata_type2)(void *, value_type, value_type)
Callback type with user data (not null) used for functions with two arguments.
Definition: muParserDef.h:367
value_type(* fun_userdata_type10)(void *, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with ten arguments.
Definition: muParserDef.h:391
value_type(* bulkfun_type0)(int, int)
Callback type used for functions without arguments.
Definition: muParserDef.h:394
value_type(* bulkfun_type3)(int, int, value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:403
value_type(* bulkfun_userdata_type7)(void *, int, int, value_type, value_type, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions with seven arguments.
Definition: muParserDef.h:448
Encapsulation of prototypes for a numerical parser function.
value_type(* fun_type6)(value_type, value_type, value_type, value_type, value_type, value_type)
Callback type used for functions with six arguments.
Definition: muParserDef.h:346
value_type(* strfun_userdata_type6)(void *, const char_type *, value_type, value_type, value_type, value_type, value_type)
Callback type with user data (not null) used for functions taking a string and five values as argumen...
Definition: muParserDef.h:499
This file contains standard definitions used by the parser.
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 ten arguments.
Definition: muParserDef.h:424