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 namespace GENAPI_NAMESPACE
38 {
39  extern const double DblErR;
40  extern const double DblNiN;
41 
42 
43  typedef double ( *OneArgFunc ) ( double arg );
44  typedef char* ( *MultiArgFunc ) ( int paramcnt, double* args,
45  CStrMap* strparams, double* result );
46  typedef int ( *PrmSrchFunc ) ( const char* str, size_t len, double* value,
47  void* param );
54  {
55  typedef enum
56  {
57  // Binary
58  OP_SHL, OP_SHR, OP_POW,
59  OP_LOGIC_NEQ, OP_LOGIC_GEQ, OP_LOGIC_LEQ,
60  OP_LOGIC_AND, OP_LOGIC_OR, // Logical
61  OP_COMSTART, OP_ASSIGN, // For internal needs
62  OP_OBR, // Special
63  OP_ADD, OP_SUB, OP_MUL, OP_DIV, OP_MOD, OP_UNK, // Arithmetic
64  OP_XOR, OP_NOT, OP_AND, OP_OR, // Bitwise
65  OP_EQU, OP_GREATER, OP_LESS,
66  OP_LOGIC, OP_LOGIC_SEP, OP_CBR, OP_COMMA, // Logical
67  OP_FORMULAEND, // For script
68  OP_INDEX_TO_VAR, OP_FUNC_ONEARG, OP_FUNC_MULTIARG // Special
69  } OperType_t;
70  static const signed char OpPriorities[OP_FUNC_MULTIARG + 1];
71  typedef struct Operation
72  {
73  OperType_t OperType;
74  const void* Func;
75  signed char PrevValTop;
77  explicit Operation() : Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
78  explicit Operation( OperType_t op ) : OperType( op ), Func( 0 ), PrevValTop( 0 ), StrParams( 0 ) {}
79  explicit Operation( OperType_t op, const void* p, signed char a, CStrMap* pM ) : OperType( op ), Func( p ), PrevValTop( a ), StrParams( pM ) {}
80  } Operation;
81  static const Operation BrOp;
82  static const Operation CbrOp;
83  static const Operation NegOp;
84  static const Operation ItvOp;
85  static const Operation CommaOp;
86  std::vector<Operation> OpStack;
87  std::vector<Operation> OpStackEval;
88  std::vector<double> ValStack;
89  std::vector<double> ValStackEval;
90  int OpTop, ValTop;
91  int ObrDist;
94  std::vector<char> errbuf;
97  const char* ParseFormula( bool ConvertUpperCase );
98  const char* PrepareFormula();
99  const char* Calc();
100  const char* CalcToObr();
101  public:
106  CMathParser( void );
107  const char* Parse( const char* Formula, bool ConvertUpperCase );
108  const char* Eval( double* result );
109  ~CMathParser();
110  };
111 
112 } /* GENAPI_NAMESPACE*/
113 
114 #ifdef _MSC_VER // *JS*
115 # pragma warning(pop)
116 #endif
117 
118 #endif //_MATHPARSER_H_
std::vector< double > ValStack
Definition: MathParser.h:88
const double DblNiN
Common types used in the public GenApi interface.
#define MATHPARSERDLL_API
Definition: MathParserDll.h:46
static const Operation BrOp
Definition: MathParser.h:81
Export Macros.
static const Operation CommaOp
Definition: MathParser.h:85
std::vector< char > errbuf
Definition: MathParser.h:94
int(* PrmSrchFunc)(const char *str, size_t len, double *value, void *param)
Definition: MathParser.h:46
static const Operation CbrOp
Definition: MathParser.h:82
Expression parser and evaluator of CSwissKnife.
Definition: MathParser.h:53
static const Operation ItvOp
Definition: MathParser.h:84
Definition of CLexer.
static const Operation NegOp
Definition: MathParser.h:83
double(* OneArgFunc)(double arg)
Definition: MathParser.h:43
std::vector< double > ValStackEval
Definition: MathParser.h:89
std::vector< Operation > OpStack
Definition: MathParser.h:86
static CStaticFuncMapDouble DoubleFunctions
Definition: MathParser.h:95
declspec&#39;s to be used for GenApi Windows dll
Definition of CStrMap.
static CSymTable MathSymTable
Definition: MathParser.h:96
std::vector< Operation > OpStackEval
Definition: MathParser.h:87
Operation(OperType_t op, const void *p, signed char a, CStrMap *pM)
Definition: MathParser.h:79
Lexical analyzer for CIntSwissKnife.
Definition: Autovector.h:48
const double DblErR
Definition: MathParser.h:39


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