Int64MathParser.h
Go to the documentation of this file.
1 //-----------------------------------------------------------------------------
2 // (c) 2006 by Basler Vision Technologies
3 // Section: Vision Components
4 // Project: GenApi
5 // Author: Margret Albrecht
6 // $Header$
7 //
8 // License: Derived from Kirill Zaborski's MathParser library (http://kirya.narod.ru/mathparser.html ).
9 // This library comes under LGPL license (see http://www.gnu.org/licenses/lgpl.html).
10 // Kirill's implementation is a C++ port of the CCalc library from Walery Studennikov (http://www.sama.ru/~despair/ccalc/)
11 // which also comes under the LGPL.
12 //-----------------------------------------------------------------------------
22 #ifndef _INT64MATHPARSER_H_
23 #define _INT64MATHPARSER_H_
24 
25 #include "GenApi/Types.h"
26 #include "GenApi/GenApiDll.h"
27 
28 #include "MathParserDll.h"
29 #include "StrMap.h"
30 #include "Int64Lexer.h"
31 
32 #include <vector>
33 
34 #ifdef _MSC_VER // *JS*
35 # pragma warning(push)
36 # pragma warning(disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of class 'yyy'
37 #endif
38 
39 #define ORIGINAL_STACK_SIZE 64
40 
41 
42 namespace GENAPI_NAMESPACE
43 {
44  extern const double DblErR;
45 
46 
55  {
56  typedef int64_t ( *OneArgFunc ) ( int64_t arg );
57  typedef char* ( *MultiArgFunc ) ( int paramcnt, int64_t* args,
58  CStrMap* strparams, int64_t* result );
59  typedef int ( *PrmSrchFunc ) ( const char* str, size_t len, int64_t* value,
60  void* param );
61  typedef enum
62  {
63  // Binary
64  OP_SHL, OP_SHR, OP_POW,
65  OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
66  OP_LOGIC_AND, OP_LOGIC_OR, // Logical
67  OP_COMSTART, OP_ASSIGN, // For internal needs
68  OP_OBR, // Special
69  OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK, // Arithmetic
70  OP_XOR, OP_NOT, OP_AND, OP_OR, // Bitwise
71  OP_EQU, OP_GREATER, OP_LESS,
72  OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA, // Logical
73  OP_FORMULAEND, // For script
74  OP_INDEX_TO_VAR, OP_FUNC_ONEARG, OP_FUNC_MULTIARG // Special
75  } OperType_t;
76  static const signed char OpPriorities[OP_FUNC_MULTIARG + 1];
77  typedef struct Operation
78  {
79  OperType_t OperType;
80  const void* Func;
81  signed char PrevValTop;
83  explicit Operation() : Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
84  explicit Operation( OperType_t op ) : OperType( op ), Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
85  explicit Operation( OperType_t op, const void* p, signed char a, CStrMap* pM ) : OperType( op ), Func( p ), PrevValTop( a ), StrParams( pM ) {}
86  } Operation;
87  static const Operation BrOp;
88  static const Operation CbrOp;
89  static const Operation NegOp;
90  static const Operation ItvOp;
91  static const Operation CommaOp;
92  std::vector<Operation> OpStack;
93  std::vector<Operation> OpStackEval;
94  std::vector<int64_t> ValStack;
95  std::vector<int64_t> ValStackEval;
96  int OpTop, ValTop;
97  int ObrDist;
102  std::vector<char> errbuf;
103  const char* ParseFormula( bool ConvertUpperCase );
104  const char* PrepareFormula();
105  const char* Calc();
106  const char* CalcToObr();
107  public:
112  CInt64MathParser( void );
113  ~CInt64MathParser();
114  const char* Parse( const char* Formula, bool ConvertUpperCase );
115  const char* Eval( int64_t* result );
116  };
117 
118 } /* GENAPI_NAMESPACE*/
119 
120 #ifdef _MSC_VER // *JS*
121 # pragma warning(pop)
122 #endif
123 
124 #endif // _INT64MATHPARSER_H_
Common types used in the public GenApi interface.
Parser and evaluator for CIntSwissKnife.
std::vector< Operation > OpStackEval
#define MATHPARSERDLL_API
Definition: MathParserDll.h:46
std::vector< Operation > OpStack
Export Macros.
__int64 int64_t
Definition: config-win32.h:21
int(* PrmSrchFunc)(const char *str, size_t len, double *value, void *param)
Definition: MathParser.h:46
std::vector< int64_t > ValStackEval
Operation(OperType_t op, const void *p, signed char a, CStrMap *pM)
double(* OneArgFunc)(double arg)
Definition: MathParser.h:43
std::vector< int64_t > ValStack
static CStaticFuncMapInt64 IntFunctions
declspec&#39;s to be used for GenApi Windows dll
Definition of CStrMap.
Lexical analyzer for CIntSwissKnife.
Definition: Autovector.h:48
const double DblErR
Definition: MathParser.h:39
Definition of CInt64Lexer.
static const Operation CommaOp


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Mar 17 2021 02:48:40