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