00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef MU_PARSER_H
00026 #define MU_PARSER_H
00027
00028
00029 #include <vector>
00030 #include <locale>
00031
00032
00033 #include "muParserBase.h"
00034
00035
00040 namespace mu
00041 {
00052 class Parser : public ParserBase
00053 {
00054 public:
00055
00056 Parser();
00057
00058 virtual void InitCharSets();
00059 virtual void InitFun();
00060 virtual void InitConst();
00061 virtual void InitOprt();
00062
00063 void SetDecSep(char_type cDecSep);
00064 void SetThousandsSep(char_type cThousandsSep);
00065
00066 value_type Diff(value_type *a_Var,
00067 value_type a_fPos,
00068 value_type a_fEpsilon = 0.00074) const;
00069
00070 private:
00071
00073 template<class TChar>
00074 class change_dec_sep : public std::numpunct<TChar>
00075 {
00076 public:
00077
00078 explicit change_dec_sep(char_type cDecSep, char_type cThousandsSep = 0, int nGroup = 3)
00079 :std::numpunct<TChar>()
00080 ,m_cDecPoint(cDecSep)
00081 ,m_cThousandsSep(cThousandsSep)
00082 ,m_nGroup(nGroup)
00083 {}
00084
00085 protected:
00086
00087 virtual char_type do_decimal_point() const
00088 {
00089 return m_cDecPoint;
00090 }
00091
00092 virtual char_type do_thousands_sep() const
00093 {
00094 return m_cThousandsSep;
00095 }
00096
00097 virtual std::string do_grouping() const
00098 {
00099 return std::string(1, m_nGroup);
00100 }
00101
00102 private:
00103
00104 int m_nGroup;
00105 char_type m_cDecPoint;
00106 char_type m_cThousandsSep;
00107 };
00108
00109
00110 static value_type Sin(value_type);
00111 static value_type Cos(value_type);
00112 static value_type Tan(value_type);
00113
00114 static value_type ASin(value_type);
00115 static value_type ACos(value_type);
00116 static value_type ATan(value_type);
00117
00118 static value_type Sinh(value_type);
00119 static value_type Cosh(value_type);
00120 static value_type Tanh(value_type);
00121
00122 static value_type ASinh(value_type);
00123 static value_type ACosh(value_type);
00124 static value_type ATanh(value_type);
00125
00126 static value_type Log2(value_type);
00127 static value_type Log10(value_type);
00128 static value_type Ln(value_type);
00129
00130 static value_type Exp(value_type);
00131 static value_type Abs(value_type);
00132 static value_type Sqrt(value_type);
00133 static value_type Rint(value_type);
00134 static value_type Sign(value_type);
00135 static value_type Ite(value_type, value_type, value_type);
00136
00137
00138
00139 static value_type UnaryMinus(value_type);
00140
00141
00142 static value_type Sum(const value_type*, int);
00143 static value_type Avg(const value_type*, int);
00144 static value_type Min(const value_type*, int);
00145 static value_type Max(const value_type*, int);
00146
00147 static int IsVal(const char_type* a_szExpr, int *a_iPos, value_type *a_fVal);
00148
00149 static std::locale s_locale;
00150 };
00151 }
00152
00153 #endif
00154