OpcUaCanOpen
CANopen OPC-UA server
muParser.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2013 Ingo Berg
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy of this
11  software and associated documentation files (the "Software"), to deal in the Software
12  without restriction, including without limitation the rights to use, copy, modify,
13  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14  permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in all copies or
17  substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 #ifndef MU_PARSER_H
26 #define MU_PARSER_H
27 
28 //--- Standard includes ------------------------------------------------------------------------
29 #include <vector>
30 
31 //--- Parser includes --------------------------------------------------------------------------
32 #include "muParserBase.h"
33 #include "muParserTemplateMagic.h"
34 
39 namespace mu
40 {
51  /* final */ class API_EXPORT_CXX Parser : public ParserBase
52  {
53  public:
54 
55  Parser();
56 
57  virtual void InitCharSets();
58  virtual void InitFun();
59  virtual void InitConst();
60  virtual void InitOprt();
61  virtual void OnDetectVar(string_type *pExpr, int &nStart, int &nEnd);
62 
63  value_type Diff(value_type *a_Var,
64  value_type a_fPos,
65  value_type a_fEpsilon = 0) const;
66 
67  protected:
68 
69  // Trigonometric functions
70  static value_type Sin(value_type);
71  static value_type Cos(value_type);
72  static value_type Tan(value_type);
73  static value_type Tan2(value_type, value_type);
74  // arcus functions
75  static value_type ASin(value_type);
76  static value_type ACos(value_type);
77  static value_type ATan(value_type);
78  static value_type ATan2(value_type, value_type);
79 
80  // hyperbolic functions
81  static value_type Sinh(value_type);
82  static value_type Cosh(value_type);
83  static value_type Tanh(value_type);
84  // arcus hyperbolic functions
85  static value_type ASinh(value_type);
86  static value_type ACosh(value_type);
87  static value_type ATanh(value_type);
88  // Logarithm functions
89  static value_type Log2(value_type); // Logarithm Base 2
90  static value_type Log10(value_type); // Logarithm Base 10
91  static value_type Ln(value_type); // Logarithm Base e (natural logarithm)
92  // misc
93  static value_type Exp(value_type);
94  static value_type Abs(value_type);
95  static value_type Sqrt(value_type);
96  static value_type Rint(value_type);
97  static value_type Sign(value_type);
98 
99  // Prefix operators
100  // !!! Unary Minus is a MUST if you want to use negative signs !!!
101  static value_type UnaryMinus(value_type);
102  static value_type UnaryPlus(value_type);
103 
104  // Functions with variable number of arguments
105  static value_type Sum(const value_type*, int); // sum
106  static value_type Avg(const value_type*, int); // mean value
107  static value_type Min(const value_type*, int); // minimum
108  static value_type Max(const value_type*, int); // maximum
109 
110  static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal);
111  };
112 } // namespace mu
113 
114 #endif
115