100.00% Lines (27/27)
100.00% Functions (6/6)
| 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_IMPL_ERROR_HPP | 11 | #ifndef BOOST_URL_IMPL_ERROR_HPP | |||||
| 12 | #define BOOST_URL_IMPL_ERROR_HPP | 12 | #define BOOST_URL_IMPL_ERROR_HPP | |||||
| 13 | 13 | |||||||
| 14 | #include <boost/url/grammar/error.hpp> | 14 | #include <boost/url/grammar/error.hpp> | |||||
| 15 | #include <type_traits> | 15 | #include <type_traits> | |||||
| 16 | 16 | |||||||
| 17 | namespace boost { | 17 | namespace boost { | |||||
| 18 | 18 | |||||||
| 19 | //----------------------------------------------- | 19 | //----------------------------------------------- | |||||
| 20 | namespace system { | 20 | namespace system { | |||||
| 21 | template<> | 21 | template<> | |||||
| 22 | struct is_error_code_enum<::boost::urls::error> | 22 | struct is_error_code_enum<::boost::urls::error> | |||||
| 23 | { | 23 | { | |||||
| 24 | static bool const value = true; | 24 | static bool const value = true; | |||||
| 25 | }; | 25 | }; | |||||
| 26 | } // system | 26 | } // system | |||||
| 27 | //----------------------------------------------- | 27 | //----------------------------------------------- | |||||
| 28 | 28 | |||||||
| 29 | namespace urls { | 29 | namespace urls { | |||||
| 30 | 30 | |||||||
| 31 | namespace detail { | 31 | namespace detail { | |||||
| 32 | 32 | |||||||
| 33 | struct BOOST_SYMBOL_VISIBLE | 33 | struct BOOST_SYMBOL_VISIBLE | |||||
| 34 | error_cat_type | 34 | error_cat_type | |||||
| 35 | : system::error_category | 35 | : system::error_category | |||||
| 36 | { | 36 | { | |||||
| 37 | BOOST_URL_CXX20_CONSTEXPR | 37 | BOOST_URL_CXX20_CONSTEXPR | |||||
| HITCBC | 38 | 246 | const char* name( | 38 | 246 | const char* name( | ||
| 39 | ) const noexcept override | 39 | ) const noexcept override | |||||
| 40 | { | 40 | { | |||||
| HITCBC | 41 | 246 | return "boost.url"; | 41 | 246 | return "boost.url"; | ||
| 42 | } | 42 | } | |||||
| 43 | 43 | |||||||
| HITCBC | 44 | 247 | std::string message( | 44 | 247 | std::string message( | ||
| 45 | int code) const override | 45 | int code) const override | |||||
| 46 | { | 46 | { | |||||
| HITCBC | 47 | 494 | return message(code, nullptr, 0); | 47 | 494 | return message(code, nullptr, 0); | ||
| 48 | } | 48 | } | |||||
| 49 | 49 | |||||||
| 50 | BOOST_URL_CXX20_CONSTEXPR | 50 | BOOST_URL_CXX20_CONSTEXPR | |||||
| HITCBC | 51 | 247 | char const* message( | 51 | 247 | char const* message( | ||
| 52 | int code, | 52 | int code, | |||||
| 53 | char*, | 53 | char*, | |||||
| 54 | std::size_t) const noexcept override | 54 | std::size_t) const noexcept override | |||||
| 55 | { | 55 | { | |||||
| HITCBC | 56 | 247 | switch(static_cast<error>(code)) | 56 | 247 | switch(static_cast<error>(code)) | ||
| 57 | { | 57 | { | |||||
| HITCBC | 58 | 1 | case error::success: return "success"; | 58 | 1 | case error::success: return "success"; | ||
| HITCBC | 59 | 1 | case error::illegal_null: return "illegal null"; | 59 | 1 | case error::illegal_null: return "illegal null"; | ||
| HITCBC | 60 | 1 | case error::illegal_reserved_char: return "illegal reserved char"; | 60 | 1 | case error::illegal_reserved_char: return "illegal reserved char"; | ||
| HITCBC | 61 | 1 | case error::non_canonical: return "non canonical"; | 61 | 1 | case error::non_canonical: return "non canonical"; | ||
| HITCBC | 62 | 98 | case error::bad_pct_hexdig: return "bad hexdig in pct-encoding"; | 62 | 98 | case error::bad_pct_hexdig: return "bad hexdig in pct-encoding"; | ||
| HITCBC | 63 | 141 | case error::incomplete_encoding: return "incomplete pct-encoding"; | 63 | 141 | case error::incomplete_encoding: return "incomplete pct-encoding"; | ||
| HITCBC | 64 | 1 | case error::missing_pct_hexdig: return "missing hexdig in pct-encoding"; | 64 | 1 | case error::missing_pct_hexdig: return "missing hexdig in pct-encoding"; | ||
| HITCBC | 65 | 1 | case error::no_space: return "no space"; | 65 | 1 | case error::no_space: return "no space"; | ||
| HITCBC | 66 | 1 | case error::not_a_base: return "not a base"; | 66 | 1 | case error::not_a_base: return "not a base"; | ||
| 67 | } | 67 | } | |||||
| HITCBC | 68 | 1 | return ""; | 68 | 1 | return ""; | ||
| 69 | } | 69 | } | |||||
| 70 | 70 | |||||||
| 71 | BOOST_URL_CXX20_CONSTEXPR | 71 | BOOST_URL_CXX20_CONSTEXPR | |||||
| 72 | system::error_condition | 72 | system::error_condition | |||||
| 73 | default_error_condition( | 73 | default_error_condition( | |||||
| 74 | int ev) const noexcept override; | 74 | int ev) const noexcept override; | |||||
| 75 | 75 | |||||||
| HITCBC | 76 | 78 | BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept | 76 | 78 | BOOST_SYSTEM_CONSTEXPR error_cat_type() noexcept | ||
| HITCBC | 77 | 78 | : error_category(0xbc15399d7a4ce829) | 77 | 78 | : error_category(0xbc15399d7a4ce829) | ||
| 78 | { | 78 | { | |||||
| HITCBC | 79 | 78 | } | 79 | 78 | } | ||
| 80 | }; | 80 | }; | |||||
| 81 | 81 | |||||||
| 82 | #if defined(BOOST_URL_HAS_CXX20_CONSTEXPR) | 82 | #if defined(BOOST_URL_HAS_CXX20_CONSTEXPR) | |||||
| 83 | // Visible so a shared library built as C++20 | 83 | // Visible so a shared library built as C++20 | |||||
| 84 | // still exports the symbol that consumers built | 84 | // still exports the symbol that consumers built | |||||
| 85 | // as C++17 reference through the extern below | 85 | // as C++17 reference through the extern below | |||||
| 86 | BOOST_SYMBOL_VISIBLE | 86 | BOOST_SYMBOL_VISIBLE | |||||
| 87 | inline constexpr error_cat_type error_cat{}; | 87 | inline constexpr error_cat_type error_cat{}; | |||||
| 88 | #else | 88 | #else | |||||
| 89 | BOOST_URL_DECL extern error_cat_type error_cat; | 89 | BOOST_URL_DECL extern error_cat_type error_cat; | |||||
| 90 | #endif | 90 | #endif | |||||
| 91 | 91 | |||||||
| 92 | } // detail | 92 | } // detail | |||||
| 93 | 93 | |||||||
| 94 | inline | 94 | inline | |||||
| 95 | BOOST_SYSTEM_CONSTEXPR | 95 | BOOST_SYSTEM_CONSTEXPR | |||||
| 96 | system::error_code | 96 | system::error_code | |||||
| HITCBC | 97 | 264 | make_error_code( | 97 | 264 | make_error_code( | ||
| 98 | error ev) noexcept | 98 | error ev) noexcept | |||||
| 99 | { | 99 | { | |||||
| 100 | return system::error_code{ | 100 | return system::error_code{ | |||||
| 101 | static_cast<std::underlying_type< | 101 | static_cast<std::underlying_type< | |||||
| 102 | error>::type>(ev), | 102 | error>::type>(ev), | |||||
| HITCBC | 103 | 264 | detail::error_cat}; | 103 | 264 | detail::error_cat}; | ||
| 104 | } | 104 | } | |||||
| 105 | 105 | |||||||
| 106 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | 106 | BOOST_URL_CXX20_CONSTEXPR_OR_INLINE | |||||
| 107 | system::error_condition | 107 | system::error_condition | |||||
| HITCBC | 108 | 9 | detail::error_cat_type:: | 108 | 9 | detail::error_cat_type:: | ||
| 109 | default_error_condition( | 109 | default_error_condition( | |||||
| 110 | int ev) const noexcept | 110 | int ev) const noexcept | |||||
| 111 | { | 111 | { | |||||
| HITCBC | 112 | 9 | switch(static_cast<error>(ev)) | 112 | 9 | switch(static_cast<error>(ev)) | ||
| 113 | { | 113 | { | |||||
| HITCBC | 114 | 6 | default: | 114 | 6 | default: | ||
| HITCBC | 115 | 6 | return {ev, *this}; | 115 | 6 | return {ev, *this}; | ||
| HITCBC | 116 | 3 | case error::bad_pct_hexdig: | 116 | 3 | case error::bad_pct_hexdig: | ||
| 117 | case error::incomplete_encoding: | 117 | case error::incomplete_encoding: | |||||
| 118 | case error::missing_pct_hexdig: | 118 | case error::missing_pct_hexdig: | |||||
| HITCBC | 119 | 3 | return grammar::condition::fatal; | 119 | 3 | return grammar::condition::fatal; | ||
| 120 | } | 120 | } | |||||
| 121 | } | 121 | } | |||||
| 122 | 122 | |||||||
| 123 | } // urls | 123 | } // urls | |||||
| 124 | } // boost | 124 | } // boost | |||||
| 125 | 125 | |||||||
| 126 | #endif | 126 | #endif | |||||