channel_error.ipp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // experimental/impl/channel_error.ipp
  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_IMPL_CHANNEL_ERROR_IPP
  11. #define BOOST_ASIO_EXPERIMENTAL_IMPL_CHANNEL_ERROR_IPP
  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/asio/experimental/channel_error.hpp>
  17. #include <boost/asio/detail/push_options.hpp>
  18. namespace boost {
  19. namespace asio {
  20. namespace experimental {
  21. namespace error {
  22. namespace detail {
  23. class channel_category : public boost::system::error_category
  24. {
  25. public:
  26. const char* name() const noexcept
  27. {
  28. return "asio.channel";
  29. }
  30. std::string message(int value) const
  31. {
  32. switch (value)
  33. {
  34. case channel_closed: return "Channel closed";
  35. case channel_cancelled: return "Channel cancelled";
  36. default: return "asio.channel error";
  37. }
  38. }
  39. };
  40. } // namespace detail
  41. const boost::system::error_category& get_channel_category()
  42. {
  43. static detail::channel_category instance;
  44. return instance;
  45. }
  46. } // namespace error
  47. } // namespace experimental
  48. } // namespace asio
  49. } // namespace boost
  50. #include <boost/asio/detail/pop_options.hpp>
  51. #endif // BOOST_ASIO_EXPERIMENTAL_IMPL_CHANNEL_ERROR_IPP