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