include/boost/regex/v5/pattern_except.hpp

85.0% Lines (17/20) 42.9% List of functions (6/15)
pattern_except.hpp
f(x) Functions (15)
Function Calls Lines Blocks
<unknown function 42> :42 boost::regex_error::regex_error(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, boost::regex_constants::error_type, long) :45 16168x 100.0% 100.0% boost::regex_error::~regex_error() :57 32196x 100.0% 100.0% boost::regex_error::code() const :58 1x 100.0% 100.0% boost::regex_error::raise() const :62 16155x 75.0% 100.0% void boost::re_detail_600::raise_runtime_error<boost::regex_error>(boost::regex_error const&) :83 13x 66.7% 100.0% void boost::re_detail_600::raise_runtime_error<std::runtime_error>(std::runtime_error const&) :83 0 0.0% 0.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<boost::c_regex_traits<char> > >(boost::regex_traits_wrapper<boost::c_regex_traits<char> > const&, boost::regex_constants::error_type) :93 0 0.0% 0.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<boost::c_regex_traits<wchar_t> > >(boost::regex_traits_wrapper<boost::c_regex_traits<wchar_t> > const&, boost::regex_constants::error_type) :93 0 0.0% 0.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<boost::cpp_regex_traits<char> > >(boost::regex_traits_wrapper<boost::cpp_regex_traits<char> > const&, boost::regex_constants::error_type) :93 0 0.0% 0.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<boost::cpp_regex_traits<wchar_t> > >(boost::regex_traits_wrapper<boost::cpp_regex_traits<wchar_t> > const&, boost::regex_constants::error_type) :93 0 0.0% 0.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<boost::icu_regex_traits> >(boost::regex_traits_wrapper<boost::icu_regex_traits> const&, boost::regex_constants::error_type) :93 0 0.0% 0.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > >(boost::regex_traits_wrapper<boost::regex_traits<char, boost::cpp_regex_traits<char> > > const&, boost::regex_constants::error_type) :93 13x 100.0% 58.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > > >(boost::regex_traits_wrapper<boost::regex_traits<wchar_t, boost::cpp_regex_traits<wchar_t> > > const&, boost::regex_constants::error_type) :93 0 0.0% 0.0% void boost::re_detail_600::raise_error<boost::regex_traits_wrapper<char32_traits> >(boost::regex_traits_wrapper<char32_traits> const&, boost::regex_constants::error_type) :93 0 0.0% 0.0%
Line TLA Hits Source Code
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_V5_PAT_EXCEPT_HPP
20 #define BOOST_RE_V5_PAT_EXCEPT_HPP
21
22 #ifndef BOOST_REGEX_CONFIG_HPP
23 #include <boost/regex/config.hpp>
24 #endif
25
26 #ifndef BOOST_REGEX_AS_MODULE
27 #include <cstddef>
28 #include <stdexcept>
29 #endif
30 #include <boost/regex/v5/error_type.hpp>
31 #include <boost/regex/v5/regex_traits_defaults.hpp>
32
33 namespace boost{
34
35 #ifdef BOOST_REGEX_MSVC
36 #pragma warning(push)
37 #pragma warning(disable : 4275)
38 #if BOOST_REGEX_MSVC >= 1800
39 #pragma warning(disable : 26812 4459)
40 #endif
41 #endif
42 BOOST_REGEX_MODULE_EXPORT class regex_error : public std::runtime_error
43 {
44 public:
45 16168x explicit regex_error(const std::string& s, regex_constants::error_type err = regex_constants::error_unknown, std::ptrdiff_t pos = 0)
46 16168x : std::runtime_error(s)
47 16168x , m_error_code(err)
48 16168x , m_position(pos)
49 {
50 16168x }
51 explicit regex_error(regex_constants::error_type err)
52 : std::runtime_error(::boost::BOOST_REGEX_DETAIL_NS::get_default_error_string(err))
53 , m_error_code(err)
54 , m_position(0)
55 {
56 }
57 32196x ~regex_error() noexcept override = default;
58 1x regex_constants::error_type code()const
59 1x { return m_error_code; }
60 std::ptrdiff_t position()const
61 { return m_position; }
62 16155x void raise()const
63 {
64 #ifndef BOOST_NO_EXCEPTIONS
65 #ifndef BOOST_REGEX_STANDALONE
66 16015x ::boost::throw_exception(*this);
67 #else
68 throw* this;
69 #endif
70 #endif
71 140x }
72 private:
73 regex_constants::error_type m_error_code;
74 std::ptrdiff_t m_position;
75 };
76
77 BOOST_REGEX_MODULE_EXPORT typedef regex_error bad_pattern;
78 BOOST_REGEX_MODULE_EXPORT typedef regex_error bad_expression;
79
80 namespace BOOST_REGEX_DETAIL_NS{
81
82 template <class E>
83 13x inline void raise_runtime_error(const E& ex)
84 {
85 #ifndef BOOST_REGEX_STANDALONE
86 13x ::boost::throw_exception(ex);
87 #else
88 throw ex;
89 #endif
90 }
91
92 template <class traits>
93 13x void raise_error(const traits& t, regex_constants::error_type code)
94 {
95 (void)t; // warning suppression
96 13x regex_error e(t.error_string(code), code, 0);
97 13x ::boost::BOOST_REGEX_DETAIL_NS::raise_runtime_error(e);
98 13x }
99
100 }
101
102 #ifdef BOOST_REGEX_MSVC
103 #pragma warning(pop)
104 #endif
105
106 } // namespace boost
107
108 #endif
109