1a8d0602edc0739ad0f8c5821507e5f5206adb07
[alexxy/gromacs.git] / src / external / muparser / muParserCallback.h
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);
86                 ParserCallback();
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