system_category_posix.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. // POSIX-specific implementation details of system_error_category
  2. //
  3. // Copyright 2018 Peter Dimov
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See accompanying
  6. // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. //
  8. // See library home page at http://www.boost.org/libs/system
  9. namespace boost
  10. {
  11. namespace system
  12. {
  13. namespace detail
  14. {
  15. inline bool is_generic_value( int ev ) BOOST_NOEXCEPT
  16. {
  17. using namespace errc;
  18. static int const gen[] =
  19. {
  20. success,
  21. address_family_not_supported,
  22. address_in_use,
  23. address_not_available,
  24. already_connected,
  25. argument_list_too_long,
  26. argument_out_of_domain,
  27. bad_address,
  28. bad_file_descriptor,
  29. bad_message,
  30. broken_pipe,
  31. connection_aborted,
  32. connection_already_in_progress,
  33. connection_refused,
  34. connection_reset,
  35. cross_device_link,
  36. destination_address_required,
  37. device_or_resource_busy,
  38. directory_not_empty,
  39. executable_format_error,
  40. file_exists,
  41. file_too_large,
  42. filename_too_long,
  43. function_not_supported,
  44. host_unreachable,
  45. identifier_removed,
  46. illegal_byte_sequence,
  47. inappropriate_io_control_operation,
  48. interrupted,
  49. invalid_argument,
  50. invalid_seek,
  51. io_error,
  52. is_a_directory,
  53. message_size,
  54. network_down,
  55. network_reset,
  56. network_unreachable,
  57. no_buffer_space,
  58. no_child_process,
  59. no_link,
  60. no_lock_available,
  61. no_message_available,
  62. no_message,
  63. no_protocol_option,
  64. no_space_on_device,
  65. no_stream_resources,
  66. no_such_device_or_address,
  67. no_such_device,
  68. no_such_file_or_directory,
  69. no_such_process,
  70. not_a_directory,
  71. not_a_socket,
  72. not_a_stream,
  73. not_connected,
  74. not_enough_memory,
  75. not_supported,
  76. operation_canceled,
  77. operation_in_progress,
  78. operation_not_permitted,
  79. operation_not_supported,
  80. operation_would_block,
  81. owner_dead,
  82. permission_denied,
  83. protocol_error,
  84. protocol_not_supported,
  85. read_only_file_system,
  86. resource_deadlock_would_occur,
  87. resource_unavailable_try_again,
  88. result_out_of_range,
  89. state_not_recoverable,
  90. stream_timeout,
  91. text_file_busy,
  92. timed_out,
  93. too_many_files_open_in_system,
  94. too_many_files_open,
  95. too_many_links,
  96. too_many_symbolic_link_levels,
  97. value_too_large,
  98. wrong_protocol_type
  99. };
  100. int const n = sizeof( gen ) / sizeof( gen[0] );
  101. for( int i = 0; i < n; ++i )
  102. {
  103. if( ev == gen[ i ] ) return true;
  104. }
  105. return false;
  106. }
  107. inline error_condition system_category_default_error_condition_posix( int ev ) BOOST_NOEXCEPT
  108. {
  109. if( is_generic_value( ev ) )
  110. {
  111. return error_condition( ev, generic_category() );
  112. }
  113. else
  114. {
  115. return error_condition( ev, system_category() );
  116. }
  117. }
  118. } // namespace detail
  119. } // namespace system
  120. } // namespace boost