3 _____ __ _____________ _______ ______ ___________
4 / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \
5 | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/
6 |__|_| /____/| __(____ /__| /____ >\___ >__|
8 Copyright (C) 2004 - 2020 Ingo Berg
10 Redistribution and use in source and binary forms, with or without modification, are permitted
11 provided that the following conditions are met:
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.
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.
30 #ifndef MU_PARSER_CALLBACK_H
31 #define MU_PARSER_CALLBACK_H
33 #include "muParserDef.h"
36 \brief Definition of the parser callback class.
42 /** \brief Encapsulation of prototypes for a numerical parser function.
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
52 class API_EXPORT_CXX ParserCallback final
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);
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);
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);
90 ParserCallback* Clone() const;
92 bool IsOptimizable() const;
93 void* GetAddr() const;
94 ECmdCode GetCode() const;
95 ETypeCode GetType() const;
97 EOprtAssociativity GetAssociativity() const;
101 void* m_pFun; ///< Pointer to the callback function, casted to void
103 /** \brief Number of numeric function arguments
105 This number is negative for functions with variable number of arguments. in this cases
106 they represent the actual number of arguments found.
109 int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
110 EOprtAssociativity m_eOprtAsct; ///< Operator associativity; Valid only for binary operators
113 bool m_bAllowOpti; ///< Flag indication optimizeability
117 /** \brief Container for Callback objects. */
118 typedef std::map<string_type, ParserCallback> funmap_type;