]>
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>Boost System Library</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"> | |
15 | <tr> | |
16 | <td width="277"> | |
17 | <a href="../../../index.html"> | |
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="#Release_History">Release History</a><br> | |
42 | <a href="#Design_Rationale">Design Rationale</a><br> | |
43 | <a href="#History">History</a><br> | |
44 | <a href="#Acknowledgements">Acknowledgements</a> | |
45 | </td> | |
46 | </tr> | |
47 | <tr> | |
48 | <td width="100%" bgcolor="#D7EEFF" align="center"> | |
49 | <b><i>Headers</i></b></td> | |
50 | </tr> | |
51 | <tr> | |
52 | <td width="100%" bgcolor="#E8F5FF"> | |
53 | <a href="reference.html#Header-error_code"><boost/system/error_code.hpp></a><br> | |
54 | <a href="reference.html#Header-system_error"> | |
55 | <boost/system/system_error.hpp></a><br> | |
56 | <a href="../../../boost/system/cygwin_error.hpp"> | |
57 | <boost/system/cygwin_error.hpp></a><br> | |
58 | <a href="../../../boost/system/linux_error.hpp"> | |
59 | <boost/system/linux_error.hpp></a><br> | |
60 | <a href="../../../boost/system/windows_error.hpp"> | |
61 | <boost/system/windows_error.hpp></a></td> | |
62 | </tr> | |
63 | </table> | |
64 | ||
65 | <h2><a name="Introduction">Introduction</a></h2> | |
66 | ||
67 | <p>Error conditions originating from the operating system or other low-level | |
68 | application program interfaces (API's) are typically reported via an integer | |
69 | representing an error code. When these low-level API calls are wrapped in | |
70 | portable code, such as in a portable library, some users want to deal with the | |
71 | error codes in portable ways. Other users need to get at the system specific | |
72 | error codes, so they can deal with system specific needs. The Boost System | |
73 | library provides simple, light-weight <a href="reference.html#Class-error_code"> | |
74 | error_code</a> objects that encapsulate system-specific error code values, yet | |
75 | also provide access to more abstract and portable error conditions via | |
76 | <a href="reference.html#Class-error_condition">error_condition</a> objects. | |
77 | Because error_code objects can represent errors from sources other than the | |
78 | operating system, including user-defined sources, each error_code and | |
79 | error_condition has an associated <a href="reference.html#Class-error_category"> | |
80 | error_category</a>.</p> | |
81 | ||
82 | <p>An exception class, <a href="reference.html#Class-system_error"> | |
83 | system_error</a>, is provided. Derived from std::runtime_error, it captures the | |
84 | underlying error_code for the problem causing the exception so that this | |
85 | important information is not lost.</p> | |
86 | <p>While exceptions are the preferred C++ default error code reporting | |
87 | mechanism, users of libraries dependent on low-level API's often need overloads | |
88 | reporting error conditions via error code arguments and/or return values rather | |
89 | than via throwing exceptions. Otherwise, when errors are not exceptional | |
90 | occurrences and must be dealt with as they arise, programs become littered with | |
91 | try/catch blocks, unreadable, and very inefficient. The Boost System library | |
92 | supports both error reporting by exception and by error code.</p> | |
93 | <p>In addition to portable errors codes and conditions supported by the <code> | |
94 | error_code.hpp</code> header, system-specific headers support the Cygwin, Linux, | |
95 | and Windows platforms. These headers are effectively no-ops if included for | |
96 | platforms other than their intended target.</p> | |
97 | <table border="1" cellpadding="10" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111"> | |
98 | <tr> | |
99 | <td>The Boost System Library is part of the C++11 Standard Library. | |
100 | A number of changes, particularly to names, were made by the C++ committee | |
101 | during standardization. The Boost implementation is tracking those changes. | |
102 | See <a href="reference.html#Deprecated-names">Deprecated names</a> for | |
103 | synonyms provided to prevent breakage of existing user code. See | |
104 | <a href="reference.html#Breaking-changes">Breaking changes</a> for changes | |
105 | that unavoidably break existing user code. All breaking changes are noisy | |
106 | and will cause compile-time errors.</td> | |
107 | </tr> | |
108 | </table> | |
109 | <h2><a name="Release_History">Release History</a></h2> | |
110 | <p><code>system-2014-06-02</code>: First modular Boost release. Minor | |
111 | maintenance changes.</p> | |
112 | <h2><a name="Design_Rationale">Design Rationale</a></h2> | |
113 | <p>Class <code>error_code</code> and <code>error_condition</code> are designed as a value types so | |
114 | they can be copied | |
115 | without slicing and do not requiring heap allocation, but still have polymorphic | |
116 | behavior based on the error category. This is achieved by abstract base class | |
117 | <code>error_category</code> supplying the polymorphic behavior, and <code> | |
118 | error_code</code> and <code>error_condition</code> containing a pointer to an object of a type derived from <code> | |
119 | error_category</code>.</p> | |
120 | <p>Many of the detailed design decisions were driven by the requirements that | |
121 | users to be able to add additional error categories, and that it be no more | |
122 | difficult to write portable code than system-specific code.</p> | |
123 | <p>The <code>operator<<</code> overload for <code>error_code</code> eliminates a | |
124 | misleading conversion to bool in code like <code>cout << ec</code>, where <code> | |
125 | ec</code> is of type <code>error_code</code>. It is also useful in its own | |
126 | right.</p> | |
127 | <h2><a name="History">History</a></h2> | |
128 | <p><a href="http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2006/n1975.html"> | |
129 | N1975</a>, Filesystem Library Proposal for TR2, accepted for Library Technical | |
130 | Report 2 (TR2) at the Berlin meeting, included additional components to | |
131 | supplement the Standard Library's Diagnostics clause. Since then, these error | |
132 | reporting components have received wider public scrutiny and enhancements have | |
133 | been made to the design. The enhanced version has been used by N2054, Networking | |
134 | Library Proposal for TR2, demonstrating that these error reporting components | |
135 | are useful beyond the original Filesystem Library.</p> | |
136 | <p>The original proposal viewed error categories as a binary choice between | |
137 | <code>errno</code> (i.e. POSIX-style) and the native operating system's error | |
138 | codes. The proposed components now allow as many additional error categories as | |
139 | are needed by either implementations or by users. The need to support additional | |
140 | error categories, for example, occurs in some networking library implementations | |
141 | because they are built on top of the POSIX <code>getaddrinfo</code> API that | |
142 | uses error codes not based on <code>errno</code>.</p> | |
143 | <h2><a name="Acknowledgements">Acknowledgements</a></h2> | |
144 | <p>Christopher Kohlhoff and Peter Dimov made important contributions to the | |
145 | design. Comments and suggestions were also received from Pavel Vozenilek, | |
146 | Gennaro Prota, Dave Abrahams, Jeff Garland, Iain Hanson, Oliver Kowalke, and | |
147 | Oleg Abrosimov. Christopher Kohlhoff suggested several improvements to the N2066 | |
148 | paper. Johan Nilsson's comments led to several of the refinements in N2066 .</p> | |
149 | <hr> | |
150 | ||
151 | <p>Revised | |
152 | <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->June 02, 2014<!--webbot bot="Timestamp" endspan i-checksum="13984" --> </font> | |
153 | </p> | |
154 | ||
155 |