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 {
00053     typedef int64_t ( *OneArgFunc ) ( int64_t arg );
00054     typedef char* ( *MultiArgFunc ) ( int paramcnt, int64_t* args,
00055                                       CStrMap* strparams, int64_t* result );
00056     typedef int ( *PrmSrchFunc ) ( const char* str, size_t len, int64_t* value,
00057                                    void* param );
00058     typedef enum
00059     {
00060         // Binary
00061         OP_SHL, OP_SHR, OP_POW,
00062         OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
00063         OP_LOGIC_AND, OP_LOGIC_OR, // Logical
00064         OP_COMSTART, OP_ASSIGN, // For internal needs
00065         OP_OBR, // Special
00066         OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK, // Arithmetic
00067         OP_XOR, OP_NOT, OP_AND, OP_OR, // Bitwise
00068         OP_EQU, OP_GREATER, OP_LESS,
00069         OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA, // Logical
00070         OP_FORMULAEND, // For script
00071         OP_INDEX_TO_VAR, OP_FUNC_ONEARG, OP_FUNC_MULTIARG // Special
00072     } OperType_t;
00073     static const signed char OpPriorities[OP_FUNC_MULTIARG + 1];
00074     typedef struct Operation
00075     {
00076         OperType_t  OperType;
00077         const void* Func;
00078         signed char PrevValTop;
00079         CStrMap*    StrParams;
00080         explicit Operation() : Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
00081         explicit Operation( OperType_t op ) : OperType( op ), Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
00082         explicit Operation( OperType_t op, const void* p, signed char a, CStrMap* pM ) : OperType( op ), Func( p ), PrevValTop( a ), StrParams( pM ) {}
00083     } Operation;
00084     static const Operation BrOp;
00085     static const Operation CbrOp;
00086     static const Operation NegOp;
00087     static const Operation ItvOp;
00088     static const Operation CommaOp;
00089     std::vector<Operation> OpStack;
00090     std::vector<Operation> OpStackEval;
00091     std::vector<int64_t> ValStack;
00092     std::vector<int64_t> ValStackEval;
00093     int    OpTop, ValTop;
00094     int    ObrDist;
00095     CInt64Lexer Lexer;
00096     CStrMap* VarParams;
00097     static CStaticFuncMapInt64 IntFunctions;
00098     static CSymTable MathSymTable;
00099     std::vector<char> errbuf;
00100     const char* ParseFormula( bool ConvertUpperCase );
00101     const char* PrepareFormula();
00102     const char* Calc();
00103     const char* CalcToObr();
00104 public:
00105     CStrMap* Parameters;
00106     CStrMap* ExtFunctions;
00107     PrmSrchFunc MoreParams;
00108     void*  ParamFuncParam;
00109     CInt64MathParser( void );
00110     ~CInt64MathParser();
00111     const char* Parse( const char* Formula, bool ConvertUpperCase );
00112     const char* Eval( int64_t* result );
00113 };
00114 
00115 #ifdef _MSC_VER // *JS*
00116 #   pragma warning(pop)
00117 #endif
00118 
00119 #endif // _INT64MATHPARSER_H_


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 18:42:47