channel_error.hpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. //
  2. // experimental/channel_error.hpp
  3. // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2024 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. #ifndef BOOST_ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP
  11. #define BOOST_ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP
  12. #if defined(_MSC_VER) && (_MSC_VER >= 1200)
  13. # pragma once
  14. #endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
  15. #include <boost/asio/detail/config.hpp>
  16. #include <boost/system/error_code.hpp>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace experimental {
  21. namespace error {
  22. enum channel_errors
  23. {
  24. /// The channel was closed.
  25. channel_closed = 1,
  26. /// The channel was cancelled.
  27. channel_cancelled = 2
  28. };
  29. extern BOOST_ASIO_DECL
  30. const boost::system::error_category& get_channel_category();
  31. static const boost::system::error_category&
  32. channel_category BOOST_ASIO_UNUSED_VARIABLE
  33. = boost::asio::experimental::error::get_channel_category();
  34. } // namespace error
  35. namespace channel_errc {
  36. // Simulates a scoped enum.
  37. using error::channel_closed;
  38. using error::channel_cancelled;
  39. } // namespace channel_errc
  40. } // namespace experimental
  41. } // namespace asio
  42. } // namespace boost
  43. namespace boost {
  44. namespace system {
  45. template<> struct is_error_code_enum<
  46. boost::asio::experimental::error::channel_errors>
  47. {
  48. static const bool value = true;
  49. };
  50. } // namespace system
  51. } // namespace boost
  52. namespace boost {
  53. namespace asio {
  54. namespace experimental {
  55. namespace error {
  56. inline boost::system::error_code make_error_code(channel_errors e)
  57. {
  58. return boost::system::error_code(
  59. static_cast<int>(e), get_channel_category());
  60. }
  61. } // namespace error
  62. } // namespace experimental
  63. } // namespace asio
  64. } // namespace boost
  65. #include <boost/asio/detail/pop_options.hpp>
  66. #if defined(BOOST_ASIO_HEADER_ONLY)
  67. # include <boost/asio/experimental/impl/channel_error.ipp>
  68. #endif // defined(BOOST_ASIO_HEADER_ONLY)
  69. #endif // BOOST_ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP