]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | <html> |
2 | ||
3 | <head> | |
4 | <meta http-equiv="Content-Language" content="en-us"> | |
5 | <meta name="GENERATOR" content="Microsoft FrontPage 5.0"> | |
6 | <meta name="ProgId" content="FrontPage.Editor.Document"> | |
7 | <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> | |
8 | <title>System Library Reference</title> | |
9 | <link rel="stylesheet" type="text/css" href="../../../doc/src/minimal.css"> | |
10 | </head> | |
11 | ||
12 | <body> | |
13 | ||
14 | <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="637"> | |
15 | <tr> | |
16 | <td width="277"> | |
17 | <a href="../../../index.htm"> | |
18 | <img src="../../../boost.png" alt="boost.png (6897 bytes)" align="middle" width="277" height="86" border="0"></a></td> | |
19 | <td width="337" align="middle"> | |
20 | <font size="7">System Library</font> | |
21 | </td> | |
22 | </tr> | |
23 | </table> | |
24 | ||
25 | <table border="0" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" bgcolor="#D7EEFF" width="100%"> | |
26 | <tr> | |
27 | <td><a href="../../../index.htm">Boost Home</a> <a href="index.html"> | |
28 | Library Home</a> Tutorial <a href="reference.html"> | |
29 | Reference</a></td> | |
30 | </tr> | |
31 | </table> | |
32 | ||
33 | <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" align="right"> | |
34 | <tr> | |
35 | <td width="100%" bgcolor="#D7EEFF" align="center"> | |
36 | <i><b>Contents</b></i></td> | |
37 | </tr> | |
38 | <tr> | |
39 | <td width="100%" bgcolor="#E8F5FF"> | |
40 | <a href="#Introduction">Introduction</a><br> | |
41 | <a href="#C++11">C++11</a><br> | |
42 | <a href="#Macros">Macros</a><br> | |
43 | <a href="#Deprecated-names">Deprecated names</a><br> | |
44 | <a href="#Breaking-changes">Breaking changes</a><br> | |
45 | <a href="#Header-error_code">Header <boost/system/error_code.hpp></a><br> | |
46 | <a href="#Class-error_category">Class <code>error_category</code></a><br> | |
47 | <a href="#Class-error_category-synopsis">Class <code>error_category</code> synopsis</a><br> | |
48 | <a href="#Class-error_category-virtual-members">Class <code>error_category</code> virtual members</a><br> | |
49 | <a href="#Class-error_category-non-virtual-members">Class <code>error_category</code> non-virtual members</a><br> | |
50 | <a href="#Class-error_category-non-member-functions">Class <code>error_category</code> | |
51 | non-member functions</a><br> | |
52 | <a href="#Class-error_category-predefined-objects">Class <code>error_category</code> predefined objects</a><br> | |
53 | <a href="#Class-error_code">Class <code>error_code</code></a><br> | |
54 | <a href="#Class-error_code-synopsis">Class <code>error_code</code> synopsis</a><br> | |
55 | <a href="#Class-error_code-constructors">Class <code>error_code</code> constructors</a><br> | |
56 | <a href="#Class-error_code-modifiers">Class <code>error_code</code> modifiers</a><br> | |
57 | <a href="#Class-error_code-observers">Class <code>error_code</code> observers</a><br> | |
58 | <a href="#Class-error_condition">Class <code>error_condition</code></a><br> | |
59 | <a href="#Class-error_condition-synopsis">Class <code>error_condition</code> synopsis</a><br> | |
60 | <a href="#Class-error_condition-constructors">Class <code>error_condition</code> constructors</a><br> | |
61 | <a href="#Class-error_condition-modifiers">Class <code>error_condition</code> modifiers</a><br> | |
62 | <a href="#Class-error_condition-observers">Class <code>error_condition</code> observers</a><br> | |
63 | <a href="#throws-object"><code>throws</code> object</a><br> | |
64 | <a href="#Semantics-of-throws">Semantics of <code>throws</code> object</a><br> | |
65 | <a href="#Non-member-functions">Non-member functions</a><br> | |
66 | <a href="#Header-system_error">Header <boost/system/system_error.hpp></a><br> | |
67 | <a href="#Class-system_error">Class <code>system_error</code></a><br> | |
68 | </td> | |
69 | </tr> | |
70 | </table> | |
71 | ||
72 | <h2><a name="Introduction">Introduction</a></h2> | |
73 | ||
74 | <p>This reference documentation describes components that programs may use to report error conditions originating from the operating | |
75 | system or other low-level application program interfaces.</p> | |
76 | <p>Boost.System library components never change the value of <code> | |
77 | errno</code>.</p> | |
78 | <h2><a name="C++11">C++11</a></h2> | |
79 | <p>The library is documented to use several C++11 features, including <code> | |
80 | noexcept</code> and explicit conversion operators. The actual implementation | |
81 | uses C++11 features only when they are available, and otherwise falls back on | |
82 | C++03 features.</p> | |
83 | <h2><a name="Macros">Macros</a></h2> | |
84 | <p>Users may defined the following macros if desired. Sensible defaults are | |
85 | provided, so users may ignore these macros if they prefer.</p> | |
86 | <table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" height="368"> | |
87 | <tr> | |
88 | <td height="16"><b><i>Macro Name</i></b></td> | |
89 | <td height="16"><b><i>Default</i></b></td> | |
90 | <td height="16"><b><i>Effect if defined</i></b></td> | |
91 | </tr> | |
92 | <tr> | |
93 | <td valign="top" height="64"><code>BOOST_ERROR_CODE_HEADER_ONLY</code></td> | |
94 | <td valign="top" height="64">Not defined.</td> | |
95 | <td valign="top" height="64">The implementation is header-only, and the | |
96 | Boost.System library is not built. Overrides other link and library macros.</td> | |
97 | </tr> | |
98 | <tr> | |
99 | <td valign="top" height="64"><code>BOOST_SYSTEM_DYN_LINK</code></td> | |
100 | <td valign="top" height="64">Defined if <code>BOOST_ALL_DYN_LINK</code> is defined, | |
101 | otherwise not defined.</td> | |
102 | <td valign="top" height="64">Boost.System library is dynamically linked. If not defined, | |
103 | static linking is assumed.</td> | |
104 | </tr> | |
105 | <tr> | |
106 | <td valign="top" height="47"><code>BOOST_SYSTEM_NO_LIB</code></td> | |
107 | <td valign="top" height="47">Defined if <code>BOOST_ALL_NO_LIB</code> is defined, | |
108 | otherwise not defined.</td> | |
109 | <td valign="top" height="47">Boost.System library does not use the Boost auto-link | |
110 | facility.</td> | |
111 | </tr> | |
112 | <tr> | |
113 | <td valign="top" height="32"><code>BOOST_SYSTEM_NO_DEPRECATED</code></td> | |
114 | <td valign="top" height="32">Not defined.</td> | |
115 | <td valign="top" height="32">Deprecated features are excluded.</td> | |
116 | </tr> | |
117 | </table> | |
118 | <h2><a name="Deprecated-names">Deprecated names</a></h2> | |
119 | <p>In the process of adding Boost.System to C++0x standard library, the C++ | |
120 | committee changed some | |
121 | names. To ease transition, Boost.System deprecates the old | |
122 | names, but continues to provide them unless macro <code>BOOST_SYSTEM_NO_DEPRECATED</code> | |
123 | is defined.</p> | |
124 | <table border="1" cellpadding="5" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111"> | |
125 | <tr> | |
126 | <td><b><i>Old usage, now deprecated</i></b></td> | |
127 | <td><b><i>Replacement</i></b></td> | |
128 | </tr> | |
129 | <tr> | |
130 | <td><code>get_generic_category()</code></td> | |
131 | <td><code>generic_category()</code></td> | |
132 | </tr> | |
133 | <tr> | |
134 | <td><code>get_system_category()</code></td> | |
135 | <td><code>system_category()</code></td> | |
136 | </tr> | |
137 | <tr> | |
138 | <td><code>namespace posix</code></td> | |
139 | <td><code>namespace errc</code></td> | |
140 | </tr> | |
141 | <tr> | |
142 | <td><code>namespace posix_error</code></td> | |
143 | <td><code>namespace errc</code></td> | |
144 | </tr> | |
145 | <tr> | |
146 | <td><code>enum posix_errno</code></td> | |
147 | <td><code>enum errc_t</code></td> | |
148 | </tr> | |
149 | <tr> | |
150 | <td><code>get_posix_category()</code></td> | |
151 | <td><code>generic_category()</code></td> | |
152 | </tr> | |
153 | <tr> | |
154 | <td><code>posix_category</code></td> | |
155 | <td><code>generic_category()</code></td> | |
156 | </tr> | |
157 | <tr> | |
158 | <td><code>errno_ecat</code></td> | |
159 | <td><code>generic_category()</code></td> | |
160 | </tr> | |
161 | <tr> | |
162 | <td><code>native_ecat</code></td> | |
163 | <td><code>system_category()</code></td> | |
164 | </tr> | |
165 | </table> | |
166 | <h2><a name="Breaking-changes">Breaking changes</a></h2> | |
167 | <p>Two static consts are replaced by functions. These are breaking changes best | |
168 | fixed by globally adding () to these names to turn them into function calls.</p> | |
169 | <table border="1" cellpadding="5" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111"> | |
170 | <tr> | |
171 | <td><b><i>Old usage, now broken</i></b></td> | |
172 | <td><b><i>Replacement</i></b></td> | |
173 | </tr> | |
174 | <tr> | |
175 | <td><code>generic_category</code></td> | |
176 | <td><code>generic_category()</code></td> | |
177 | </tr> | |
178 | <tr> | |
179 | <td><code>system_category</code></td> | |
180 | <td><code>system_category()</code></td> | |
181 | </tr> | |
182 | </table> | |
183 | <p>User-defined BOOST_POSIX_API and BOOST_WINDOWS_API macros are no longer supported.</p> | |
184 | <h2><a name="Header-error_code">Header <boost/system/error_code.hpp></a></h2> | |
185 | <h3><boost/system/error_code.hpp> synopsis</h3> | |
186 | <blockquote> | |
187 | <pre>namespace boost | |
188 | { | |
189 | namespace system | |
190 | { | |
191 | class <a href="#Class-error_category">error_category</a>; | |
192 | const error_category & <a href="#system_category">system_category</a>() noexcept; | |
193 | const error_category & <a href="#generic_category">generic_category</a>() noexcept; | |
194 | ||
195 | class <a href="#Class-error_code">error_code</a>; | |
196 | class <a href="#Class-error_condition">error_condition</a>; | |
197 | ||
198 | // "Concept" helpers | |
199 | template< class T="" > | |
200 | struct is_error_code_enum { static const bool value = false; }; | |
201 | ||
202 | template< class T="" > | |
203 | struct is_error_condition_enum { static const bool value = false; }; | |
204 | ||
205 | // generic error_conditions | |
206 | namespace errc | |
207 | { | |
208 | enum errc_t | |
209 | { | |
210 | success = 0, | |
211 | address_family_not_supported, //EAFNOSUPPORT | |
212 | address_in_use, //EADDRINUSE | |
213 | address_not_available, //EADDRNOTAVAIL | |
214 | already_connected, //EISCONN | |
215 | argument_list_too_long, //E2BIG | |
216 | argument_out_of_domain, //EDOM | |
217 | bad_address, //EFAULT | |
218 | bad_file_descriptor, //EBADF | |
219 | bad_message, //EBADMSG | |
220 | broken_pipe, //EPIPE | |
221 | connection_aborted, //ECONNABORTED | |
222 | connection_already_in_progress, //EALREADY | |
223 | connection_refused, //ECONNREFUSED | |
224 | connection_reset, //ECONNRESET | |
225 | cross_device_link, //EXDEV | |
226 | destination_address_required, //EDESTADDRREQ | |
227 | device_or_resource_busy, //EBUSY | |
228 | directory_not_empty, //ENOTEMPTY | |
229 | executable_format_error, //ENOEXEC | |
230 | file_exists, //EEXIST | |
231 | file_too_large, //EFBIG | |
232 | filename_too_long, //ENAMETOOLONG | |
233 | function_not_supported, //ENOSYS | |
234 | host_unreachable, //EHOSTUNREACH | |
235 | identifier_removed, //EIDRM | |
236 | illegal_byte_sequence, //EILSEQ | |
237 | inappropriate_io_control_operation,//ENOTTY | |
238 | interrupted, //EINTR | |
239 | invalid_argument, //EINVAL | |
240 | invalid_seek, //ESPIPE | |
241 | io_error, //EIO | |
242 | is_a_directory, //EISDIR | |
243 | message_size, //EMSGSIZE | |
244 | network_down, //ENETDOWN | |
245 | network_reset, //ENETRESET | |
246 | network_unreachable, //ENETUNREACH | |
247 | no_buffer_space, //ENOBUFS | |
248 | no_child_process, //ECHILD | |
249 | no_link, //ENOLINK | |
250 | no_lock_available, //ENOLCK | |
251 | no_message_available, //ENODATA | |
252 | no_message, //ENOMSG | |
253 | no_protocol_option, //ENOPROTOOPT | |
254 | no_space_on_device, //ENOSPC | |
255 | no_stream_resources, //ENOSR | |
256 | no_such_device_or_address, //ENXIO | |
257 | no_such_device, //ENODEV | |
258 | no_such_file_or_directory, //ENOENT | |
259 | no_such_process, //ESRCH | |
260 | not_a_directory, //ENOTDIR | |
261 | not_a_socket, //ENOTSOCK | |
262 | not_a_stream, //ENOSTR | |
263 | not_connected, //ENOTCONN | |
264 | not_enough_memory, //ENOMEM | |
265 | not_supported, //ENOTSUP | |
266 | operation_canceled, //ECANCELED | |
267 | operation_in_progress, //EINPROGRESS | |
268 | operation_not_permitted, //EPERM | |
269 | operation_not_supported, //EOPNOTSUPP | |
270 | operation_would_block, //EWOULDBLOCK | |
271 | owner_dead, //EOWNERDEAD | |
272 | permission_denied, //EACCES | |
273 | protocol_error, //EPROTO | |
274 | protocol_not_supported, //EPROTONOSUPPORT | |
275 | read_only_file_system, //EROFS | |
276 | resource_deadlock_would_occur, //EDEADLK | |
277 | resource_unavailable_try_again, //EAGAIN | |
278 | result_out_of_range, //ERANGE | |
279 | state_not_recoverable, //ENOTRECOVERABLE | |
280 | stream_timeout, //ETIME | |
281 | text_file_busy, //ETXTBSY | |
282 | timed_out, //ETIMEDOUT | |
283 | too_many_files_open_in_system, //ENFILE | |
284 | too_many_files_open, //EMFILE | |
285 | too_many_links, //EMLINK | |
286 | too_many_synbolic_link_levels, //ELOOP | |
287 | value_too_large, //EOVERFLOW | |
288 | wrong_protocol_type //EPROTOTYPE | |
289 | }; | |
290 | ||
291 | } // namespace errc | |
292 | ||
293 | template<> struct is_error_condition_enum<posix::posix_errno><errc::errc_t> | |
294 | { static const bool value = true; }; | |
295 | ||
296 | // <a href="#Non-member-functions">non-member functions</a> | |
297 | ||
298 | bool operator==( const error_code & lhs, const error_code & rhs ) noexcept; | |
299 | bool operator==( const error_code & code, const error_condition & condition ) noexcept; | |
300 | bool operator==( const error_condition & condition, const error_code & code ) noexcept; | |
301 | bool operator==( const error_condition & lhs, const error_condition & rhs ) noexcept; | |
302 | ||
303 | bool operator!=( const error_code & lhs, const error_code & rhs ) noexcept; | |
304 | bool operator!=( const error_code & code, const error_condition & condition ) noexcept; | |
305 | bool operator!=( const error_condition & condition, const error_code & code ) noexcept; | |
306 | bool operator!=( const error_condition & lhs, const error_condition & rhs ) noexcept; | |
307 | ||
308 | bool operator<( const error_code & lhs, const error_code & rhs ) noexcept; | |
309 | bool operator<( const error_condition & lhs, const error_condition & rhs ) noexcept; | |
310 | ||
311 | error_code make_error_code( errc::errc_t e ) noexcept; | |
312 | error_condition make_error_condition( errc::errc_t e ) noexcept; | |
313 | ||
314 | template <class charT, class traits> | |
315 | std::basic_ostream<charT,traits>& | |
316 | operator<<( basic_ostream<charT,traits>& os, const error_code & ec ); | |
317 | ||
318 | size_t hash_value( const error_code & ec ); | |
319 | } | |
320 | }</pre> | |
321 | </blockquote> | |
322 | <p>The value of each<code> errc_t</code> constant shall be the same as the | |
323 | value of the <code><cerrno></code> macro shown in the above synopsis.</p> | |
324 | <p>Users may specialize <code>is_error_code_enum</code> and <code> | |
325 | is_error_condition_enum</code> templates to indicate that a type is eligible for | |
326 | class <code>error_code</code> and <code>error_condition</code> automatic | |
327 | conversions respectively.</p> | |
328 | ||
329 | <pre>const error_category & <a name="system_category">system_category</a>();</pre> | |
330 | <blockquote> | |
331 | <p><i>Returns:</i> A reference to a <code>error_category</code> object | |
332 | identifying errors originating from the operating system.</p> | |
333 | </blockquote> | |
334 | <pre>const error_category & <a name="generic_category">generic_category</a>();</pre> | |
335 | <blockquote> | |
336 | <p><i>Returns:</i> A reference to a <code>error_category</code> object | |
337 | identifying portable error conditions.</p> | |
338 | </blockquote> | |
339 | ||
340 | <h2><a name="Class-error_category">Class <code>error_category</code></a></h2> | |
341 | <p>The class <code>error_category</code> defines the base class for types used | |
342 | to identify the source and encoding of a particular category of error code.</p> | |
343 | <p><i>[Note:</i> Classes may be derived from <code>error_category</code> | |
344 | to support additional categories of errors. <i>--end note]</i></p> | |
345 | <p>The class <code>error_category</code> serves as a base class for types used | |
346 | to identify the source and encoding of a particular category of error code. | |
347 | Classes may be derived from <code>error_category</code> to support categories of | |
348 | errors in addition to those defined in the Boost System library. Such classes | |
349 | shall behave as specified in this subclause. [<i> Note:</i> <code>error_category</code> | |
350 | objects are passed by reference, and two such objects are equal if they have the | |
351 | same address. This means that applications using custom <code>error_category</code> | |
352 |