3 _____ __ _____________ _______ ______ ___________
4 / \| | \____ \__ \\_ __ \/ ___// __ \_ __ \
5 | Y Y \ | / |_> > __ \| | \/\___ \\ ___/| | \/
6 |__|_| /____/| __(____ /__| /____ >\___ >__|
8 Copyright (C) 2004 - 2020 Ingo Berg
10 Redistribution and use in source and binary forms, with or without modification, are permitted
11 provided that the following conditions are met:
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.
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.
29 #ifndef MU_PARSER_ERROR_H
30 #define MU_PARSER_ERROR_H
38 #include "muParserDef.h"
41 \brief This file defines the error class used by the parser.
46 /** \brief A class that handles the error messages. */
47 class ParserErrorMsg final
50 static const ParserErrorMsg& Instance();
51 string_type operator[](unsigned a_iIdx) const;
54 ParserErrorMsg& operator=(const ParserErrorMsg&) = delete;
55 ParserErrorMsg(const ParserErrorMsg&) = delete;
58 ~ParserErrorMsg() = default;
60 std::vector<string_type> m_vErrMsg; ///< A vector with the predefined error messages
64 /** \brief Error class of the parser.
66 Part of the math parser package.
68 class API_EXPORT_CXX ParserError
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);
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);
86 ParserError& operator=(const ParserError& a_Obj);
89 void SetFormula(const string_type& a_strFormula);
90 const string_type& GetExpr() const;
91 const string_type& GetMsg() const;
93 const string_type& GetToken() const;
94 EErrorCodes GetCode() const;
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;