]>
Commit | Line | Data |
---|---|---|
1e59de90 TL |
1 | // |
2 | // experimental/channel_error.hpp | |
3 | // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | |
4 | // | |
5 | // Copyright (c) 2003-2022 Christopher M. Kohlhoff (chris at kohlhoff dot com) | |
6 | // | |
7 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
8 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
9 | // | |
10 | ||
11 | #ifndef BOOST_ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP | |
12 | #define BOOST_ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP | |
13 | ||
14 | #if defined(_MSC_VER) && (_MSC_VER >= 1200) | |
15 | # pragma once | |
16 | #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) | |
17 | ||
18 | #include <boost/asio/detail/config.hpp> | |
19 | #include <boost/system/error_code.hpp> | |
20 | ||
21 | #include <boost/asio/detail/push_options.hpp> | |
22 | ||
23 | namespace boost { | |
24 | namespace asio { | |
25 | namespace experimental { | |
26 | namespace error { | |
27 | ||
28 | enum channel_errors | |
29 | { | |
30 | /// The channel was closed. | |
31 | channel_closed = 1, | |
32 | ||
33 | /// The channel was cancelled. | |
34 | channel_cancelled = 2 | |
35 | }; | |
36 | ||
37 | extern BOOST_ASIO_DECL | |
38 | const boost::system::error_category& get_channel_category(); | |
39 | ||
40 | static const boost::system::error_category& | |
41 | channel_category BOOST_ASIO_UNUSED_VARIABLE | |
42 | = boost::asio::experimental::error::get_channel_category(); | |
43 | ||
44 | } // namespace error | |
45 | namespace channel_errc { | |
46 | // Simulates a scoped enum. | |
47 | using error::channel_closed; | |
48 | using error::channel_cancelled; | |
49 | } // namespace channel_errc | |
50 | } // namespace experimental | |
51 | } // namespace asio | |
52 | } // namespace boost | |
53 | ||
54 | namespace boost { | |
55 | namespace system { | |
56 | ||
57 | template<> struct is_error_code_enum< | |
58 | boost::asio::experimental::error::channel_errors> | |
59 | { | |
60 | static const bool value = true; | |
61 | }; | |
62 | ||
63 | } // namespace system | |
64 | } // namespace boost | |
65 | ||
66 | namespace boost { | |
67 | namespace asio { | |
68 | namespace experimental { | |
69 | namespace error { | |
70 | ||
71 | inline boost::system::error_code make_error_code(channel_errors e) | |
72 | { | |
73 | return boost::system::error_code( | |
74 | static_cast<int>(e), get_channel_category()); | |
75 | } | |
76 | ||
77 | } // namespace error | |
78 | } // namespace experimental | |
79 | } // namespace asio | |
80 | } // namespace boost | |
81 | ||
82 | #include <boost/asio/detail/pop_options.hpp> | |
83 | ||
84 | #if defined(BOOST_ASIO_HEADER_ONLY) | |
85 | # include <boost/asio/experimental/impl/channel_error.ipp> | |
86 | #endif // defined(BOOST_ASIO_HEADER_ONLY) | |
87 | ||
88 | #endif // BOOST_ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP |