include/boost/http/impl/error.hpp
100.0% Lines (6/0/6)
100.0% List of functions (2/0/2)
Functions (2)
| Line | TLA | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2021 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/cppalliance/http | ||
| 8 | // | ||
| 9 | |||
| 10 | #ifndef BOOST_HTTP_IMPL_ERROR_HPP | ||
| 11 | #define BOOST_HTTP_IMPL_ERROR_HPP | ||
| 12 | |||
| 13 | #include <system_error> | ||
| 14 | |||
| 15 | namespace std { | ||
| 16 | template<> | ||
| 17 | struct is_error_code_enum< | ||
| 18 | ::boost::http::error> | ||
| 19 | : std::true_type {}; | ||
| 20 | |||
| 21 | template<> | ||
| 22 | struct is_error_condition_enum< | ||
| 23 | ::boost::http::condition> | ||
| 24 | : std::true_type {}; | ||
| 25 | } // std | ||
| 26 | |||
| 27 | namespace boost { | ||
| 28 | |||
| 29 | //----------------------------------------------- | ||
| 30 | |||
| 31 | namespace http { | ||
| 32 | |||
| 33 | namespace detail { | ||
| 34 | |||
| 35 | struct BOOST_HTTP_SYMBOL_VISIBLE | ||
| 36 | error_cat_type | ||
| 37 | : std::error_category | ||
| 38 | { | ||
| 39 | BOOST_HTTP_DECL const char* name( | ||
| 40 | ) const noexcept override; | ||
| 41 | BOOST_HTTP_DECL std::string message( | ||
| 42 | int) const override; | ||
| 43 | constexpr error_cat_type() noexcept = default; | ||
| 44 | }; | ||
| 45 | |||
| 46 | struct BOOST_HTTP_SYMBOL_VISIBLE | ||
| 47 | condition_cat_type | ||
| 48 | : std::error_category | ||
| 49 | { | ||
| 50 | BOOST_HTTP_DECL const char* name( | ||
| 51 | ) const noexcept override; | ||
| 52 | BOOST_HTTP_DECL std::string message( | ||
| 53 | int) const override; | ||
| 54 | BOOST_HTTP_DECL bool equivalent( | ||
| 55 | std::error_code const&, int | ||
| 56 | ) const noexcept override; | ||
| 57 | constexpr condition_cat_type() noexcept = default; | ||
| 58 | }; | ||
| 59 | |||
| 60 | BOOST_HTTP_DECL extern | ||
| 61 | error_cat_type error_cat; | ||
| 62 | BOOST_HTTP_DECL extern | ||
| 63 | condition_cat_type condition_cat; | ||
| 64 | |||
| 65 | } // detail | ||
| 66 | |||
| 67 | inline | ||
| 68 | std::error_code | ||
| 69 | 120678x | make_error_code( | |
| 70 | error ev) noexcept | ||
| 71 | { | ||
| 72 | 120678x | return std::error_code{ | |
| 73 | static_cast<std::underlying_type< | ||
| 74 | error>::type>(ev), | ||
| 75 | 120678x | detail::error_cat}; | |
| 76 | } | ||
| 77 | |||
| 78 | inline | ||
| 79 | std::error_condition | ||
| 80 | 154847x | make_error_condition( | |
| 81 | condition c) noexcept | ||
| 82 | { | ||
| 83 | 154847x | return std::error_condition{ | |
| 84 | static_cast<std::underlying_type< | ||
| 85 | condition>::type>(c), | ||
| 86 | 154847x | detail::condition_cat}; | |
| 87 | } | ||
| 88 | |||
| 89 | } // http | ||
| 90 | } // boost | ||
| 91 | |||
| 92 | #endif | ||
| 93 |