Add HeFFTe based FFT backend
[alexxy/gromacs.git] / src / external / muparser / include / muParserError.h
1 /*
2
3          _____  __ _____________ _______  ______ ___________
4         /     \|  |  \____ \__  \\_  __ \/  ___// __ \_  __ \
5    |  Y Y  \  |  /  |_> > __ \|  | \/\___ \\  ___/|  | \/
6    |__|_|  /____/|   __(____  /__|  /____  >\___  >__|
7                  \/      |__|       \/           \/     \/
8    Copyright (C) 2004 - 2020 Ingo Berg
9
10         Redistribution and use in source and binary forms, with or without modification, are permitted
11         provided that the following conditions are met:
12
13           * Redistributions of source code must retain the above copyright notice, this list of
14                 conditions and the following disclaimer.
15           * Redistributions in binary form must reproduce the above copyright notice, this list of
16                 conditions and the following disclaimer in the documentation and/or other materials provided
17                 with the distribution.
18
19         THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
20         IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
21         FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
22         CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23         DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24         DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
25         IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
26         OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29 #ifndef MU_PARSER_ERROR_H
30 #define MU_PARSER_ERROR_H
31
32 #include <stdexcept>
33 #include <string>
34 #include <sstream>
35 #include <vector>
36 #include <memory>
37
38 #include "muParserDef.h"
39
40 /** \file
41         \brief This file defines the error class used by the parser.
42 */
43
44 namespace mu
45 {
46         /** \brief A class that handles the error messages.     */
47         class ParserErrorMsg final
48         {
49         public:
50                 static const ParserErrorMsg& Instance();
51                 string_type operator[](unsigned a_iIdx) const;
52
53         private:
54                 ParserErrorMsg& operator=(const ParserErrorMsg&) = delete;
55                 ParserErrorMsg(const ParserErrorMsg&) = delete;
56                 ParserErrorMsg();
57
58                 ~ParserErrorMsg() = default;
59
60                 std::vector<string_type>  m_vErrMsg;  ///< A vector with the predefined error messages
61         };
62
63
64         /** \brief Error class of the parser.
65
66           Part of the math parser package.
67         */
68         class API_EXPORT_CXX ParserError
69         {
70         private:
71
72                 /** \brief Replace all ocuurences of a substring with another string. */
73                 void ReplaceSubString(string_type& strSource, const string_type& strFind, const string_type& strReplaceWith);
74                 void Reset();
75
76         public:
77
78                 ParserError();
79                 explicit ParserError(EErrorCodes a_iErrc);
80                 explicit ParserError(const string_type& sMsg);
81                 ParserError(EErrorCodes a_iErrc, const string_type& sTok, const string_type& sFormula = string_type(), int a_iPos = -1);
82                 ParserError(EErrorCodes a_iErrc, int a_iPos, const string_type& sTok);
83                 ParserError(const char_type* a_szMsg, int a_iPos = -1, const string_type& sTok = string_type());
84                 ParserError(const ParserError& a_Obj);
85
86                 ParserError& operator=(const ParserError& a_Obj);
87                 ~ParserError();
88
89                 void SetFormula(const string_type& a_strFormula);
90                 const string_type& GetExpr() const;
91                 const string_type& GetMsg() const;
92                 int GetPos() const;
93                 const string_type& GetToken() const;
94                 EErrorCodes GetCode() const;
95
96         private:
97                 string_type m_strMsg;     ///< The message string
98                 string_type m_strFormula; ///< Formula string
99                 string_type m_strTok;     ///< Token related with the error
100                 int m_iPos;               ///< Formula position related to the error 
101                 EErrorCodes m_iErrc;      ///< Error code
102                 const ParserErrorMsg& m_ErrMsg;
103         };
104
105 } // namespace mu
106
107 #endif
108