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) 2004 - 2020 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 = -1, ECmdCode a_iCode = cmFUNC);
57  ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec, EOprtAssociativity a_eAssociativity);
58  ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti);
59  ParserCallback(fun_type3 a_pFun, bool a_bAllowOpti);
60  ParserCallback(fun_type4 a_pFun, bool a_bAllowOpti);
61  ParserCallback(fun_type5 a_pFun, bool a_bAllowOpti);
62  ParserCallback(fun_type6 a_pFun, bool a_bAllowOpti);
63  ParserCallback(fun_type7 a_pFun, bool a_bAllowOpti);
64  ParserCallback(fun_type8 a_pFun, bool a_bAllowOpti);
65  ParserCallback(fun_type9 a_pFun, bool a_bAllowOpti);
66  ParserCallback(fun_type10 a_pFun, bool a_bAllowOpti);
67 
68  ParserCallback(bulkfun_type0 a_pFun, bool a_bAllowOpti);
69  ParserCallback(bulkfun_type1 a_pFun, bool a_bAllowOpti);
70  ParserCallback(bulkfun_type2 a_pFun, bool a_bAllowOpti);
71  ParserCallback(bulkfun_type3 a_pFun, bool a_bAllowOpti);
72  ParserCallback(bulkfun_type4 a_pFun, bool a_bAllowOpti);
73  ParserCallback(bulkfun_type5 a_pFun, bool a_bAllowOpti);
74  ParserCallback(bulkfun_type6 a_pFun, bool a_bAllowOpti);
75  ParserCallback(bulkfun_type7 a_pFun, bool a_bAllowOpti);
76  ParserCallback(bulkfun_type8 a_pFun, bool a_bAllowOpti);
77  ParserCallback(bulkfun_type9 a_pFun, bool a_bAllowOpti);
78  ParserCallback(bulkfun_type10 a_pFun, bool a_bAllowOpti);
79 
80  ParserCallback(multfun_type a_pFun, bool a_bAllowOpti);
81  ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti);
82  ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti);
83  ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti);
84  ParserCallback(strfun_type4 a_pFun, bool a_bAllowOpti);
85  ParserCallback(strfun_type5 a_pFun, bool a_bAllowOpti);
87  ParserCallback(const ParserCallback& a_Fun);
88  ParserCallback & operator=(const ParserCallback& a_Fun);
89 
90  ParserCallback* Clone() const;
91 
92  bool IsOptimizable() const;
93  void* GetAddr() const;
94  ECmdCode GetCode() const;
95  ETypeCode GetType() const;
96  int GetPri() const;
97  EOprtAssociativity GetAssociativity() const;
98  int GetArgc() const;
99 
100  private:
101  void* m_pFun; ///< Pointer to the callback function, casted to void
102 
103  /** \brief Number of numeric function arguments
104 
105  This number is negative for functions with variable number of arguments. in this cases
106  they represent the actual number of arguments found.
107  */
108  int m_iArgc;
109  int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
110  EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
111  ECmdCode m_iCode;
112  ETypeCode m_iType;
113  bool m_bAllowOpti; ///< Flag indication optimizeability
114  };
115 
116 
117  /** \brief Container for Callback objects. */
118  typedef std::map<string_type, ParserCallback> funmap_type;
119 
120 } // namespace mu
121 
122 #endif
123 
value_type(* strfun_type1)(const char_type *)
Callback type used for functions taking a string as an argument.
Definition: muParserDef.h:397
value_type(* bulkfun_type1)(int, int, value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:364
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:385
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(* bulkfun_type2)(int, int, value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:367
value_type(* fun_type1)(value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:331
value_type(* strfun_type4)(const char_type *, value_type, value_type, value_type)
Callback type used for functions taking a string and a value as arguments.
Definition: muParserDef.h:406
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:388
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:403
value_type(* multfun_type)(const value_type *, int)
Callback type used for functions with a variable argument list.
Definition: muParserDef.h:394
Code for a generic function item.
Definition: muParserDef.h:170
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:376
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:379
value_type(* strfun_type5)(const char_type *, value_type, value_type, value_type, value_type)
Callback type used for functions taking a string and two values as arguments.
Definition: muParserDef.h:409
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(* 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(* strfun_type2)(const char_type *, value_type)
Callback type used for functions taking a string and a value as arguments.
Definition: muParserDef.h:400
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_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:382
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(* 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:373
value_type(* bulkfun_type0)(int, int)
Callback type used for functions without arguments.
Definition: muParserDef.h:361
value_type(* bulkfun_type3)(int, int, value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:370
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
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:391