system_category_impl.hpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
  2. #define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED
  3. // Copyright Beman Dawes 2006, 2007
  4. // Copyright Christoper Kohlhoff 2007
  5. // Copyright Peter Dimov 2017, 2018, 2020
  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. // See library home page at http://www.boost.org/libs/system
  11. #include <boost/system/detail/system_category.hpp>
  12. #include <boost/system/detail/system_category_message.hpp>
  13. #include <boost/system/detail/error_condition.hpp>
  14. #include <boost/system/api_config.hpp>
  15. #if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
  16. # error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
  17. #endif
  18. // system_error_category implementation
  19. #if defined(BOOST_WINDOWS_API)
  20. #include <boost/system/detail/system_category_condition_win32.hpp>
  21. inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const noexcept
  22. {
  23. int e2 = system_category_condition_win32( ev );
  24. if( e2 == -1 )
  25. {
  26. return error_condition( ev, *this );
  27. }
  28. else
  29. {
  30. return error_condition( boost::system::detail::generic_value_tag( e2 ) );
  31. }
  32. }
  33. #else // #if defined(BOOST_WINDOWS_API)
  34. inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const noexcept
  35. {
  36. return error_condition( boost::system::detail::generic_value_tag( ev ) );
  37. }
  38. #endif // #if defined(BOOST_WINDOWS_API)
  39. inline std::string boost::system::detail::system_error_category::message( int ev ) const
  40. {
  41. return system_error_category_message( ev );
  42. }
  43. inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const noexcept
  44. {
  45. return system_error_category_message( ev, buffer, len );
  46. }
  47. #endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED