Line data 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_proto 8 : // 9 : 10 : #ifndef BOOST_HTTP_PROTO_IMPL_ERROR_HPP 11 : #define BOOST_HTTP_PROTO_IMPL_ERROR_HPP 12 : 13 : #include <boost/core/detail/string_view.hpp> 14 : #include <boost/system/error_category.hpp> 15 : #include <boost/system/is_error_code_enum.hpp> 16 : #include <boost/system/is_error_condition_enum.hpp> 17 : 18 : namespace boost { 19 : 20 : namespace system { 21 : 22 : template<> 23 : struct is_error_code_enum< 24 : ::boost::http_proto::error> 25 : { 26 : static bool const value = true; 27 : }; 28 : 29 : template<> 30 : struct is_error_condition_enum< 31 : ::boost::http_proto::condition> 32 : { 33 : static bool const value = true; 34 : }; 35 : 36 : } // system 37 : 38 : //----------------------------------------------- 39 : 40 : namespace http_proto { 41 : 42 : namespace detail { 43 : 44 : struct BOOST_SYMBOL_VISIBLE 45 : error_cat_type 46 : : system::error_category 47 : { 48 : BOOST_HTTP_PROTO_DECL const char* name( 49 : ) const noexcept override; 50 : BOOST_HTTP_PROTO_DECL std::string message( 51 : int) const override; 52 : BOOST_HTTP_PROTO_DECL char const* message( 53 : int, char*, std::size_t 54 : ) const noexcept override; 55 11 : BOOST_SYSTEM_CONSTEXPR error_cat_type() 56 11 : : error_category(0x3663257e7585fbfd) 57 : { 58 11 : } 59 : }; 60 : 61 : struct BOOST_SYMBOL_VISIBLE 62 : condition_cat_type 63 : : system::error_category 64 : { 65 : BOOST_HTTP_PROTO_DECL const char* name( 66 : ) const noexcept override; 67 : BOOST_HTTP_PROTO_DECL std::string message( 68 : int) const override; 69 : BOOST_HTTP_PROTO_DECL char const* message( 70 : int, char*, std::size_t 71 : ) const noexcept override; 72 : BOOST_HTTP_PROTO_DECL bool equivalent( 73 : system::error_code const&, int 74 : ) const noexcept override; 75 5 : BOOST_SYSTEM_CONSTEXPR condition_cat_type() 76 5 : : error_category(0xa36e10f16c666a7) 77 : { 78 5 : } 79 : }; 80 : 81 : } // detail 82 : 83 : inline 84 : system::error_code 85 42810 : make_error_code( 86 : error ev) noexcept 87 : { 88 : static BOOST_SYSTEM_CONSTEXPR 89 42810 : detail::error_cat_type cat{}; 90 : return system::error_code{ 91 : static_cast<std::underlying_type< 92 42810 : error>::type>(ev), cat}; 93 : } 94 : 95 : inline 96 : system::error_condition 97 87663 : make_error_condition( 98 : condition c) noexcept 99 : { 100 : static BOOST_SYSTEM_CONSTEXPR 101 87663 : detail::condition_cat_type cat{}; 102 87663 : return system::error_condition{ 103 : static_cast<std::underlying_type< 104 87663 : condition>::type>(c), cat}; 105 : } 106 : 107 : } // http_proto 108 : } // boost 109 : 110 : #endif