1 /* 2 * 3 * Copyright (c) 1998-2002 4 * John Maddock 5 * 6 * Use, modification and distribution are subject to the 7 * Boost Software License, Version 1.0. (See accompanying file 8 * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 9 * 10 */ 11 12 /* 13 * LOCATION: see http://www.boost.org for most recent version. 14 * FILE pattern_except.hpp 15 * VERSION see <boost/version.hpp> 16 * DESCRIPTION: Declares pattern-matching exception classes. 17 */ 18 19 #ifndef BOOST_RE_PAT_EXCEPT_HPP 20 #define BOOST_RE_PAT_EXCEPT_HPP 21 22 #ifndef BOOST_REGEX_CONFIG_HPP 23 #include <boost/regex/config.hpp> 24 #endif 25 26 #include <stdexcept> 27 #include <cstddef> 28 #include <boost/regex/v4/error_type.hpp> 29 30 namespace boost{ 31 32 #ifdef BOOST_MSVC 33 #pragma warning(push) 34 #pragma warning(disable: 4103) 35 #endif 36 #ifdef BOOST_HAS_ABI_HEADERS 37 # include BOOST_ABI_PREFIX 38 #endif 39 #ifdef BOOST_MSVC 40 #pragma warning(pop) 41 #endif 42 43 #ifdef BOOST_MSVC 44 #pragma warning(push) 45 #pragma warning(disable : 4275) 46 #if BOOST_MSVC >= 1800 47 #pragma warning(disable : 26812) 48 #endif 49 #endif 50 class BOOST_REGEX_DECL regex_error : public std::runtime_error 51 { 52 public: 53 explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0); 54 explicit regex_error(regex_constants::error_type err); 55 ~regex_error() BOOST_NOEXCEPT_OR_NOTHROW; code() const56 regex_constants::error_type code()const 57 { return m_error_code; } position() const58 std::ptrdiff_t position()const 59 { return m_position; } 60 void raise()const; 61 private: 62 regex_constants::error_type m_error_code; 63 std::ptrdiff_t m_position; 64 }; 65 66 typedef regex_error bad_pattern; 67 typedef regex_error bad_expression; 68 69 namespace BOOST_REGEX_DETAIL_NS{ 70 71 BOOST_REGEX_DECL void BOOST_REGEX_CALL raise_runtime_error(const std::runtime_error& ex); 72 73 template <class traits> raise_error(const traits & t,regex_constants::error_type code)74void raise_error(const traits& t, regex_constants::error_type code) 75 { 76 (void)t; // warning suppression 77 std::runtime_error e(t.error_string(code)); 78 ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e); 79 } 80 81 } 82 83 #ifdef BOOST_MSVC 84 #pragma warning(pop) 85 #endif 86 87 #ifdef BOOST_MSVC 88 #pragma warning(push) 89 #pragma warning(disable: 4103) 90 #endif 91 #ifdef BOOST_HAS_ABI_HEADERS 92 # include BOOST_ABI_SUFFIX 93 #endif 94 #ifdef BOOST_MSVC 95 #pragma warning(pop) 96 #endif 97 98 } // namespace boost 99 100 #endif 101 102 103 104