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
8 : //
9 :
10 : #ifndef BOOST_HTTP_IMPL_ERROR_HPP
11 : #define BOOST_HTTP_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 : #include <system_error>
18 :
19 : namespace boost {
20 :
21 : namespace system {
22 :
23 : template<>
24 : struct is_error_code_enum<
25 : ::boost::http::error>
26 : {
27 : static bool const value = true;
28 : };
29 :
30 : template<>
31 : struct is_error_condition_enum<
32 : ::boost::http::condition>
33 : {
34 : static bool const value = true;
35 : };
36 :
37 : } // system
38 : } // boost
39 :
40 : namespace std {
41 : template<>
42 : struct is_error_code_enum<
43 : ::boost::http::error>
44 : : std::true_type {};
45 :
46 : template<>
47 : struct is_error_condition_enum<
48 : ::boost::http::condition>
49 : : std::true_type {};
50 : } // std
51 :
52 : namespace boost {
53 :
54 : //-----------------------------------------------
55 :
56 : namespace http {
57 :
58 : namespace detail {
59 :
60 : struct BOOST_HTTP_SYMBOL_VISIBLE
61 : error_cat_type
62 : : system::error_category
63 : {
64 : BOOST_HTTP_DECL const char* name(
65 : ) const noexcept override;
66 : BOOST_HTTP_DECL std::string message(
67 : int) const override;
68 : BOOST_HTTP_DECL char const* message(
69 : int, char*, std::size_t
70 : ) const noexcept override;
71 : BOOST_SYSTEM_CONSTEXPR error_cat_type()
72 : : error_category(0x3663257e7585fbfd)
73 : {
74 : }
75 : };
76 :
77 : struct BOOST_HTTP_SYMBOL_VISIBLE
78 : condition_cat_type
79 : : system::error_category
80 : {
81 : BOOST_HTTP_DECL const char* name(
82 : ) const noexcept override;
83 : BOOST_HTTP_DECL std::string message(
84 : int) const override;
85 : BOOST_HTTP_DECL char const* message(
86 : int, char*, std::size_t
87 : ) const noexcept override;
88 : BOOST_HTTP_DECL bool equivalent(
89 : system::error_code const&, int
90 : ) const noexcept override;
91 : BOOST_SYSTEM_CONSTEXPR condition_cat_type()
92 : : error_category(0xa36e10f16c666a7)
93 : {
94 : }
95 : };
96 :
97 : BOOST_HTTP_DECL extern
98 : error_cat_type error_cat;
99 : BOOST_HTTP_DECL extern
100 : condition_cat_type condition_cat;
101 :
102 : } // detail
103 :
104 : inline
105 : BOOST_SYSTEM_CONSTEXPR
106 : system::error_code
107 116301 : make_error_code(
108 : error ev) noexcept
109 : {
110 : return system::error_code{
111 : static_cast<std::underlying_type<
112 : error>::type>(ev),
113 116301 : detail::error_cat};
114 : }
115 :
116 : inline
117 : BOOST_SYSTEM_CONSTEXPR
118 : system::error_condition
119 120467 : make_error_condition(
120 : condition c) noexcept
121 : {
122 120467 : return system::error_condition{
123 : static_cast<std::underlying_type<
124 : condition>::type>(c),
125 120467 : detail::condition_cat};
126 : }
127 :
128 : } // http
129 : } // boost
130 :
131 : #endif
|