Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/generic/include/boost/asio/error.hpp @ 16:2665513ce2d3
Add boost headers
author | Chris Cannam |
---|---|
date | Tue, 05 Aug 2014 11:11:38 +0100 |
parents | |
children | c530137014c0 |
comparison
equal
deleted
inserted
replaced
15:663ca0da4350 | 16:2665513ce2d3 |
---|---|
1 // | |
2 // error.hpp | |
3 // ~~~~~~~~~ | |
4 // | |
5 // Copyright (c) 2003-2013 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 BOOST_ASIO_ERROR_HPP | |
12 #define BOOST_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 <boost/asio/detail/config.hpp> | |
19 #include <boost/cerrno.hpp> | |
20 #include <boost/system/error_code.hpp> | |
21 #if defined(BOOST_ASIO_WINDOWS) \ | |
22 || defined(__CYGWIN__) \ | |
23 || defined(BOOST_ASIO_WINDOWS_RUNTIME) | |
24 # include <winerror.h> | |
25 #else | |
26 # include <cerrno> | |
27 # include <netdb.h> | |
28 #endif | |
29 | |
30 #if defined(GENERATING_DOCUMENTATION) | |
31 /// INTERNAL ONLY. | |
32 # define BOOST_ASIO_NATIVE_ERROR(e) implementation_defined | |
33 /// INTERNAL ONLY. | |
34 # define BOOST_ASIO_SOCKET_ERROR(e) implementation_defined | |
35 /// INTERNAL ONLY. | |
36 # define BOOST_ASIO_NETDB_ERROR(e) implementation_defined | |
37 /// INTERNAL ONLY. | |
38 # define BOOST_ASIO_GETADDRINFO_ERROR(e) implementation_defined | |
39 /// INTERNAL ONLY. | |
40 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) implementation_defined | |
41 #elif defined(BOOST_ASIO_WINDOWS_RUNTIME) | |
42 # define BOOST_ASIO_NATIVE_ERROR(e) __HRESULT_FROM_WIN32(e) | |
43 # define BOOST_ASIO_SOCKET_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e) | |
44 # define BOOST_ASIO_NETDB_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e) | |
45 # define BOOST_ASIO_GETADDRINFO_ERROR(e) __HRESULT_FROM_WIN32(WSA ## e) | |
46 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win | |
47 #elif defined(BOOST_ASIO_WINDOWS) || defined(__CYGWIN__) | |
48 # define BOOST_ASIO_NATIVE_ERROR(e) e | |
49 # define BOOST_ASIO_SOCKET_ERROR(e) WSA ## e | |
50 # define BOOST_ASIO_NETDB_ERROR(e) WSA ## e | |
51 # define BOOST_ASIO_GETADDRINFO_ERROR(e) WSA ## e | |
52 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_win | |
53 #else | |
54 # define BOOST_ASIO_NATIVE_ERROR(e) e | |
55 # define BOOST_ASIO_SOCKET_ERROR(e) e | |
56 # define BOOST_ASIO_NETDB_ERROR(e) e | |
57 # define BOOST_ASIO_GETADDRINFO_ERROR(e) e | |
58 # define BOOST_ASIO_WIN_OR_POSIX(e_win, e_posix) e_posix | |
59 #endif | |
60 | |
61 #include <boost/asio/detail/push_options.hpp> | |
62 | |
63 namespace boost { | |
64 namespace asio { | |
65 namespace error { | |
66 | |
67 enum basic_errors | |
68 { | |
69 /// Permission denied. | |
70 access_denied = BOOST_ASIO_SOCKET_ERROR(EACCES), | |
71 | |
72 /// Address family not supported by protocol. | |
73 address_family_not_supported = BOOST_ASIO_SOCKET_ERROR(EAFNOSUPPORT), | |
74 | |
75 /// Address already in use. | |
76 address_in_use = BOOST_ASIO_SOCKET_ERROR(EADDRINUSE), | |
77 | |
78 /// Transport endpoint is already connected. | |
79 already_connected = BOOST_ASIO_SOCKET_ERROR(EISCONN), | |
80 | |
81 /// Operation already in progress. | |
82 already_started = BOOST_ASIO_SOCKET_ERROR(EALREADY), | |
83 | |
84 /// Broken pipe. | |
85 broken_pipe = BOOST_ASIO_WIN_OR_POSIX( | |
86 BOOST_ASIO_NATIVE_ERROR(ERROR_BROKEN_PIPE), | |
87 BOOST_ASIO_NATIVE_ERROR(EPIPE)), | |
88 | |
89 /// A connection has been aborted. | |
90 connection_aborted = BOOST_ASIO_SOCKET_ERROR(ECONNABORTED), | |
91 | |
92 /// Connection refused. | |
93 connection_refused = BOOST_ASIO_SOCKET_ERROR(ECONNREFUSED), | |
94 | |
95 /// Connection reset by peer. | |
96 connection_reset = BOOST_ASIO_SOCKET_ERROR(ECONNRESET), | |
97 | |
98 /// Bad file descriptor. | |
99 bad_descriptor = BOOST_ASIO_SOCKET_ERROR(EBADF), | |
100 | |
101 /// Bad address. | |
102 fault = BOOST_ASIO_SOCKET_ERROR(EFAULT), | |
103 | |
104 /// No route to host. | |
105 host_unreachable = BOOST_ASIO_SOCKET_ERROR(EHOSTUNREACH), | |
106 | |
107 /// Operation now in progress. | |
108 in_progress = BOOST_ASIO_SOCKET_ERROR(EINPROGRESS), | |
109 | |
110 /// Interrupted system call. | |
111 interrupted = BOOST_ASIO_SOCKET_ERROR(EINTR), | |
112 | |
113 /// Invalid argument. | |
114 invalid_argument = BOOST_ASIO_SOCKET_ERROR(EINVAL), | |
115 | |
116 /// Message too long. | |
117 message_size = BOOST_ASIO_SOCKET_ERROR(EMSGSIZE), | |
118 | |
119 /// The name was too long. | |
120 name_too_long = BOOST_ASIO_SOCKET_ERROR(ENAMETOOLONG), | |
121 | |
122 /// Network is down. | |
123 network_down = BOOST_ASIO_SOCKET_ERROR(ENETDOWN), | |
124 | |
125 /// Network dropped connection on reset. | |
126 network_reset = BOOST_ASIO_SOCKET_ERROR(ENETRESET), | |
127 | |
128 /// Network is unreachable. | |
129 network_unreachable = BOOST_ASIO_SOCKET_ERROR(ENETUNREACH), | |
130 | |
131 /// Too many open files. | |
132 no_descriptors = BOOST_ASIO_SOCKET_ERROR(EMFILE), | |
133 | |
134 /// No buffer space available. | |
135 no_buffer_space = BOOST_ASIO_SOCKET_ERROR(ENOBUFS), | |
136 | |
137 /// Cannot allocate memory. | |
138 no_memory = BOOST_ASIO_WIN_OR_POSIX( | |
139 BOOST_ASIO_NATIVE_ERROR(ERROR_OUTOFMEMORY), | |
140 BOOST_ASIO_NATIVE_ERROR(ENOMEM)), | |
141 | |
142 /// Operation not permitted. | |
143 no_permission = BOOST_ASIO_WIN_OR_POSIX( | |
144 BOOST_ASIO_NATIVE_ERROR(ERROR_ACCESS_DENIED), | |
145 BOOST_ASIO_NATIVE_ERROR(EPERM)), | |
146 | |
147 /// Protocol not available. | |
148 no_protocol_option = BOOST_ASIO_SOCKET_ERROR(ENOPROTOOPT), | |
149 | |
150 /// Transport endpoint is not connected. | |
151 not_connected = BOOST_ASIO_SOCKET_ERROR(ENOTCONN), | |
152 | |
153 /// Socket operation on non-socket. | |
154 not_socket = BOOST_ASIO_SOCKET_ERROR(ENOTSOCK), | |
155 | |
156 /// Operation cancelled. | |
157 operation_aborted = BOOST_ASIO_WIN_OR_POSIX( | |
158 BOOST_ASIO_NATIVE_ERROR(ERROR_OPERATION_ABORTED), | |
159 BOOST_ASIO_NATIVE_ERROR(ECANCELED)), | |
160 | |
161 /// Operation not supported. | |
162 operation_not_supported = BOOST_ASIO_SOCKET_ERROR(EOPNOTSUPP), | |
163 | |
164 /// Cannot send after transport endpoint shutdown. | |
165 shut_down = BOOST_ASIO_SOCKET_ERROR(ESHUTDOWN), | |
166 | |
167 /// Connection timed out. | |
168 timed_out = BOOST_ASIO_SOCKET_ERROR(ETIMEDOUT), | |
169 | |
170 /// Resource temporarily unavailable. | |
171 try_again = BOOST_ASIO_WIN_OR_POSIX( | |
172 BOOST_ASIO_NATIVE_ERROR(ERROR_RETRY), | |
173 BOOST_ASIO_NATIVE_ERROR(EAGAIN)), | |
174 | |
175 /// The socket is marked non-blocking and the requested operation would block. | |
176 would_block = BOOST_ASIO_SOCKET_ERROR(EWOULDBLOCK) | |
177 }; | |
178 | |
179 enum netdb_errors | |
180 { | |
181 /// Host not found (authoritative). | |
182 host_not_found = BOOST_ASIO_NETDB_ERROR(HOST_NOT_FOUND), | |
183 | |
184 /// Host not found (non-authoritative). | |
185 host_not_found_try_again = BOOST_ASIO_NETDB_ERROR(TRY_AGAIN), | |
186 | |
187 /// The query is valid but does not have associated address data. | |
188 no_data = BOOST_ASIO_NETDB_ERROR(NO_DATA), | |
189 | |
190 /// A non-recoverable error occurred. | |
191 no_recovery = BOOST_ASIO_NETDB_ERROR(NO_RECOVERY) | |
192 }; | |
193 | |
194 enum addrinfo_errors | |
195 { | |
196 /// The service is not supported for the given socket type. | |
197 service_not_found = BOOST_ASIO_WIN_OR_POSIX( | |
198 BOOST_ASIO_NATIVE_ERROR(WSATYPE_NOT_FOUND), | |
199 BOOST_ASIO_GETADDRINFO_ERROR(EAI_SERVICE)), | |
200 | |
201 /// The socket type is not supported. | |
202 socket_type_not_supported = BOOST_ASIO_WIN_OR_POSIX( | |
203 BOOST_ASIO_NATIVE_ERROR(WSAESOCKTNOSUPPORT), | |
204 BOOST_ASIO_GETADDRINFO_ERROR(EAI_SOCKTYPE)) | |
205 }; | |
206 | |
207 enum misc_errors | |
208 { | |
209 /// Already open. | |
210 already_open = 1, | |
211 | |
212 /// End of file or stream. | |
213 eof, | |
214 | |
215 /// Element not found. | |
216 not_found, | |
217 | |
218 /// The descriptor cannot fit into the select system call's fd_set. | |
219 fd_set_failure | |
220 }; | |
221 | |
222 inline const boost::system::error_category& get_system_category() | |
223 { | |
224 return boost::system::system_category(); | |
225 } | |
226 | |
227 #if !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__) | |
228 | |
229 extern BOOST_ASIO_DECL | |
230 const boost::system::error_category& get_netdb_category(); | |
231 | |
232 extern BOOST_ASIO_DECL | |
233 const boost::system::error_category& get_addrinfo_category(); | |
234 | |
235 #else // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__) | |
236 | |
237 inline const boost::system::error_category& get_netdb_category() | |
238 { | |
239 return get_system_category(); | |
240 } | |
241 | |
242 inline const boost::system::error_category& get_addrinfo_category() | |
243 { | |
244 return get_system_category(); | |
245 } | |
246 | |
247 #endif // !defined(BOOST_ASIO_WINDOWS) && !defined(__CYGWIN__) | |
248 | |
249 extern BOOST_ASIO_DECL | |
250 const boost::system::error_category& get_misc_category(); | |
251 | |
252 static const boost::system::error_category& system_category | |
253 = boost::asio::error::get_system_category(); | |
254 static const boost::system::error_category& netdb_category | |
255 = boost::asio::error::get_netdb_category(); | |
256 static const boost::system::error_category& addrinfo_category | |
257 = boost::asio::error::get_addrinfo_category(); | |
258 static const boost::system::error_category& misc_category | |
259 = boost::asio::error::get_misc_category(); | |
260 | |
261 } // namespace error | |
262 } // namespace asio | |
263 } // namespace boost | |
264 | |
265 namespace boost { | |
266 namespace system { | |
267 | |
268 template<> struct is_error_code_enum<boost::asio::error::basic_errors> | |
269 { | |
270 static const bool value = true; | |
271 }; | |
272 | |
273 template<> struct is_error_code_enum<boost::asio::error::netdb_errors> | |
274 { | |
275 static const bool value = true; | |
276 }; | |
277 | |
278 template<> struct is_error_code_enum<boost::asio::error::addrinfo_errors> | |
279 { | |
280 static const bool value = true; | |
281 }; | |
282 | |
283 template<> struct is_error_code_enum<boost::asio::error::misc_errors> | |
284 { | |
285 static const bool value = true; | |
286 }; | |
287 | |
288 } // namespace system | |
289 } // namespace boost | |
290 | |
291 namespace boost { | |
292 namespace asio { | |
293 namespace error { | |
294 | |
295 inline boost::system::error_code make_error_code(basic_errors e) | |
296 { | |
297 return boost::system::error_code( | |
298 static_cast<int>(e), get_system_category()); | |
299 } | |
300 | |
301 inline boost::system::error_code make_error_code(netdb_errors e) | |
302 { | |
303 return boost::system::error_code( | |
304 static_cast<int>(e), get_netdb_category()); | |
305 } | |
306 | |
307 inline boost::system::error_code make_error_code(addrinfo_errors e) | |
308 { | |
309 return boost::system::error_code( | |
310 static_cast<int>(e), get_addrinfo_category()); | |
311 } | |
312 | |
313 inline boost::system::error_code make_error_code(misc_errors e) | |
314 { | |
315 return boost::system::error_code( | |
316 static_cast<int>(e), get_misc_category()); | |
317 } | |
318 | |
319 } // namespace error | |
320 } // namespace asio | |
321 } // namespace boost | |
322 | |
323 #include <boost/asio/detail/pop_options.hpp> | |
324 | |
325 #undef BOOST_ASIO_NATIVE_ERROR | |
326 #undef BOOST_ASIO_SOCKET_ERROR | |
327 #undef BOOST_ASIO_NETDB_ERROR | |
328 #undef BOOST_ASIO_GETADDRINFO_ERROR | |
329 #undef BOOST_ASIO_WIN_OR_POSIX | |
330 | |
331 #if defined(BOOST_ASIO_HEADER_ONLY) | |
332 # include <boost/asio/impl/error.ipp> | |
333 #endif // defined(BOOST_ASIO_HEADER_ONLY) | |
334 | |
335 #endif // BOOST_ASIO_ERROR_HPP |