100.00% Lines (36/36)
100.00% Functions (11/11)
| TLA | Baseline | Branch | ||||||
|---|---|---|---|---|---|---|---|---|
| Line | Hits | Code | Line | Hits | Code | |||
| 1 | // | 1 | // | |||||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | |||||
| 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | |||||
| 4 | // | 4 | // | |||||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |||||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |||||
| 7 | // | 7 | // | |||||
| 8 | // Official repository: https://github.com/boostorg/url | 8 | // Official repository: https://github.com/boostorg/url | |||||
| 9 | // | 9 | // | |||||
| 10 | 10 | |||||||
| 11 | #ifndef BOOST_URL_GRAMMAR_IMPL_ERROR_HPP | 11 | #ifndef BOOST_URL_GRAMMAR_IMPL_ERROR_HPP | |||||
| 12 | #define BOOST_URL_GRAMMAR_IMPL_ERROR_HPP | 12 | #define BOOST_URL_GRAMMAR_IMPL_ERROR_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <type_traits> | 14 | #include <type_traits> | |||||
| 15 | 15 | |||||||
| 16 | namespace boost { | 16 | namespace boost { | |||||
| 17 | namespace system { | 17 | namespace system { | |||||
| 18 | template<> | 18 | template<> | |||||
| 19 | struct is_error_code_enum< | 19 | struct is_error_code_enum< | |||||
| 20 | ::boost::urls::grammar::error> | 20 | ::boost::urls::grammar::error> | |||||
| 21 | { | 21 | { | |||||
| 22 | static bool const value = true; | 22 | static bool const value = true; | |||||
| 23 | }; | 23 | }; | |||||
| 24 | template<> | 24 | template<> | |||||
| 25 | struct is_error_condition_enum< | 25 | struct is_error_condition_enum< | |||||
| 26 | ::boost::urls::grammar::condition> | 26 | ::boost::urls::grammar::condition> | |||||
| 27 | { | 27 | { | |||||
| 28 | static bool const value = true; | 28 | static bool const value = true; | |||||
| 29 | }; | 29 | }; | |||||
| 30 | } // system | 30 | } // system | |||||
| 31 | } // boost | 31 | } // boost | |||||
| 32 | 32 | |||||||
| 33 | namespace boost { | 33 | namespace boost { | |||||
| 34 | namespace urls { | 34 | namespace urls { | |||||
| 35 | namespace grammar { | 35 | namespace grammar { | |||||
| 36 | 36 | |||||||
| 37 | namespace detail { | 37 | namespace detail { | |||||
| 38 | 38 | |||||||
| 39 | struct BOOST_SYMBOL_VISIBLE | 39 | struct BOOST_SYMBOL_VISIBLE | |||||
| 40 | error_cat_type | 40 | error_cat_type | |||||
| 41 | : system::error_category | 41 | : system::error_category | |||||
| 42 | { | 42 | { | |||||
| 43 | BOOST_URL_CXX20_CONSTEXPR | 43 | BOOST_URL_CXX20_CONSTEXPR | |||||
| HITCBC | 44 | 616 | const char* name( | 44 | 616 | const char* name( | ||
| 45 | ) const noexcept override | 45 | ) const noexcept override | |||||
| 46 | { | 46 | { | |||||
| HITCBC | 47 | 616 | return "boost.url.grammar"; | 47 | 616 | return "boost.url.grammar"; | ||
| 48 | } | 48 | } | |||||
| 49 | 49 | |||||||
| HITCBC | 50 | 616 | std::string message( | 50 | 616 | std::string message( | ||
| 51 | int code) const override | 51 | int code) const override | |||||
| 52 | { | 52 | { | |||||
| HITCBC | 53 | 1232 | return message(code, nullptr, 0); | 53 | 1232 | return message(code, nullptr, 0); | ||
| 54 | } | 54 | } | |||||
| 55 | 55 | |||||||
| 56 | BOOST_URL_CXX20_CONSTEXPR | 56 | BOOST_URL_CXX20_CONSTEXPR | |||||
| HITCBC | 57 | 616 | char const* message( | 57 | 616 | char const* message( | ||
| 58 | int code, | 58 | int code, | |||||
| 59 | char*, | 59 | char*, | |||||
| 60 | std::size_t) const noexcept override | 60 | std::size_t) const noexcept override | |||||
| 61 | { | 61 | { | |||||
| HITCBC | 62 | 616 | switch(static_cast<error>(code)) | 62 | 616 | switch(static_cast<error>(code)) | ||
| 63 | { | 63 | { | |||||
| HITCBC | 64 | 1 | default: | 64 | 1 | default: | ||
| HITCBC | 65 | 1 | case error::need_more: return "need more"; | 65 | 1 | case error::need_more: return "need more"; | ||
| HITCBC | 66 | 63 | case error::mismatch: return "mismatch"; | 66 | 63 | case error::mismatch: return "mismatch"; | ||
| HITCBC | 67 | 13 | case error::invalid: return "invalid"; | 67 | 13 | case error::invalid: return "invalid"; | ||
| HITCBC | 68 | 1 | case error::end_of_range: return "end of range"; | 68 | 1 | case error::end_of_range: return "end of range"; | ||
| HITCBC | 69 | 537 | case error::leftover: return "leftover"; | 69 | 537 | case error::leftover: return "leftover"; | ||
| HITCBC | 70 | 1 | case error::out_of_range: return "out of range"; | 70 | 1 | case error::out_of_range: return "out of range"; | ||
| 71 | } | 71 | } | |||||
| 72 | } | 72 | } | |||||
| 73 | 73 | |||||||
| 74 | BOOST_URL_CXX20_CONSTEXPR | 74 | BOOST_URL_CXX20_CONSTEXPR | |||||
| 75 | system::error_condition | 75 | system::error_condition | |||||
| 76 | default_error_condition( | 76 | default_error_condition( | |||||
| 77 | int ev) const noexcept override; | 77 | int ev) const noexcept override; | |||||
| 78 | 78 | |||||||
| HITCBC | 79 | 78 | BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept | 79 | 78 | BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept | ||
| HITCBC | 80 | 78 | : error_category(0x0536e50a30f9e9f2) | 80 | 78 | : error_category(0x0536e50a30f9e9f2) | ||
| 81 | { | 81 | { | |||||
| HITCBC | 82 | 78 | } | 82 | 78 | } | ||
| 83 | }; | 83 | }; | |||||
| 84 | 84 | |||||||
| 85 | struct BOOST_SYMBOL_VISIBLE | 85 | struct BOOST_SYMBOL_VISIBLE | |||||
| 86 | condition_cat_type | 86 | condition_cat_type | |||||
| 87 | : system::error_category | 87 | : system::error_category | |||||
| 88 | { | 88 | { | |||||
| 89 | BOOST_URL_CXX20_CONSTEXPR | 89 | BOOST_URL_CXX20_CONSTEXPR | |||||
| HITCBC | 90 | 5 | const char* name( | 90 | 5 | const char* name( | ||
| 91 | ) const noexcept override | 91 | ) const noexcept override | |||||
| 92 | { | 92 | { | |||||
| HITCBC | 93 | 5 | return "boost.url.grammar"; | 93 | 5 | return "boost.url.grammar"; | ||
| 94 | } | 94 | } | |||||
| 95 | 95 | |||||||
| HITCBC | 96 | 5 | std::string message( | 96 | 5 | std::string message( | ||
| 97 | int code) const override | 97 | int code) const override | |||||
| 98 | { | 98 | { | |||||
| HITCBC | 99 | 10 | return message(code, nullptr, 0); | 99 | 10 | return message(code, nullptr, 0); | ||
| 100 | } | 100 | } | |||||
| 101 | 101 | |||||||
| 102 | BOOST_URL_CXX20_CONSTEXPR | 102 | BOOST_URL_CXX20_CONSTEXPR | |||||
| HITCBC | 103 | 5 | char const* message( | 103 | 5 | char const* message( | ||
| 104 | int code, | 104 | int code, | |||||
| 105 | char*, | 105 | char*, | |||||
| 106 | std::size_t) const noexcept override | 106 | std::size_t) const noexcept override | |||||
| 107 | { | 107 | { | |||||
| 108 | switch(static_cast<condition>(code)) | 108 | switch(static_cast<condition>(code)) | |||||
| 109 | { | 109 | { | |||||
| 110 | default: | 110 | default: | |||||
| 111 | case condition::fatal: | 111 | case condition::fatal: | |||||
| HITCBC | 112 | 5 | return "fatal condition"; | 112 | 5 | return "fatal condition"; | ||
| 113 | } | 113 | } | |||||
| 114 | } | 114 | } | |||||
| 115 | 115 | |||||||
| HITCBC | 116 | 78 | BOOST_SYSTEM_CONSTEXPR condition_cat_type() | 116 | 78 | BOOST_SYSTEM_CONSTEXPR condition_cat_type() | ||
| HITCBC | 117 | 78 | : error_category(0x0536e50a30f9e9f2) | 117 | 78 | : error_category(0x0536e50a30f9e9f2) | ||
| 118 | { | 118 | { | |||||
| HITCBC | 119 | 78 | } | 119 | 78 | } | ||
| 120 | }; | 120 | }; | |||||
| 121 | 121 | |||||||
| 122 | #if defined(BOOST_URL_HAS_CXX20_CONSTEXPR) | 122 | #if defined(BOOST_URL_HAS_CXX20_CONSTEXPR) | |||||
| 123 | // Visible so a shared library built as C++20 | 123 | // Visible so a shared library built as C++20 | |||||
| 124 | // still exports the symbols that consumers built | 124 | // still exports the symbols that consumers built | |||||
| 125 | // as C++17 reference through the externs below | 125 | // as C++17 reference through the externs below | |||||
| 126 | BOOST_SYMBOL_VISIBLE | 126 | BOOST_SYMBOL_VISIBLE | |||||
| 127 | inline constexpr error_cat_type error_cat{}; | 127 | inline constexpr error_cat_type error_cat{}; | |||||
| 128 | BOOST_SYMBOL_VISIBLE | 128 | BOOST_SYMBOL_VISIBLE | |||||
| 129 | inline constexpr condition_cat_type condition_cat{}; | 129 | inline constexpr condition_cat_type condition_cat{}; | |||||
| 130 | #else | 130 | #else | |||||
| 131 | BOOST_URL_DECL extern error_cat_type error_cat; | 131 | BOOST_URL_DECL extern error_cat_type error_cat; | |||||
| 132 | BOOST_URL_DECL extern condition_cat_type condition_cat; | 132 | BOOST_URL_DECL extern condition_cat_type condition_cat; | |||||
| 133 | #endif | 133 | #endif | |||||
| 134 | 134 | |||||||
| 135 | } // detail | 135 | } // detail | |||||
| 136 | 136 | |||||||
| 137 | inline | 137 | inline | |||||
| 138 | BOOST_SYSTEM_CONSTEXPR | 138 | BOOST_SYSTEM_CONSTEXPR | |||||
| 139 | system::error_code | 139 | system::error_code | |||||
| HITCBC | 140 | 53381 | make_error_code( | 140 | 53401 | make_error_code( | ||
| 141 | error ev) noexcept | 141 | error ev) noexcept | |||||
| 142 | { | 142 | { | |||||
| 143 | return system::error_code{ | 143 | return system::error_code{ | |||||
| 144 | static_cast<std::underlying_type< | 144 | static_cast<std::underlying_type< | |||||
| 145 | error>::type>(ev), | 145 | error>::type>(ev), | |||||
| HITCBC | 146 | 53381 | detail::error_cat}; | 146 | 53401 | detail::error_cat}; | ||
| 147 | } | 147 | } | |||||
| 148 | 148 | |||||||
| 149 | inline | 149 | inline | |||||
| 150 | BOOST_SYSTEM_CONSTEXPR | 150 | BOOST_SYSTEM_CONSTEXPR | |||||
| 151 | system::error_condition | 151 | system::error_condition | |||||
| HITCBC | 152 | 20 | make_error_condition( | 152 | 20 | make_error_condition( | ||
| 153 | condition c) noexcept | 153 | condition c) noexcept | |||||
| 154 | { | 154 | { | |||||
| HITCBC | 155 | 20 | return system::error_condition{ | 155 | 20 | return system::error_condition{ | ||
| 156 | static_cast<std::underlying_type< | 156 | static_cast<std::underlying_type< | |||||
| 157 | condition>::type>(c), | 157 | condition>::type>(c), | |||||
| HITCBC | 158 | 20 | detail::condition_cat}; | 158 | 20 | detail::condition_cat}; | ||
| 159 | } | 159 | } | |||||
| 160 | 160 | |||||||
| 161 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | 161 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | |||||
| 162 | system::error_condition | 162 | system::error_condition | |||||
| HITCBC | 163 | 6 | detail::error_cat_type:: | 163 | 6 | detail::error_cat_type:: | ||
| 164 | default_error_condition( | 164 | default_error_condition( | |||||
| 165 | int ev) const noexcept | 165 | int ev) const noexcept | |||||
| 166 | { | 166 | { | |||||
| HITCBC | 167 | 6 | switch(static_cast<error>(ev)) | 167 | 6 | switch(static_cast<error>(ev)) | ||
| 168 | { | 168 | { | |||||
| HITCBC | 169 | 2 | case error::invalid: | 169 | 2 | case error::invalid: | ||
| 170 | case error::out_of_range: | 170 | case error::out_of_range: | |||||
| HITCBC | 171 | 2 | return condition::fatal; | 171 | 2 | return condition::fatal; | ||
| HITCBC | 172 | 4 | default: | 172 | 4 | default: | ||
| HITCBC | 173 | 4 | return {ev, *this}; | 173 | 4 | return {ev, *this}; | ||
| 174 | } | 174 | } | |||||
| 175 | } | 175 | } | |||||
| 176 | 176 | |||||||
| 177 | } // grammar | 177 | } // grammar | |||||
| 178 | } // urls | 178 | } // urls | |||||
| 179 | } // boost | 179 | } // boost | |||||
| 180 | 180 | |||||||
| 181 | #endif | 181 | #endif | |||||