PageRenderTime 1005ms CodeModel.GetById 36ms RepoModel.GetById 0ms app.codeStats 0ms

/QtXiangqi/lib/asio-1.4.1/include/asio/error.hpp

http://hoxchess.googlecode.com/
C++ Header | 260 lines | 140 code | 62 blank | 58 comment | 2 complexity | 38364466967036259dcbfbff9d548b49 MD5 | raw file
Possible License(s): GPL-3.0
  1. //
  2. // error.hpp
  3. // ~~~~~~~~~
  4. //
  5. // Copyright (c) 2003-2008 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_ERROR_HPP
  11. #define ASIO_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/push_options.hpp"
  16. #include "asio/detail/push_options.hpp"
  17. #include <cerrno>
  18. #include <boost/config.hpp>
  19. #include "asio/detail/pop_options.hpp"
  20. #include "asio/error_code.hpp"
  21. #include "asio/detail/socket_types.hpp"
  22. #if defined(GENERATING_DOCUMENTATION)
  23. /// INTERNAL ONLY.
  24. # define ASIO_NATIVE_ERROR(e) implementation_defined
  25. /// INTERNAL ONLY.
  26. # define ASIO_SOCKET_ERROR(e) implementation_defined
  27. /// INTERNAL ONLY.
  28. # define ASIO_NETDB_ERROR(e) implementation_defined
  29. /// INTERNAL ONLY.
  30. # define ASIO_GETADDRINFO_ERROR(e) implementation_defined
  31. /// INTERNAL ONLY.
  32. # define ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined
  33. #elif defined(BOOST_WINDOWS) || defined(__CYGWIN__)
  34. # define ASIO_NATIVE_ERROR(e) e
  35. # define ASIO_SOCKET_ERROR(e) WSA ## e
  36. # define ASIO_NETDB_ERROR(e) WSA ## e
  37. # define ASIO_GETADDRINFO_ERROR(e) WSA ## e
  38. # define ASIO_WIN_OR_POSIX(e_win, e_posix) e_win
  39. #else
  40. # define ASIO_NATIVE_ERROR(e) e
  41. # define ASIO_SOCKET_ERROR(e) e
  42. # define ASIO_NETDB_ERROR(e) e
  43. # define ASIO_GETADDRINFO_ERROR(e) e
  44. # define ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix
  45. #endif
  46. namespace asio {
  47. namespace error {
  48. enum basic_errors
  49. {
  50. /// Permission denied.
  51. access_denied = ASIO_SOCKET_ERROR(EACCES),
  52. /// Address family not supported by protocol.
  53. address_family_not_supported = ASIO_SOCKET_ERROR(EAFNOSUPPORT),
  54. /// Address already in use.
  55. address_in_use = ASIO_SOCKET_ERROR(EADDRINUSE),
  56. /// Transport endpoint is already connected.
  57. already_connected = ASIO_SOCKET_ERROR(EISCONN),
  58. /// Operation already in progress.
  59. already_started = ASIO_SOCKET_ERROR(EALREADY),
  60. /// Broken pipe.
  61. broken_pipe = ASIO_WIN_OR_POSIX(
  62. ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE),
  63. ASIO_NATIVE_ERROR(EPIPE)),
  64. /// A connection has been aborted.
  65. connection_aborted = ASIO_SOCKET_ERROR(ECONNABORTED),
  66. /// Connection refused.
  67. connection_refused = ASIO_SOCKET_ERROR(ECONNREFUSED),
  68. /// Connection reset by peer.
  69. connection_reset = ASIO_SOCKET_ERROR(ECONNRESET),
  70. /// Bad file descriptor.
  71. bad_descriptor = ASIO_SOCKET_ERROR(EBADF),
  72. /// Bad address.
  73. fault = ASIO_SOCKET_ERROR(EFAULT),
  74. /// No route to host.
  75. host_unreachable = ASIO_SOCKET_ERROR(EHOSTUNREACH),
  76. /// Operation now in progress.
  77. in_progress = ASIO_SOCKET_ERROR(EINPROGRESS),
  78. /// Interrupted system call.
  79. interrupted = ASIO_SOCKET_ERROR(EINTR),
  80. /// Invalid argument.
  81. invalid_argument = ASIO_SOCKET_ERROR(EINVAL),
  82. /// Message too long.
  83. message_size = ASIO_SOCKET_ERROR(EMSGSIZE),
  84. /// The name was too long.
  85. name_too_long = ASIO_SOCKET_ERROR(ENAMETOOLONG),
  86. /// Network is down.
  87. network_down = ASIO_SOCKET_ERROR(ENETDOWN),
  88. /// Network dropped connection on reset.
  89. network_reset = ASIO_SOCKET_ERROR(ENETRESET),
  90. /// Network is unreachable.
  91. network_unreachable = ASIO_SOCKET_ERROR(ENETUNREACH),
  92. /// Too many open files.
  93. no_descriptors = ASIO_SOCKET_ERROR(EMFILE),
  94. /// No buffer space available.
  95. no_buffer_space = ASIO_SOCKET_ERROR(ENOBUFS),
  96. /// Cannot allocate memory.
  97. no_memory = ASIO_WIN_OR_POSIX(
  98. ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY),
  99. ASIO_NATIVE_ERROR(ENOMEM)),
  100. /// Operation not permitted.
  101. no_permission = ASIO_WIN_OR_POSIX(
  102. ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED),
  103. ASIO_NATIVE_ERROR(EPERM)),
  104. /// Protocol not available.
  105. no_protocol_option = ASIO_SOCKET_ERROR(ENOPROTOOPT),
  106. /// Transport endpoint is not connected.
  107. not_connected = ASIO_SOCKET_ERROR(ENOTCONN),
  108. /// Socket operation on non-socket.
  109. not_socket = ASIO_SOCKET_ERROR(ENOTSOCK),
  110. /// Operation cancelled.
  111. operation_aborted = ASIO_WIN_OR_POSIX(
  112. ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED),
  113. ASIO_NATIVE_ERROR(ECANCELED)),
  114. /// Operation not supported.
  115. operation_not_supported = ASIO_SOCKET_ERROR(EOPNOTSUPP),
  116. /// Cannot send after transport endpoint shutdown.
  117. shut_down = ASIO_SOCKET_ERROR(ESHUTDOWN),
  118. /// Connection timed out.
  119. timed_out = ASIO_SOCKET_ERROR(ETIMEDOUT),
  120. /// Resource temporarily unavailable.
  121. try_again = ASIO_WIN_OR_POSIX(
  122. ASIO_NATIVE_ERROR(ERROR_RETRY),
  123. ASIO_NATIVE_ERROR(EAGAIN)),
  124. /// The socket is marked non-blocking and the requested operation would block.
  125. would_block = ASIO_SOCKET_ERROR(EWOULDBLOCK)
  126. };
  127. enum netdb_errors
  128. {
  129. /// Host not found (authoritative).
  130. host_not_found = ASIO_NETDB_ERROR(HOST_NOT_FOUND),
  131. /// Host not found (non-authoritative).
  132. host_not_found_try_again = ASIO_NETDB_ERROR(TRY_AGAIN),
  133. /// The query is valid but does not have associated address data.
  134. no_data = ASIO_NETDB_ERROR(NO_DATA),
  135. /// A non-recoverable error occurred.
  136. no_recovery = ASIO_NETDB_ERROR(NO_RECOVERY)
  137. };
  138. enum addrinfo_errors
  139. {
  140. /// The service is not supported for the given socket type.
  141. service_not_found = ASIO_WIN_OR_POSIX(
  142. ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND),
  143. ASIO_GETADDRINFO_ERROR(EAI_SERVICE)),
  144. /// The socket type is not supported.
  145. socket_type_not_supported = ASIO_WIN_OR_POSIX(
  146. ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT),
  147. ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE))
  148. };
  149. enum misc_errors
  150. {
  151. /// Already open.
  152. already_open = 1,
  153. /// End of file or stream.
  154. eof,
  155. /// Element not found.
  156. not_found,
  157. /// The descriptor cannot fit into the select system call's fd_set.
  158. fd_set_failure
  159. };
  160. enum ssl_errors
  161. {
  162. };
  163. // boostify: error category definitions go here.
  164. inline asio::error_code make_error_code(basic_errors e)
  165. {
  166. return asio::error_code(
  167. static_cast<int>(e), get_system_category());
  168. }
  169. inline asio::error_code make_error_code(netdb_errors e)
  170. {
  171. return asio::error_code(
  172. static_cast<int>(e), get_netdb_category());
  173. }
  174. inline asio::error_code make_error_code(addrinfo_errors e)
  175. {
  176. return asio::error_code(
  177. static_cast<int>(e), get_addrinfo_category());
  178. }
  179. inline asio::error_code make_error_code(misc_errors e)
  180. {
  181. return asio::error_code(
  182. static_cast<int>(e), get_misc_category());
  183. }
  184. inline asio::error_code make_error_code(ssl_errors e)
  185. {
  186. return asio::error_code(
  187. static_cast<int>(e), get_ssl_category());
  188. }
  189. } // namespace error
  190. } // namespace asio
  191. #undef ASIO_NATIVE_ERROR
  192. #undef ASIO_SOCKET_ERROR
  193. #undef ASIO_NETDB_ERROR
  194. #undef ASIO_GETADDRINFO_ERROR
  195. #undef ASIO_WIN_OR_POSIX
  196. #include "asio/impl/error_code.ipp"
  197. #include "asio/detail/pop_options.hpp"
  198. #endif // ASIO_ERROR_HPP