Int64MathParser.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 //-----------------------------------------------------------------------------
00022 #ifndef _INT64MATHPARSER_H_
00023 #define _INT64MATHPARSER_H_
00024 
00025 #include "GenApi/Types.h"
00026 #include "GenApi/GenApiDll.h"
00027 
00028 #include "MathParserDll.h"
00029 #include "StrMap.h"
00030 #include "Int64Lexer.h"
00031 
00032 #include <vector>
00033 
00034 #ifdef _MSC_VER // *JS*
00035 #pragma warning(push)
00036 #pragma warning(disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of class 'yyy'
00037 #endif
00038 
00039 #define ORIGINAL_STACK_SIZE 64
00040 
00041 extern const double DblErR;
00042 
00043 
00051 class MATHPARSERDLL_API CInt64MathParser{
00052   typedef int64_t (*OneArgFunc) ( int64_t arg );
00053   typedef char* (*MultiArgFunc) ( int paramcnt, int64_t *args,
00054     CStrMap *strparams, int64_t *result );
00055   typedef int (*PrmSrchFunc) ( const char *str, size_t len, int64_t *value,
00056     void *param );
00057   typedef enum {
00058     // Binary
00059     OP_SHL, OP_SHR, OP_POW,
00060     OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
00061     OP_LOGIC_AND, OP_LOGIC_OR, // Logical
00062     OP_COMSTART, OP_ASSIGN, // For internal needs
00063     OP_OBR, // Special
00064     OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK, // Arithmetic
00065     OP_XOR, OP_NOT, OP_AND, OP_OR, // Bitwise
00066     OP_EQU, OP_GREATER, OP_LESS,
00067     OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA, // Logical
00068     OP_FORMULAEND, // For script
00069     OP_FUNC_ONEARG, OP_FUNC_MULTIARG // Special
00070   } OperType_t;
00071   static const char OpPriorities[OP_FUNC_MULTIARG+1];
00072   typedef struct {
00073     OperType_t  OperType;
00074         const void  *Func;
00075         signed char PrevValTop;
00076         CStrMap *StrParams;
00077     } Operation;
00078     static const Operation BrOp;
00079     static const Operation NegOp;
00080     std::vector<Operation> OpStack;
00081     std::vector<int64_t> ValStack;
00082     int    OpTop, ValTop;
00083     int    ObrDist;
00084     CInt64Lexer Lexer;
00085     CStrMap *VarParams;
00086     static CStaticFuncMapInt64 IntFunctions;
00087     static CSymTable MathSymTable;
00088     std::vector<char> errbuf;
00089     const char * ParseFormula(int64_t *result, bool ConvertUpperCase);
00090     const char * PrepareFormula();
00091     const char * Calc();
00092     const char * CalcToObr();
00093 public:
00094     CStrMap *Parameters;
00095     CStrMap *ExtFunctions;
00096     PrmSrchFunc MoreParams;
00097     void  *ParamFuncParam;
00098     CInt64MathParser(void );
00099     const char * Parse( const char *Formula, int64_t *result, bool ConvertUpperCase);
00100     ~CInt64MathParser();
00101 };
00102 
00103 #ifdef _MSC_VER // *JS*
00104 #pragma warning(pop)
00105 #endif
00106 
00107 
00108 #endif // _INT64MATHPARSER_H_


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