NCBI C++ ToolKit
muParserCallback.h
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2004-2008 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  This class is not used for string function prototyping.
48 
49  \author (C) 2004-2007 Ingo Berg
50 */
52 {
53 public:
54  ParserCallback(fun_type0 a_pFun, bool a_bAllowOpti);
55  ParserCallback(fun_type1 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC);
56  ParserCallback(fun_type2 a_pFun, bool a_bAllowOpti, int a_iPrec = -1, ECmdCode a_iCode=cmFUNC);
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(multfun_type a_pFun, bool a_bAllowOpti);
61  ParserCallback(strfun_type1 a_pFun, bool a_bAllowOpti);
62  ParserCallback(strfun_type2 a_pFun, bool a_bAllowOpti);
63  ParserCallback(strfun_type3 a_pFun, bool a_bAllowOpti);
65  ParserCallback(const ParserCallback &a_Fun);
66 
67  ParserCallback* Clone() const;
68 
69  bool IsOptimizable() const;
70  void* GetAddr() const;
71  ECmdCode GetCode() const;
72  ETypeCode GetType() const;
73  int GetPri() const;
74  int GetArgc() const;
75 
76 private:
77  void *m_pFun; ///< Pointer to the callback function, casted to void
78 
79  /** \brief Number of numeric function arguments
80 
81  This number is negative for functions with variable number of arguments. in this cases
82  they represent the actual number of arguments found.
83  */
84  int m_iArgc;
85  int m_iPri; ///< Valid only for binary and infix operators; Operator precedence.
88  bool m_bAllowOpti; ///< Flag indication optimizeability
89 };
90 
91 //------------------------------------------------------------------------------
92 /** \brief Container for Callback objects. */
93 typedef std::map<string_type, ParserCallback> funmap_type;
94 
95 } // namespace mu
96 
97 #endif
98 
Encapsulation of prototypes for a numerical parser function.
void * m_pFun
Pointer to the callback function, casted to void.
ParserCallback * Clone() const
Clone this instance and return a pointer to the new instance.
ParserCallback()
Default constructor.
int m_iPri
Valid only for binary and infix operators; Operator precedence.
int GetArgc() const
Returns the number of function Arguments.
ETypeCode GetType() const
bool m_bAllowOpti
Flag indication optimizeability.
int GetPri() const
Return the operator priority.
int m_iArgc
Number of numeric function arguments.
bool IsOptimizable() const
Return tru if the function is conservative.
void * GetAddr() const
Get the callback address for the parser function.
ECmdCode GetCode() const
Return the callback code.
This file contains standard definitions used by the parser.
Namespace for mathematical applications.
Definition: muParser.h:41
value_type(* multfun_type)(const value_type *, int)
Callback type used for functions with a variable argument list.
Definition: muParserDef.h:285
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:291
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:294
value_type(* strfun_type1)(const char_type *)
Callback type used for functions taking a string as an argument.
Definition: muParserDef.h:288
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:282
std::map< string_type, ParserCallback > funmap_type
Container for Callback objects.
ECmdCode
Bytecode values.
Definition: muParserDef.h:161
@ cmFUNC
Code for a function item.
Definition: muParserDef.h:185
value_type(* fun_type2)(value_type, value_type)
Callback type used for functions with two arguments.
Definition: muParserDef.h:273
ETypeCode
Types internally used by the parser.
Definition: muParserDef.h:199
value_type(* fun_type3)(value_type, value_type, value_type)
Callback type used for functions with three arguments.
Definition: muParserDef.h:276
value_type(* fun_type4)(value_type, value_type, value_type, value_type)
Callback type used for functions with four arguments.
Definition: muParserDef.h:279
value_type(* fun_type0)()
Callback type used for functions without arguments.
Definition: muParserDef.h:267
value_type(* fun_type1)(value_type)
Callback type used for functions with a single arguments.
Definition: muParserDef.h:270
Modified on Wed Apr 17 13:09:24 2024 by modify_doxy.py rev. 669887