OpcUaCanOpen
CANopen OPC-UA server
muParserError.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2004-2011 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 
26 #ifndef MU_PARSER_ERROR_H
27 #define MU_PARSER_ERROR_H
28 
29 #include <cassert>
30 #include <stdexcept>
31 #include <string>
32 #include <sstream>
33 #include <vector>
34 #include <memory>
35 
36 #include "muParserDef.h"
37 
42 namespace mu
43 {
44 
47 {
48  // Formula syntax errors
66  ecSTR_RESULT = 17,
67 
68  // Invalid Parser input Parameters
73 
79  ecOPT_PRI = 27,
80  //
83  ecGENERIC = 30,
84  ecLOCALE = 31,
85 
89 
91 
92  // internal errors
94 
95  // The last two are special entries
98 };
99 
100 //---------------------------------------------------------------------------
104 {
105 public:
106  static const ParserErrorMsg& Instance();
107  string_type operator[](unsigned a_iIdx) const;
108 
109 private:
110  ParserErrorMsg& operator=(const ParserErrorMsg &) = delete;
111  ParserErrorMsg(const ParserErrorMsg&) = delete;
112  ParserErrorMsg();
113 
114  ~ParserErrorMsg() = default;
115 
116  std::vector<string_type> m_vErrMsg;
117 };
118 
119 //---------------------------------------------------------------------------
126 {
127 private:
128 
130  void ReplaceSubString( string_type &strSource,
131  const string_type &strFind,
132  const string_type &strReplaceWith);
133  void Reset();
134 
135 public:
136 
137  ParserError();
138  explicit ParserError(EErrorCodes a_iErrc);
139  explicit ParserError(const string_type &sMsg);
140  ParserError( EErrorCodes a_iErrc,
141  const string_type &sTok,
142  const string_type &sFormula = string_type(),
143  int a_iPos = -1);
144  ParserError( EErrorCodes a_iErrc,
145  int a_iPos,
146  const string_type &sTok);
147  ParserError( const char_type *a_szMsg,
148  int a_iPos = -1,
149  const string_type &sTok = string_type());
150  ParserError(const ParserError &a_Obj);
151  ParserError& operator=(const ParserError &a_Obj);
152  ~ParserError();
153 
154  void SetFormula(const string_type &a_strFormula);
155  const string_type& GetExpr() const;
156  const string_type& GetMsg() const;
157  int GetPos() const;
158  const string_type& GetToken() const;
159  EErrorCodes GetCode() const;
160 
161 private:
165  int m_iPos;
168 };
169 
170 } // namespace mu
171 
172 #endif
173