Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
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
00059 OP_SHL, OP_SHR, OP_POW,
00060 OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
00061 OP_LOGIC_AND, OP_LOGIC_OR,
00062 OP_COMSTART, OP_ASSIGN,
00063 OP_OBR,
00064 OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK,
00065 OP_XOR, OP_NOT, OP_AND, OP_OR,
00066 OP_EQU, OP_GREATER, OP_LESS,
00067 OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA,
00068 OP_FORMULAEND,
00069 OP_FUNC_ONEARG, OP_FUNC_MULTIARG
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_