include/boost/http/brotli/impl/error.hpp
100.0% Lines (2/2)
100.0% Functions (1/1)
| Line | TLA | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2021 Vinnie Falco ([email protected]) | ||
| 3 | // Copyright (c) 2024 Mohammad Nejati | ||
| 4 | // | ||
| 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) | ||
| 7 | // | ||
| 8 | // Official repository: https://github.com/cppalliance/http | ||
| 9 | // | ||
| 10 | |||
| 11 | #ifndef BOOST_HTTP_BROTLI_IMPL_ERROR_HPP | ||
| 12 | #define BOOST_HTTP_BROTLI_IMPL_ERROR_HPP | ||
| 13 | |||
| 14 | #include <boost/http/detail/config.hpp> | ||
| 15 | |||
| 16 | #include <boost/system/error_category.hpp> | ||
| 17 | #include <boost/system/is_error_code_enum.hpp> | ||
| 18 | #include <system_error> | ||
| 19 | |||
| 20 | namespace boost { | ||
| 21 | |||
| 22 | namespace system { | ||
| 23 | template<> | ||
| 24 | struct is_error_code_enum< | ||
| 25 | ::boost::http::brotli::error> | ||
| 26 | { | ||
| 27 | static bool const value = true; | ||
| 28 | }; | ||
| 29 | } // system | ||
| 30 | } // boost | ||
| 31 | |||
| 32 | namespace std { | ||
| 33 | template<> | ||
| 34 | struct is_error_code_enum< | ||
| 35 | ::boost::http::brotli::error> | ||
| 36 | : std::true_type {}; | ||
| 37 | } // std | ||
| 38 | |||
| 39 | namespace boost { | ||
| 40 | namespace http { | ||
| 41 | namespace brotli { | ||
| 42 | |||
| 43 | namespace detail { | ||
| 44 | |||
| 45 | struct BOOST_SYMBOL_VISIBLE | ||
| 46 | error_cat_type | ||
| 47 | : system::error_category | ||
| 48 | { | ||
| 49 | BOOST_HTTP_DECL const char* name( | ||
| 50 | ) const noexcept override; | ||
| 51 | BOOST_HTTP_DECL bool failed( | ||
| 52 | int) const noexcept override; | ||
| 53 | BOOST_HTTP_DECL std::string message( | ||
| 54 | int) const override; | ||
| 55 | BOOST_HTTP_DECL char const* message( | ||
| 56 | int, char*, std::size_t | ||
| 57 | ) const noexcept override; | ||
| 58 | BOOST_SYSTEM_CONSTEXPR error_cat_type() | ||
| 59 | : error_category(0xc38951ab8832fb6f) | ||
| 60 | { | ||
| 61 | } | ||
| 62 | }; | ||
| 63 | |||
| 64 | BOOST_HTTP_DECL extern | ||
| 65 | error_cat_type error_cat; | ||
| 66 | |||
| 67 | } // detail | ||
| 68 | |||
| 69 | inline | ||
| 70 | BOOST_SYSTEM_CONSTEXPR | ||
| 71 | system::error_code | ||
| 72 | 1 | make_error_code( | |
| 73 | error ev) noexcept | ||
| 74 | { | ||
| 75 | return system::error_code{ | ||
| 76 | static_cast<std::underlying_type< | ||
| 77 | error>::type>(ev), | ||
| 78 | 1 | detail::error_cat}; | |
| 79 | } | ||
| 80 | |||
| 81 | } // brotli | ||
| 82 | } // http | ||
| 83 | } // boost | ||
| 84 | |||
| 85 | #endif | ||
| 86 |