MathParser.h
Go to the documentation of this file.
00001 //-----------------------------------------------------------------------------
00002 //  (c) 2006 by Basler Vision Technologies
00003 //  Section: Vision Components
00004 //  Project: GenApi
00005 //  Author:  Margret Albrecht
00006 //  $Header$
00007 //
00008 // License: Derived from Kirill Zaborski's MathParser library (http://kirya.narod.ru/mathparser.html ).
00009 // This library comes under LGPL license (see http://www.gnu.org/licenses/lgpl.html).
00010 // Kirill's implementation is a C++ port of the CCalc library from Walery Studennikov (http://www.sama.ru/~despair/ccalc/)
00011 // which also comes under the LGPL.
00012 //-----------------------------------------------------------------------------
00019 #ifndef _MATHPARSER_H_
00020 #define _MATHPARSER_H_
00021 
00022 #include "MathParserDll.h"
00023 #include "GenApi/Types.h"
00024 #include "GenApi/GenApiDll.h"
00025 #include "StrMap.h"
00026 #include "Lexer.h"
00027 
00028 #include <vector>
00029 
00030 #ifdef _MSC_VER // *JS*
00031 #pragma warning(push)
00032 #pragma warning(disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of class 'yyy'
00033 #endif
00034 
00035 #define ORIGINAL_STACK_SIZE 64
00036 
00037 extern const double DblErR;
00038 extern const double DblNiN;
00039 
00040 
00041 typedef double (*OneArgFunc) ( double arg );
00042 typedef char* (*MultiArgFunc) ( int paramcnt, double *args,
00043                  CStrMap *strparams, double *result );
00044 typedef int (*PrmSrchFunc) ( const char *str, size_t len, double *value,
00045                  void *param );
00051 class MATHPARSERDLL_API CMathParser{
00052     typedef enum {
00053         // Binary
00054         OP_SHL, OP_SHR, OP_POW,
00055         OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
00056         OP_LOGIC_AND, OP_LOGIC_OR, // Logical
00057         OP_COMSTART, OP_ASSIGN, // For internal needs
00058         OP_OBR, // Special
00059         OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK, // Arithmetic
00060         OP_XOR, OP_NOT, OP_AND, OP_OR, // Bitwise
00061         OP_EQU, OP_GREATER, OP_LESS,
00062         OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA, // Logical
00063         OP_FORMULAEND, // For script
00064         OP_FUNC_ONEARG, OP_FUNC_MULTIARG // Special
00065     } OperType_t;
00066     static const char OpPriorities[OP_FUNC_MULTIARG+1];
00067     typedef struct {
00068         OperType_t    OperType;
00069         const void    *Func;
00070         signed char    PrevValTop;
00071         CStrMap   *StrParams;
00072     } Operation;
00073     static const Operation BrOp;
00074     static const Operation NegOp;
00075     std::vector<Operation> OpStack;
00076     std::vector<double> ValStack;
00077     int    OpTop, ValTop;
00078     int    ObrDist;
00079     CLexer Lexer;
00080     CStrMap *VarParams;
00081     std::vector<char> errbuf;
00082     static CStaticFuncMapDouble DoubleFunctions;
00083     static CSymTable MathSymTable;
00084     const char * ParseFormula(double *result, bool ConvertUpperCase);
00085     const char * PrepareFormula();
00086     const char * Calc();
00087     const char * CalcToObr();
00088 public:
00089     CStrMap *Parameters;
00090     CStrMap *ExtFunctions;
00091     PrmSrchFunc MoreParams;
00092     void  *ParamFuncParam;
00093     CMathParser(void);
00094     const char * Parse( const char *Formula, double *result, bool ConvertUpperCase);
00095     ~CMathParser(void);
00096 };
00097 
00098 #ifdef _MSC_VER // *JS*
00099 #pragma warning(pop)
00100 #endif
00101 
00102 #endif //_MATHPARSER_H_


rc_visard_driver
Author(s): Heiko Hirschmueller , Christian Emmerich , Felix Ruess
autogenerated on Thu Jun 6 2019 20:43:05