comparison muParserDLL.h @ 0:d9aae7d7f2c6

Import
author Daniele Nicolodi <daniele.nicolodi@obspm.fr>
date Tue, 03 Jul 2012 10:38:59 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d9aae7d7f2c6
1 /*
2 __________
3 _____ __ __\______ \_____ _______ ______ ____ _______
4 / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5 | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6 |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7 \/ \/ \/ \/
8 Copyright (C) 2004-2007 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 #ifndef MU_PARSER_DLL_H
26 #define MU_PARSER_DLL_H
27
28 #if defined(_WIN32)
29 #ifdef MUPARSERLIB_EXPORTS
30 // #define MU_PARSER_API extern "C" __declspec(dllexport)
31 #define API_EXPORT(TYPE) extern "C" __declspec(dllexport) TYPE __stdcall
32 #else
33 // #define MU_PARSER_API extern __declspec(dllimport)
34 #define API_EXPORT(TYPE) extern __declspec(dllimport) TYPE __stdcall
35 #endif
36 #else
37 #define MU_PARSER_API /* empty macro */
38 #endif
39
40 // Basic types
41 typedef void* muParserHandle_t; // parser handle
42 typedef char muChar_t; // character type
43 typedef int muBool_t; // boolean type
44 typedef int muInt_t; // integer type
45 typedef double muFloat_t; // floating point type
46
47 // function types for calculation
48 typedef muFloat_t (*muFun1_t)(muFloat_t);
49 typedef muFloat_t (*muFun2_t)(muFloat_t, muFloat_t);
50 typedef muFloat_t (*muFun3_t)(muFloat_t, muFloat_t, muFloat_t);
51 typedef muFloat_t (*muFun4_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t);
52 typedef muFloat_t (*muFun5_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t);
53 typedef muFloat_t (*muMultFun_t)(const muFloat_t*, muInt_t);
54 typedef muFloat_t (*muStrFun1_t)(const muChar_t*);
55 typedef muFloat_t (*muStrFun2_t)(const muChar_t*, muFloat_t);
56 typedef muFloat_t (*muStrFun3_t)(const muChar_t*, muFloat_t, muFloat_t);
57
58 // Functions for parser management
59 typedef void (*muErrorHandler_t)(muParserHandle_t a_hParser); // [optional] callback to an error handler
60 typedef muFloat_t* (*muFacFun_t)(const muChar_t*, void*); // [optional] callback for creating new variables
61 typedef muInt_t (*muIdentFun_t)(const muChar_t*, muInt_t*, muFloat_t*); // [optional] value identification callbacks
62
63 //-----------------------------------------------------------------------------------------------------
64 //
65 //
66 // muParser C compatible bindings
67 //
68 //
69 //-----------------------------------------------------------------------------------------------------
70
71 // Basic operations / initialization
72 API_EXPORT(muParserHandle_t) mupCreate(void);
73 API_EXPORT(void) mupRelease(muParserHandle_t a_hParser);
74 API_EXPORT(const muChar_t*) mupGetExpr(muParserHandle_t a_hParser);
75 API_EXPORT(void) mupSetExpr(muParserHandle_t a_hParser, const muChar_t *a_szExpr);
76 API_EXPORT(void) mupSetVarFactory(muParserHandle_t a_hParser, muFacFun_t a_pFactory, void* pUserData);
77
78 API_EXPORT(muFloat_t) mupEval(muParserHandle_t a_hParser);
79
80 // Defining callbacks / variables / constants
81 API_EXPORT(void) mupDefineFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun1_t a_pFun, muBool_t a_bOptimize);
82 API_EXPORT(void) mupDefineFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun2_t a_pFun, muBool_t a_bOptimize);
83 API_EXPORT(void) mupDefineFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun3_t a_pFun, muBool_t a_bOptimize);
84 API_EXPORT(void) mupDefineFun4(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun4_t a_pFun, muBool_t a_bOptimize);
85 API_EXPORT(void) mupDefineFun5(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun5_t a_pFun, muBool_t a_bOptimize);
86 // string functions
87 API_EXPORT(void) mupDefineStrFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun1_t a_pFun);
88 API_EXPORT(void) mupDefineStrFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun2_t a_pFun);
89 API_EXPORT(void) mupDefineStrFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun3_t a_pFun);
90
91 API_EXPORT(void) mupDefineMultFun( muParserHandle_t a_hParser,
92 const muChar_t* a_szName,
93 muMultFun_t a_pFun,
94 muBool_t a_bOptimize);
95
96 API_EXPORT(void) mupDefineOprt( muParserHandle_t a_hParser,
97 const muChar_t* a_szName,
98 muFun2_t a_pFun,
99 muInt_t a_iPri1,
100 muBool_t a_bOptimize);
101
102 API_EXPORT(void) mupDefineConst( muParserHandle_t a_hParser,
103 const muChar_t* a_szName,
104 muFloat_t a_fVal );
105
106 API_EXPORT(void) mupDefineStrConst( muParserHandle_t a_hParser,
107 const muChar_t* a_szName,
108 const muChar_t *a_sVal );
109
110 API_EXPORT(void) mupDefineVar( muParserHandle_t a_hParser,
111 const muChar_t* a_szName,
112 muFloat_t *a_fVar);
113
114 API_EXPORT(void) mupDefinePostfixOprt( muParserHandle_t a_hParser,
115 const muChar_t* a_szName,
116 muFun1_t a_pOprt,
117 muBool_t a_bOptimize);
118
119
120 API_EXPORT(void) mupDefineInfixOprt( muParserHandle_t a_hParser,
121 const muChar_t* a_szName,
122 muFun1_t a_pOprt,
123 muBool_t a_bOptimize);
124
125 // Define character sets for identifiers
126 API_EXPORT(void) mupDefineNameChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
127 API_EXPORT(void) mupDefineOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
128 API_EXPORT(void) mupDefineInfixOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
129
130 // Remove all / single variables
131 API_EXPORT(void) mupRemoveVar(muParserHandle_t a_hParser, const muChar_t* a_szName);
132 API_EXPORT(void) mupClearVar(muParserHandle_t a_hParser);
133 API_EXPORT(void) mupClearConst(muParserHandle_t a_hParser);
134 API_EXPORT(void) mupClearOprt(muParserHandle_t a_hParser);
135 API_EXPORT(void) mupClearFun(muParserHandle_t a_hParser);
136
137 // Querying variables / expression variables / constants
138 API_EXPORT(int) mupGetExprVarNum(muParserHandle_t a_hParser);
139 API_EXPORT(int) mupGetVarNum(muParserHandle_t a_hParser);
140 API_EXPORT(int) mupGetConstNum(muParserHandle_t a_hParser);
141 API_EXPORT(void) mupGetExprVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar);
142 API_EXPORT(void) mupGetVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar);
143 API_EXPORT(void) mupGetConst(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t* a_pVar);
144
145 // Add value recognition callbacks
146 API_EXPORT(void) mupAddValIdent(muParserHandle_t a_hParser, muIdentFun_t);
147
148 // Error handling
149 API_EXPORT(muBool_t) mupError(muParserHandle_t a_hParser);
150 API_EXPORT(void) mupErrorReset(muParserHandle_t a_hParser);
151 API_EXPORT(void) mupSetErrorHandler(muParserHandle_t a_hParser, muErrorHandler_t a_pErrHandler);
152 API_EXPORT(const muChar_t*) mupGetErrorMsg(muParserHandle_t a_hParser);
153 API_EXPORT(muInt_t) mupGetErrorCode(muParserHandle_t a_hParser);
154 API_EXPORT(muInt_t) mupGetErrorPos(muParserHandle_t a_hParser);
155 API_EXPORT(const muChar_t*) mupGetErrorToken(muParserHandle_t a_hParser);
156 API_EXPORT(const muChar_t*) mupGetErrorExpr(muParserHandle_t a_hParser);
157
158 // This is used for .NET only. It creates a new variable allowing the dll to
159 // manage the variable rather than the .NET garbage collector.
160 API_EXPORT(muFloat_t*) mupCreateVar(void);
161 API_EXPORT(void) mupReleaseVar(muFloat_t*);
162
163 #endif // include guard