channel_error.hpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. #ifndef ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP
  11. #define 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 "asio/detail/config.hpp"
  16. #include "asio/error_code.hpp"
  17. #include "asio/detail/push_options.hpp"
  18. namespace asio {
  19. namespace experimental {
  20. namespace error {
  21. enum channel_errors
  22. {
  23. /// The channel was closed.
  24. channel_closed = 1,
  25. /// The channel was cancelled.
  26. channel_cancelled = 2
  27. };
  28. extern ASIO_DECL
  29. const asio::error_category& get_channel_category();
  30. static const asio::error_category&
  31. channel_category ASIO_UNUSED_VARIABLE
  32. = asio::experimental::error::get_channel_category();
  33. } // namespace error
  34. namespace channel_errc {
  35. // Simulates a scoped enum.
  36. using error::channel_closed;
  37. using error::channel_cancelled;
  38. } // namespace channel_errc
  39. } // namespace experimental
  40. } // namespace asio
  41. #if defined(ASIO_HAS_STD_SYSTEM_ERROR)
  42. namespace std {
  43. template<> struct is_error_code_enum<
  44. asio::experimental::error::channel_errors>
  45. {
  46. static const bool value = true;
  47. };
  48. } // namespace std
  49. #endif // defined(ASIO_HAS_STD_SYSTEM_ERROR)
  50. namespace asio {
  51. namespace experimental {
  52. namespace error {
  53. inline asio::error_code make_error_code(channel_errors e)
  54. {
  55. return asio::error_code(
  56. static_cast<int>(e), get_channel_category());
  57. }
  58. } // namespace error
  59. } // namespace experimental
  60. } // namespace asio
  61. #include "asio/detail/pop_options.hpp"
  62. #if defined(ASIO_HEADER_ONLY)
  63. # include "asio/experimental/impl/channel_error.ipp"
  64. #endif // defined(ASIO_HEADER_ONLY)
  65. #endif // ASIO_EXPERIMENTAL_CHANNEL_ERROR_HPP