| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // | ||
| 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) | ||
| 6 | // | ||
| 7 | // Official repository: https://github.com/boostorg/url | ||
| 8 | // | ||
| 9 | |||
| 10 | |||
| 11 | #include <boost/url/detail/config.hpp> | ||
| 12 | #include <boost/url/grammar/error.hpp> | ||
| 13 | |||
| 14 | namespace boost { | ||
| 15 | namespace urls { | ||
| 16 | namespace grammar { | ||
| 17 | |||
| 18 | namespace detail { | ||
| 19 | |||
| 20 | const char* | ||
| 21 | 82 | error_cat_type:: | |
| 22 | name() const noexcept | ||
| 23 | { | ||
| 24 | 82 | return "boost.url.grammar"; | |
| 25 | } | ||
| 26 | |||
| 27 | std::string | ||
| 28 | 82 | error_cat_type:: | |
| 29 | message(int code) const | ||
| 30 | { | ||
| 31 |
1/2✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
|
164 | return message(code, nullptr, 0); |
| 32 | } | ||
| 33 | |||
| 34 | char const* | ||
| 35 | 82 | error_cat_type:: | |
| 36 | message( | ||
| 37 | int code, | ||
| 38 | char*, | ||
| 39 | std::size_t) const noexcept | ||
| 40 | { | ||
| 41 |
6/6✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
✓ Branch 2 taken 13 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 1 times.
|
82 | switch(static_cast<error>(code)) |
| 42 | { | ||
| 43 | 1 | default: | |
| 44 | 1 | case error::need_more: return "need more"; | |
| 45 | 14 | case error::mismatch: return "mismatch"; | |
| 46 | 13 | case error::invalid: return "invalid"; | |
| 47 | 1 | case error::end_of_range: return "end of range"; | |
| 48 | 52 | case error::leftover: return "leftover"; | |
| 49 | 1 | case error::out_of_range: return "out of range"; | |
| 50 | } | ||
| 51 | } | ||
| 52 | |||
| 53 | system::error_condition | ||
| 54 | 6 | error_cat_type:: | |
| 55 | default_error_condition( | ||
| 56 | int ev) const noexcept | ||
| 57 | { | ||
| 58 |
2/2✓ Branch 0 taken 2 times.
✓ Branch 1 taken 4 times.
|
6 | switch(static_cast<error>(ev)) |
| 59 | { | ||
| 60 | 2 | case error::invalid: | |
| 61 | case error::out_of_range: | ||
| 62 | 2 | return condition::fatal; | |
| 63 | 4 | default: | |
| 64 | 4 | return {ev, *this}; | |
| 65 | } | ||
| 66 | } | ||
| 67 | |||
| 68 | //------------------------------------------------ | ||
| 69 | |||
| 70 | const char* | ||
| 71 | 5 | condition_cat_type:: | |
| 72 | name() const noexcept | ||
| 73 | { | ||
| 74 | 5 | return "boost.url.grammar"; | |
| 75 | } | ||
| 76 | |||
| 77 | std::string | ||
| 78 | 5 | condition_cat_type:: | |
| 79 | message(int code) const | ||
| 80 | { | ||
| 81 |
1/2✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
|
10 | return message(code, nullptr, 0); |
| 82 | } | ||
| 83 | |||
| 84 | char const* | ||
| 85 | 5 | condition_cat_type:: | |
| 86 | message( | ||
| 87 | int code, char*, std::size_t) const noexcept | ||
| 88 | { | ||
| 89 | switch(static_cast<condition>(code)) | ||
| 90 | { | ||
| 91 | default: | ||
| 92 | case condition::fatal: | ||
| 93 | 5 | return "fatal condition"; | |
| 94 | } | ||
| 95 | } | ||
| 96 | |||
| 97 | //----------------------------------------------- | ||
| 98 | |||
| 99 | // msvc 14.0 has a bug that warns about inability | ||
| 100 | // to use constexpr construction here, even though | ||
| 101 | // there's no constexpr construction | ||
| 102 | #if defined(_MSC_VER) && _MSC_VER <= 1900 | ||
| 103 | # pragma warning( push ) | ||
| 104 | # pragma warning( disable : 4592 ) | ||
| 105 | #endif | ||
| 106 | |||
| 107 | error_cat_type error_cat; | ||
| 108 | condition_cat_type condition_cat; | ||
| 109 | |||
| 110 | #if defined(_MSC_VER) && _MSC_VER <= 1900 | ||
| 111 | # pragma warning( pop ) | ||
| 112 | #endif | ||
| 113 | |||
| 114 | } // detail | ||
| 115 | |||
| 116 | } // grammar | ||
| 117 | } // urls | ||
| 118 | } // boost | ||
| 119 | |||
| 120 |