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 : namespace detail {
42 :
43 : struct BOOST_SYMBOL_VISIBLE
44 : error_cat_type
45 : : system::error_category
46 : {
47 : BOOST_HTTP_PROTO_DECL
48 : const char* name() const noexcept override;
49 :
50 : BOOST_HTTP_PROTO_DECL
51 : std::string message(int) const override;
52 :
53 : BOOST_HTTP_PROTO_DECL
54 : char const* message(
55 : int, char*, std::size_t) const noexcept override;
56 :
57 : BOOST_SYSTEM_CONSTEXPR
58 49 : error_cat_type()
59 49 : : error_category(0x3663257e7585fbfd)
60 : {
61 49 : }
62 : };
63 :
64 : struct BOOST_SYMBOL_VISIBLE
65 : condition_cat_type
66 : : system::error_category
67 : {
68 : BOOST_HTTP_PROTO_DECL
69 : const char* name() const noexcept override;
70 :
71 : BOOST_HTTP_PROTO_DECL
72 : std::string message(int) const override;
73 :
74 : BOOST_HTTP_PROTO_DECL
75 : char const* message(
76 : int, char*, std::size_t) const noexcept override;
77 :
78 : BOOST_HTTP_PROTO_DECL
79 : bool equivalent(
80 : system::error_code const&,
81 : int) const noexcept override;
82 :
83 : BOOST_SYSTEM_CONSTEXPR
84 49 : condition_cat_type()
85 49 : : error_category(0xa36e10f16c666a7)
86 : {
87 49 : }
88 : };
89 :
90 : BOOST_HTTP_PROTO_DECL extern
91 : error_cat_type error_cat;
92 : BOOST_HTTP_PROTO_DECL extern
93 : condition_cat_type condition_cat;
94 :
95 : } // detail
96 :
97 : inline
98 : BOOST_SYSTEM_CONSTEXPR
99 : system::error_code
100 4543 : make_error_code(
101 : error ev) noexcept
102 : {
103 : return system::error_code{
104 : static_cast<std::underlying_type<
105 : error>::type>(ev),
106 4543 : detail::error_cat};
107 : }
108 :
109 : inline
110 : BOOST_SYSTEM_CONSTEXPR
111 : system::error_condition
112 11334 : make_error_condition(
113 : condition c) noexcept
114 : {
115 11334 : return system::error_condition{
116 : static_cast<std::underlying_type<
117 : condition>::type>(c),
118 11334 : detail::condition_cat};
119 : }
120 :
121 : } // http_proto
122 : } // boost
123 :
124 : #endif
|