muParser: muParserDLL.h Source File

- Main Page
- Namespaces
- Classes
- Files
- Examples

# muParserDLL.h

Go to the documentation of this file.

    00001 ﻿/*
    00002                  __________
    00003     _____   __ __\______   \_____  _______  ______  ____ _______
    00004    /     \ |  |  \|     ___/\__  \ \_  __ \/  ___/_/ __ \\_  __ \
    00005   |  Y Y  \|  |  /|    |     / __ \_|  | \/\___ \ \  ___/ |  | \/
    00006   |__|_|  /|____/ |____|    (____  /|__|  /____  > \___  >|__|
    00007         \/                       \/            \/      \/
    00008   Copyright (C) 2004-2008 Ingo Berg
    00009
    00010   Permission is hereby granted, free of charge, to any person obtaining a copy of this
    00011   software and associated documentation files (the "Software"), to deal in the Software
    00012   without restriction, including without limitation the rights to use, copy, modify,
    00013   merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
    00014   permit persons to whom the Software is furnished to do so, subject to the following conditions:
    00015
    00016   The above copyright notice and this permission notice shall be included in all copies or
    00017   substantial portions of the Software.
    00018
    00019   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
    00020   NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
    00021   NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
    00022   DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    00023   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
    00024 */
    00025 #ifndef MU_PARSER_DLL_H
    00026 #define MU_PARSER_DLL_H
    00027
    00028 #if defined(_WIN32)
    00029     #ifdef MUPARSERLIB_EXPORTS
    00030         #define API_EXPORT(TYPE) extern "C" __declspec(dllexport) TYPE __stdcall
    00031     #else
    00032         #define API_EXPORT(TYPE) extern __declspec(dllimport) TYPE __stdcall
    00033     #endif
    00034 #else
    00035     #define MU_PARSER_API       /* empty macro */
    00036 #endif
    00037
    00042 // Basic types
    00043 typedef void*  muParserHandle_t;    // parser handle
    00044 typedef char   muChar_t;            // character type
    00045 typedef int    muBool_t;            // boolean type
    00046 typedef int    muInt_t;             // integer type
    00047 typedef double muFloat_t;           // floating point type
    00048
    00049 // function types for calculation
    00050 typedef muFloat_t (*muFun0_t)();
    00051 typedef muFloat_t (*muFun1_t)(muFloat_t);
    00052 typedef muFloat_t (*muFun2_t)(muFloat_t, muFloat_t);
    00053 typedef muFloat_t (*muFun3_t)(muFloat_t, muFloat_t, muFloat_t);
    00054 typedef muFloat_t (*muFun4_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t);
    00055 typedef muFloat_t (*muFun5_t)(muFloat_t, muFloat_t, muFloat_t, muFloat_t, muFloat_t);
    00056 typedef muFloat_t (*muMultFun_t)(const muFloat_t*, muInt_t);
    00057 typedef muFloat_t (*muStrFun1_t)(const muChar_t*);
    00058 typedef muFloat_t (*muStrFun2_t)(const muChar_t*, muFloat_t);
    00059 typedef muFloat_t (*muStrFun3_t)(const muChar_t*, muFloat_t, muFloat_t);
    00060
    00061 // Functions for parser management
    00062 typedef void (*muErrorHandler_t)(muParserHandle_t a_hParser);           // [optional] callback to an error handler
    00063 typedef muFloat_t* (*muFacFun_t)(const muChar_t*, void*);               // [optional] callback for creating new variables
    00064 typedef muInt_t (*muIdentFun_t)(const muChar_t*, muInt_t*, muFloat_t*); // [optional] value identification callbacks
    00065
    00066 //-----------------------------------------------------------------------------------------------------
    00067 //
    00068 //
    00069 // muParser C compatible bindings
    00070 //
    00071 //
    00072 //-----------------------------------------------------------------------------------------------------
    00073
    00074 // Basic operations / initialization
    00075 API_EXPORT(muParserHandle_t) mupCreate();
    00076 API_EXPORT(void) mupRelease(muParserHandle_t a_hParser);
    00077 API_EXPORT(const muChar_t*) mupGetExpr(muParserHandle_t a_hParser);
    00078 API_EXPORT(void) mupSetExpr(muParserHandle_t a_hParser, const muChar_t *a_szExpr);
    00079 API_EXPORT(void) mupSetVarFactory(muParserHandle_t a_hParser, muFacFun_t a_pFactory, void* pUserData);
    00080
    00081 API_EXPORT(muFloat_t) mupEval(muParserHandle_t a_hParser);
    00082
    00083 // Defining callbacks / variables / constants
    00084 API_EXPORT(void) mupDefineFun0(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun0_t a_pFun, muBool_t a_bOptimize);
    00085 API_EXPORT(void) mupDefineFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun1_t a_pFun, muBool_t a_bOptimize);
    00086 API_EXPORT(void) mupDefineFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun2_t a_pFun, muBool_t a_bOptimize);
    00087 API_EXPORT(void) mupDefineFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun3_t a_pFun, muBool_t a_bOptimize);
    00088 API_EXPORT(void) mupDefineFun4(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun4_t a_pFun, muBool_t a_bOptimize);
    00089 API_EXPORT(void) mupDefineFun5(muParserHandle_t a_hParser, const muChar_t *a_szName, muFun5_t a_pFun, muBool_t a_bOptimize);
    00090 // string functions
    00091 API_EXPORT(void) mupDefineStrFun1(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun1_t a_pFun);
    00092 API_EXPORT(void) mupDefineStrFun2(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun2_t a_pFun);
    00093 API_EXPORT(void) mupDefineStrFun3(muParserHandle_t a_hParser, const muChar_t *a_szName, muStrFun3_t a_pFun);
    00094
    00095 API_EXPORT(void) mupDefineMultFun( muParserHandle_t a_hParser,
    00096                                    const muChar_t* a_szName,
    00097                                    muMultFun_t a_pFun,
    00098                                    muBool_t a_bOptimize);
    00099
    00100 API_EXPORT(void) mupDefineOprt( muParserHandle_t a_hParser,
    00101                                 const muChar_t* a_szName,
    00102                                 muFun2_t a_pFun,
    00103                                 muInt_t a_iPri1,
    00104                                 muBool_t a_bOptimize);
    00105
    00106 API_EXPORT(void) mupDefineConst( muParserHandle_t a_hParser,
    00107                                  const muChar_t* a_szName,
    00108                                  muFloat_t a_fVal );
    00109
    00110 API_EXPORT(void) mupDefineStrConst( muParserHandle_t a_hParser,
    00111                                     const muChar_t* a_szName,
    00112                                     const muChar_t *a_sVal );
    00113
    00114 API_EXPORT(void) mupDefineVar( muParserHandle_t a_hParser,
    00115                                const muChar_t* a_szName,
    00116                                muFloat_t *a_fVar);
    00117
    00118 API_EXPORT(void) mupDefinePostfixOprt( muParserHandle_t a_hParser,
    00119                                        const muChar_t* a_szName,
    00120                                        muFun1_t a_pOprt,
    00121                                        muBool_t a_bOptimize);
    00122
    00123
    00124 API_EXPORT(void) mupDefineInfixOprt( muParserHandle_t a_hParser,
    00125                                      const muChar_t* a_szName,
    00126                                      muFun1_t a_pOprt,
    00127                                      muBool_t a_bOptimize);
    00128
    00129 // Define character sets for identifiers
    00130 API_EXPORT(void) mupDefineNameChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
    00131 API_EXPORT(void) mupDefineOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
    00132 API_EXPORT(void) mupDefineInfixOprtChars(muParserHandle_t a_hParser, const muChar_t* a_szCharset);
    00133
    00134 // Remove all / single variables
    00135 API_EXPORT(void) mupRemoveVar(muParserHandle_t a_hParser, const muChar_t* a_szName);
    00136 API_EXPORT(void) mupClearVar(muParserHandle_t a_hParser);
    00137 API_EXPORT(void) mupClearConst(muParserHandle_t a_hParser);
    00138 API_EXPORT(void) mupClearOprt(muParserHandle_t a_hParser);
    00139 API_EXPORT(void) mupClearFun(muParserHandle_t a_hParser);
    00140
    00141 // Querying variables / expression variables / constants
    00142 API_EXPORT(int) mupGetExprVarNum(muParserHandle_t a_hParser);
    00143 API_EXPORT(int) mupGetVarNum(muParserHandle_t a_hParser);
    00144 API_EXPORT(int) mupGetConstNum(muParserHandle_t a_hParser);
    00145 API_EXPORT(void) mupGetExprVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar);
    00146 API_EXPORT(void) mupGetVar(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t** a_pVar);
    00147 API_EXPORT(void) mupGetConst(muParserHandle_t a_hParser, unsigned a_iVar, const muChar_t** a_pszName, muFloat_t* a_pVar);
    00148 API_EXPORT(void) mupSetArgSep(muParserHandle_t a_hParser, const muChar_t cArgSep);
    00149 API_EXPORT(void) mupSetDecSep(muParserHandle_t a_hParser, const muChar_t cArgSep);
    00150 API_EXPORT(void) mupSetThousandsSep(muParserHandle_t a_hParser, const muChar_t cArgSep);
    00151
    00152 // Add value recognition callbacks
    00153 API_EXPORT(void) mupAddValIdent(muParserHandle_t a_hParser, muIdentFun_t);
    00154
    00155 // Error handling
    00156 API_EXPORT(muBool_t) mupError(muParserHandle_t a_hParser);
    00157 API_EXPORT(void) mupErrorReset(muParserHandle_t a_hParser);
    00158 API_EXPORT(void) mupSetErrorHandler(muParserHandle_t a_hParser, muErrorHandler_t a_pErrHandler);
    00159 API_EXPORT(const muChar_t*) mupGetErrorMsg(muParserHandle_t a_hParser);
    00160 API_EXPORT(muInt_t) mupGetErrorCode(muParserHandle_t a_hParser);
    00161 API_EXPORT(muInt_t) mupGetErrorPos(muParserHandle_t a_hParser);
    00162 API_EXPORT(const muChar_t*) mupGetErrorToken(muParserHandle_t a_hParser);
    00163 API_EXPORT(const muChar_t*) mupGetErrorExpr(muParserHandle_t a_hParser);
    00164
    00165 // This is used for .NET only. It creates a new variable allowing the dll to
    00166 // manage the variable rather than the .NET garbage collector.
    00167 API_EXPORT(muFloat_t*) mupCreateVar();
    00168 API_EXPORT(void) mupReleaseVar(muFloat_t*);
    00169
    00170
    00171 #endif // include guard