All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  {
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_
GENAPI_NAMESPACE::CInt64MathParser::Lexer
CInt64Lexer Lexer
Definition: Int64MathParser.h:98
GENAPI_NAMESPACE
Lexical analyzer for CIntSwissKnife.
Definition: Destructible.h:30
MATHPARSERDLL_API
#define MATHPARSERDLL_API
Definition: MathParserDll.h:46
GENAPI_NAMESPACE::CInt64MathParser::MoreParams
PrmSrchFunc MoreParams
Definition: Int64MathParser.h:110
GENAPI_NAMESPACE::CInt64MathParser::NegOp
static const Operation NegOp
Definition: Int64MathParser.h:89
GENAPI_NAMESPACE::CInt64MathParser::ExtFunctions
CStrMap * ExtFunctions
Definition: Int64MathParser.h:109
GENAPI_NAMESPACE::CInt64MathParser::OP_INDEX_TO_VAR
@ OP_INDEX_TO_VAR
Definition: Int64MathParser.h:74
GENAPI_NAMESPACE::CInt64MathParser::IntFunctions
static CStaticFuncMapInt64 IntFunctions
Definition: Int64MathParser.h:100
Types.h
Common types used in the public GenApi interface.
GENAPI_NAMESPACE::CInt64MathParser::ItvOp
static const Operation ItvOp
Definition: Int64MathParser.h:90
GENAPI_NAMESPACE::CInt64MathParser::ParamFuncParam
void * ParamFuncParam
Definition: Int64MathParser.h:111
GENAPI_NAMESPACE::CStaticFuncMapInt64
Definition: StrMap.h:66
GENAPI_NAMESPACE::CInt64MathParser::OP_FORMULAEND
@ OP_FORMULAEND
Definition: Int64MathParser.h:73
GENAPI_NAMESPACE::CInt64MathParser
Parser and evaluator for CIntSwissKnife.
Definition: Int64MathParser.h:54
GENAPI_NAMESPACE::CInt64MathParser::ObrDist
int ObrDist
Definition: Int64MathParser.h:97
GENAPI_NAMESPACE::CInt64MathParser::ValTop
int ValTop
Definition: Int64MathParser.h:96
GENAPI_NAMESPACE::CInt64MathParser::Operation
Definition: Int64MathParser.h:77
GENAPI_NAMESPACE::CInt64MathParser::OP_LESS
@ OP_LESS
Definition: Int64MathParser.h:71
GENAPI_NAMESPACE::CInt64MathParser::Operation::PrevValTop
signed char PrevValTop
Definition: Int64MathParser.h:81
GENAPI_NAMESPACE::CInt64MathParser::OP_LOGIC_OR
@ OP_LOGIC_OR
Definition: Int64MathParser.h:66
GENAPI_NAMESPACE::CInt64MathParser::OP_LOGIC_NEQ
@ OP_LOGIC_NEQ
Definition: Int64MathParser.h:65
GENAPI_NAMESPACE::CInt64MathParser::Operation::OperType
OperType_t OperType
Definition: Int64MathParser.h:79
GENAPI_NAMESPACE::CInt64MathParser::CbrOp
static const Operation CbrOp
Definition: Int64MathParser.h:88
GENAPI_NAMESPACE::CInt64MathParser::OP_XOR
@ OP_XOR
Definition: Int64MathParser.h:70
GENAPI_NAMESPACE::CInt64MathParser::BrOp
static const Operation BrOp
Definition: Int64MathParser.h:87
StrMap.h
Definition of CStrMap.
GENAPI_NAMESPACE::CInt64MathParser::MathSymTable
static CSymTable MathSymTable
Definition: Int64MathParser.h:101
GENAPI_NAMESPACE::CInt64MathParser::ValStackEval
std::vector< int64_t > ValStackEval
Definition: Int64MathParser.h:95
GENAPI_NAMESPACE::CInt64MathParser::OP_UNK
@ OP_UNK
Definition: Int64MathParser.h:69
GENAPI_NAMESPACE::CInt64MathParser::errbuf
std::vector< char > errbuf
Definition: Int64MathParser.h:102
GENAPI_NAMESPACE::CStrMap
Definition: StrMap.h:31
Int64Lexer.h
Definition of CInt64Lexer.
GENAPI_NAMESPACE::CInt64MathParser::VarParams
CStrMap * VarParams
Definition: Int64MathParser.h:99
MathParserDll.h
Export Macros.
GENAPI_NAMESPACE::CInt64MathParser::OpStack
std::vector< Operation > OpStack
Definition: Int64MathParser.h:92
GENAPI_NAMESPACE::CInt64MathParser::Operation::Operation
Operation(OperType_t op, const void *p, signed char a, CStrMap *pM)
Definition: Int64MathParser.h:85
GENAPI_NAMESPACE::CInt64MathParser::Operation::Func
const void * Func
Definition: Int64MathParser.h:80
GENAPI_NAMESPACE::CInt64MathParser::Operation::Operation
Operation()
Definition: Int64MathParser.h:83
GENAPI_NAMESPACE::CInt64MathParser::Operation::Operation
Operation(OperType_t op)
Definition: Int64MathParser.h:84
GENAPI_NAMESPACE::CInt64MathParser::ValStack
std::vector< int64_t > ValStack
Definition: Int64MathParser.h:94
GENAPI_NAMESPACE::CSymTable
Definition: SymTable.h:26
GENAPI_NAMESPACE::CInt64MathParser::CommaOp
static const Operation CommaOp
Definition: Int64MathParser.h:91
GENAPI_NAMESPACE::CInt64MathParser::OpStackEval
std::vector< Operation > OpStackEval
Definition: Int64MathParser.h:93
GENAPI_NAMESPACE::DblErR
const double DblErR
Definition: MathParser.h:39
int64_t
__int64 int64_t
Definition: config-win32.h:21
GENAPI_NAMESPACE::PrmSrchFunc
int(* PrmSrchFunc)(const char *str, size_t len, double *value, void *param)
Definition: MathParser.h:46
GENAPI_NAMESPACE::CInt64MathParser::OP_SHR
@ OP_SHR
Definition: Int64MathParser.h:64
GENAPI_NAMESPACE::CInt64MathParser::OP_LOGIC_SEP
@ OP_LOGIC_SEP
Definition: Int64MathParser.h:72
GENAPI_NAMESPACE::CInt64MathParser::OP_OBR
@ OP_OBR
Definition: Int64MathParser.h:68
GENAPI_NAMESPACE::CInt64MathParser::Operation::StrParams
CStrMap * StrParams
Definition: Int64MathParser.h:82
GENAPI_NAMESPACE::CInt64Lexer
Definition: Int64Lexer.h:35
GENAPI_NAMESPACE::CInt64MathParser::Parameters
CStrMap * Parameters
Definition: Int64MathParser.h:108
GENAPI_NAMESPACE::CInt64MathParser::OperType_t
OperType_t
Definition: Int64MathParser.h:61
GenApiDll.h
declspec's to be used for GenApi Windows dll
GENAPI_NAMESPACE::CInt64MathParser::OP_COMSTART
@ OP_COMSTART
Definition: Int64MathParser.h:67
GENAPI_NAMESPACE::OneArgFunc
double(* OneArgFunc)(double arg)
Definition: MathParser.h:43


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11