MathParser.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 //-----------------------------------------------------------------------------
19 #ifndef _MATHPARSER_H_
20 #define _MATHPARSER_H_
21 
22 #include "MathParserDll.h"
23 #include "GenApi/Types.h"
24 #include "GenApi/GenApiDll.h"
25 #include "StrMap.h"
26 #include "Lexer.h"
27 
28 #include <vector>
29 
30 #ifdef _MSC_VER // *JS*
31 # pragma warning(push)
32 # pragma warning(disable: 4251) // class 'xxx' needs to have dll-interface to be used by clients of class 'yyy'
33 #endif
34 
35 #define ORIGINAL_STACK_SIZE 64
36 
37 extern const double DblErR;
38 extern const double DblNiN;
39 
40 
41 typedef double ( *OneArgFunc ) ( double arg );
42 typedef char* ( *MultiArgFunc ) ( int paramcnt, double* args,
43  CStrMap* strparams, double* result );
44 typedef int ( *PrmSrchFunc ) ( const char* str, size_t len, double* value,
45  void* param );
52 {
53  typedef enum
54  {
55  // Binary
56  OP_SHL, OP_SHR, OP_POW,
57  OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
58  OP_LOGIC_AND, OP_LOGIC_OR, // Logical
59  OP_COMSTART, OP_ASSIGN, // For internal needs
60  OP_OBR, // Special
61  OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK, // Arithmetic
62  OP_XOR, OP_NOT, OP_AND, OP_OR, // Bitwise
63  OP_EQU, OP_GREATER, OP_LESS,
64  OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA, // Logical
65  OP_FORMULAEND, // For script
66  OP_INDEX_TO_VAR, OP_FUNC_ONEARG, OP_FUNC_MULTIARG // Special
67  } OperType_t;
68  static const signed char OpPriorities[OP_FUNC_MULTIARG + 1];
69  typedef struct Operation
70  {
71  OperType_t OperType;
72  const void* Func;
73  signed char PrevValTop;
75  explicit Operation() : Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
76  explicit Operation( OperType_t op ) : OperType( op ), Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
77  explicit Operation( OperType_t op, const void* p, signed char a, CStrMap* pM ) : OperType( op ), Func( p ), PrevValTop( a ), StrParams( pM ) {}
78  } Operation;
79  static const Operation BrOp;
80  static const Operation CbrOp;
81  static const Operation NegOp;
82  static const Operation ItvOp;
83  static const Operation CommaOp;
84  std::vector<Operation> OpStack;
85  std::vector<Operation> OpStackEval;
86  std::vector<double> ValStack;
87  std::vector<double> ValStackEval;
88  int OpTop, ValTop;
89  int ObrDist;
92  std::vector<char> errbuf;
95  const char* ParseFormula( bool ConvertUpperCase );
96  const char* PrepareFormula();
97  const char* Calc();
98  const char* CalcToObr();
99 public:
104  CMathParser( void );
105  const char* Parse( const char* Formula, bool ConvertUpperCase );
106  const char* Eval( double* result );
107  ~CMathParser();
108 };
109 
110 #ifdef _MSC_VER // *JS*
111 # pragma warning(pop)
112 #endif
113 
114 #endif //_MATHPARSER_H_
Map for variables in swissknife expression.
Definition: StrMap.h:27
Common types used in the public GenApi interface.
PrmSrchFunc MoreParams
Definition: MathParser.h:102
#define MATHPARSERDLL_API
Definition: MathParserDll.h:46
void * ParamFuncParam
Definition: MathParser.h:103
Operation(OperType_t op, const void *p, signed char a, CStrMap *pM)
Definition: MathParser.h:77
static const Operation ItvOp
Definition: MathParser.h:82
const double DblNiN
static CSymTable MathSymTable
Definition: MathParser.h:94
Export Macros.
static CStaticFuncMapDouble DoubleFunctions
Definition: MathParser.h:93
std::vector< char > errbuf
Definition: MathParser.h:92
CStrMap * ExtFunctions
Definition: MathParser.h:101
static const Operation BrOp
Definition: MathParser.h:79
std::vector< Operation > OpStack
Definition: MathParser.h:84
int(* PrmSrchFunc)(const char *str, size_t len, double *value, void *param)
Definition: MathParser.h:44
std::vector< double > ValStack
Definition: MathParser.h:86
Definition of CLexer.
std::vector< Operation > OpStackEval
Definition: MathParser.h:85
Operation(OperType_t op)
Definition: MathParser.h:76
const double DblErR
CStrMap * Parameters
Definition: MathParser.h:100
static const Operation CommaOp
Definition: MathParser.h:83
signed char PrevValTop
Definition: MathParser.h:73
static const Operation CbrOp
Definition: MathParser.h:80
declspec&#39;s to be used for GenApi Windows dll
Definition of CStrMap.
CLexer Lexer
Definition: MathParser.h:90
static const Operation NegOp
Definition: MathParser.h:81
Definition: Lexer.h:46
double(* OneArgFunc)(double arg)
Definition: MathParser.h:41
const void * Func
Definition: MathParser.h:72
Expression parser and evaluator of CSwissKnife.
Definition: MathParser.h:51
CStrMap * VarParams
Definition: MathParser.h:91
std::vector< double > ValStackEval
Definition: MathParser.h:87


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 19:10:54