System: merge accumulated changes from trunk

[SVN r49292]
This commit is contained in:
Beman Dawes
2008-10-12 13:51:47 +00:00
7 changed files with 399 additions and 63 deletions

View File

@ -39,6 +39,7 @@
<td width="100%" bgcolor="#E8F5FF"> <td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br> <a href="#Introduction">Introduction</a><br>
<a href="#Macros">Macros</a><br> <a href="#Macros">Macros</a><br>
<a href="#Deprecated-names">Deprecated names</a><br>
<a href="#Header-error_code">Header &lt;boost/system/error_code.hpp&gt;</a><br> <a href="#Header-error_code">Header &lt;boost/system/error_code.hpp&gt;</a><br>
<a href="#Class-error_category">Class <code>error_category</code></a><br> <a href="#Class-error_category">Class <code>error_category</code></a><br>
&nbsp;&nbsp;&nbsp;<a href="#Class-error_category-synopsis">Class <code>error_category</code> synopsis</a><br> &nbsp;&nbsp;&nbsp;<a href="#Class-error_category-synopsis">Class <code>error_category</code> synopsis</a><br>
@ -57,6 +58,8 @@
&nbsp;&nbsp;&nbsp;<a href="#Class-error_condition-constructors">Class <code>error_condition</code> constructors</a><br> &nbsp;&nbsp;&nbsp;<a href="#Class-error_condition-constructors">Class <code>error_condition</code> constructors</a><br>
&nbsp;&nbsp;&nbsp;<a href="#Class-error_condition-modifiers">Class <code>error_condition</code> modifiers</a><br> &nbsp;&nbsp;&nbsp;<a href="#Class-error_condition-modifiers">Class <code>error_condition</code> modifiers</a><br>
&nbsp;&nbsp;&nbsp;<a href="#Class-error_condition-observers">Class <code>error_condition</code> observers</a><br> &nbsp;&nbsp;&nbsp;<a href="#Class-error_condition-observers">Class <code>error_condition</code> observers</a><br>
<a href="#throws-object"><code>throws</code> object</a><br>
<a href="#Semantics-of-throws">Semantics of <code>throws</code> object</a><br>
<a href="#Non-member-functions">Non-member functions</a><br> <a href="#Non-member-functions">Non-member functions</a><br>
<a href="#Header-system_error">Header &lt;boost/system/system_error.hpp&gt;</a><br> <a href="#Header-system_error">Header &lt;boost/system/system_error.hpp&gt;</a><br>
&nbsp;&nbsp;&nbsp;<a href="#Class-system_error">Class <code>system_error</code></a><br> &nbsp;&nbsp;&nbsp;<a href="#Class-system_error">Class <code>system_error</code></a><br>
@ -114,6 +117,45 @@ provided, so users may ignore these macros if they prefer.</p>
<td valign="top">Deprecated features are excluded.</td> <td valign="top">Deprecated features are excluded.</td>
</tr> </tr>
</table> </table>
<h2><a name="Deprecated-names">Deprecated names</a></h2>
<p>In the process of adding Boost.System to C++0x standard library, some of the
names are being changed. To ease transition, Boost.System deprecates the old
names, but continues to provide them unless macro <code>BOOST_SYSTEM_NO_DEPRECATED</code>
is defined.</p>
<table border="1" cellpadding="5" cellspacing="1" style="border-collapse: collapse" bordercolor="#111111">
<tr>
<td><b><i>Old name, now deprecated</i></b></td>
<td><b><i>New name</i></b></td>
</tr>
<tr>
<td><code>namespace posix</code></td>
<td><code>namespace errc</code></td>
</tr>
<tr>
<td><code>namespace posix_error</code></td>
<td><code>namespace errc</code></td>
</tr>
<tr>
<td><code>enum posix_errno</code></td>
<td><code>enum errc_t</code></td>
</tr>
<tr>
<td><code>get_posix_category()</code></td>
<td><code>get_generic_category()</code></td>
</tr>
<tr>
<td><code>posix_category</code></td>
<td><code>generic_category</code></td>
</tr>
<tr>
<td><code>errno_ecat</code></td>
<td><code>generic_category</code></td>
</tr>
<tr>
<td><code>native_ecat</code></td>
<td><code>system_category</code></td>
</tr>
</table>
<h2><a name="Header-error_code">Header &lt;boost/system/error_code.hpp&gt;</a></h2> <h2><a name="Header-error_code">Header &lt;boost/system/error_code.hpp&gt;</a></h2>
<h3>&lt;boost/system/error_code.hpp&gt; synopsis</h3> <h3>&lt;boost/system/error_code.hpp&gt; synopsis</h3>
<blockquote> <blockquote>
@ -223,6 +265,11 @@ provided, so users may ignore these macros if they prefer.</p>
template<> struct is_error_condition_enum<posix::posix_errno>&lt;errc::errc_t&gt; template<> struct is_error_condition_enum<posix::posix_errno>&lt;errc::errc_t&gt;
{ static const bool value = true; }; { static const bool value = true; };
// predefined error_code object used as &quot;throw on error&quot; tag
extern error_code <a href="#throws-object">throws</a>;
// <a href="#Non-member-functions">non-member functions</a>
bool operator==( const error_code &amp; lhs, const error_code &amp; rhs ); bool operator==( const error_code &amp; lhs, const error_code &amp; rhs );
bool operator==( const error_code &amp; code, const error_condition &amp; condition ); bool operator==( const error_code &amp; code, const error_condition &amp; condition );
bool operator==( const error_condition &amp; condition, const error_code &amp; code ); bool operator==( const error_condition &amp; condition, const error_code &amp; code );
@ -279,7 +326,7 @@ types should create a single object of each such type. <i>
virtual ~error_category(); virtual ~error_category();
virtual const char * name() const = 0; virtual const char * name() const = 0;
virtual string message( error_code::value_type ev ) const = 0; virtual string message( int ev ) const = 0;
virtual error_condition default_error_condition( int ev ) const; virtual error_condition default_error_condition( int ev ) const;
virtual bool equivalent( int code, const error_condition &amp; condition ) const; virtual bool equivalent( int code, const error_condition &amp; condition ) const;
virtual bool equivalent( const error_code &amp; code, int condition ) const; virtual bool equivalent( const error_code &amp; code, int condition ) const;
@ -305,7 +352,7 @@ this subclause.</p>
<p><i>Returns: </i>a string naming the error category.</p> <p><i>Returns: </i>a string naming the error category.</p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>virtual string message( error_code::value_type ev ) const=0;</pre> <pre>virtual string message( int ev ) const=0;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> A string that describes the error denoted by <p><i>Returns:</i> A string that describes the error denoted by
<code>ev</code>.</p> <code>ev</code>.</p>
@ -370,7 +417,7 @@ non-member functions</a></h3>
<h3><a name="Class-error_category-predefined-objects">Class <code>error_category</code> <h3><a name="Class-error_category-predefined-objects">Class <code>error_category</code>
predefined objects</a></h3> predefined objects</a></h3>
<p>Predefined objects <code>system_category</code> <p>Predefined objects <code>system_category</code>
and <code>generic_category</code> identify operating system error codes and portable error conditions, respectively.</p> and <code>generic_category</code> identify system specific error codes and portable error conditions, respectively.</p>
<h2><a name="Class-error_code">Class <code> <h2><a name="Class-error_code">Class <code>
error_code</code></a></h2> error_code</code></a></h2>
<p>The class <code>error_code</code> describes an object used to hold error code <p>The class <code>error_code</code> describes an object used to hold error code
@ -392,7 +439,7 @@ error_code</code> synopsis</a></h3>
error_code(); error_code();
error_code( val, const error_category &amp; cat ); error_code( val, const error_category &amp; cat );
template &lt;class <code>ErrorCodeEnum</code>&gt; template &lt;class <code>ErrorCodeEnum</code>&gt;
error_code(<code> errorCodeEnum</code> e, error_code(<code> ErrorCodeEnum</code> e,
typename enable_if&lt;is_error_code_enum&lt;<code>ErrorCodeEnum</code>&gt; &gt;::type* = 0); typename enable_if&lt;is_error_code_enum&lt;<code>ErrorCodeEnum</code>&gt; &gt;::type* = 0);
// modifiers: // modifiers:
@ -411,7 +458,7 @@ error_code</code> synopsis</a></h3>
private: private:
int val_; // <i>exposition only</i> int val_; // <i>exposition only</i>
const error_category &amp; cat_; // <i>exposition only</i> const error_category * cat_; // <i>exposition only</i>
}; };
} }
}</pre> }</pre>
@ -442,7 +489,7 @@ error_code</code> constructors</a></h3>
error_code</code> modifiers</a></h3> error_code</code> modifiers</a></h3>
<pre>void assign( int val, const error_category &amp; cat );</pre> <pre>void assign( int val, const error_category &amp; cat );</pre>
<blockquote> <blockquote>
<p><i>Postconditions:</i> <code>val_ == val &amp;&amp; cat_ == cat</code>.</p> <p><i>Postconditions:</i> <code>val_ == val &amp;&amp; cat_ == &amp;cat</code>.</p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>template&lt;typename <code>ErrorCodeEnum</code>&gt; <pre>template&lt;typename <code>ErrorCodeEnum</code>&gt;
@ -463,9 +510,9 @@ error_code</code> observers</a></h3>
<p><i>Returns:</i> <code>val_</code>.</p> <p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<p><code>error_category category() const;</code></p> <p><code>const error_category &amp; category() const;</code></p>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>cat_</code>.</p> <p><i>Returns:</i> <code>*cat_</code>.</p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>error_condition default_error_condition() const;</pre> <pre>error_condition default_error_condition() const;</pre>
@ -480,7 +527,7 @@ error_code</code> observers</a></h3>
</blockquote> </blockquote>
<p><code>operator <i>unspecified-bool-type</i>() const;</code></p> <p><code>operator <i>unspecified-bool-type</i>() const;</code></p>
<blockquote> <blockquote>
<p><i>Returns:</i> if <code>value() != value_type()</code>, returns a value that will evaluate <p><i>Returns:</i> if <code>value() != 0</code>, returns a value that will evaluate
<code>true</code> in a boolean context; otherwise, returns a value that will <code>true</code> in a boolean context; otherwise, returns a value that will
evaluate <code>false</code> in a boolean context. The value type returned shall evaluate <code>false</code> in a boolean context. The value type returned shall
not be convertible to <code>int</code>.</p> not be convertible to <code>int</code>.</p>
@ -528,7 +575,7 @@ implementation specific. <i>--end note ]</i></p>
private: private:
int val_; // <i>exposition only</i> int val_; // <i>exposition only</i>
const error_category &amp; cat_; // <i>exposition only</i> const error_category * cat_; // <i>exposition only</i>
}; };
} }
}</pre> }</pre>
@ -538,13 +585,13 @@ constructors</a></h3>
<pre>error_condition(); </pre> <pre>error_condition(); </pre>
<blockquote> <blockquote>
<p><i>Effects:</i> Constructs an object of type <code>error_condition</code>.</p> <p><i>Effects:</i> Constructs an object of type <code>error_condition</code>.</p>
<p><i>Postconditions:</i> <code>val_ == 0 and cat_ == generic_category</code>.</p> <p><i>Postconditions:</i> <code>val_ == 0 and cat_ == &amp;generic_category</code>.</p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>error_condition( value_type val, const error_category &amp; cat );</pre> <pre>error_condition( int val, const error_category &amp; cat );</pre>
<blockquote> <blockquote>
<p><i>Effects: </i>Constructs an object of type error_condition.</p> <p><i>Effects: </i>Constructs an object of type error_condition.</p>
<p><i>Postconditions:</i> <code>val_ == val and cat_ == cat</code>.</p> <p><i>Postconditions:</i> <code>val_ == val and cat_ == &amp;cat</code>.</p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>template &lt;class ErrorConditionEnum&gt; <pre>template &lt;class ErrorConditionEnum&gt;
@ -557,9 +604,9 @@ constructors</a></h3>
</blockquote> </blockquote>
<h3><a name="Class-error_condition-modifiers">Class <code>error_condition</code> <h3><a name="Class-error_condition-modifiers">Class <code>error_condition</code>
modifiers</a></h3> modifiers</a></h3>
<pre>void assign( value_type val, const error_category &amp; cat ); </pre> <pre>void assign( int val, const error_category &amp; cat ); </pre>
<blockquote> <blockquote>
<p><i>Postconditions:</i> <code>val_ == val and cat_ == cat</code>. </p> <p><i>Postconditions:</i> <code>val_ == val and cat_ == &amp;cat</code>. </p>
<p><i>Throws:</i> Nothing.</p> <p><i>Throws:</i> Nothing.</p>
</blockquote> </blockquote>
<pre>template&lt;typename ErrorConditionEnum&gt; <pre>template&lt;typename ErrorConditionEnum&gt;
@ -575,14 +622,14 @@ modifiers</a></h3>
</blockquote> </blockquote>
<h3><a name="Class-error_condition-observers">Class <code>error_condition</code> <h3><a name="Class-error_condition-observers">Class <code>error_condition</code>
observers</a></h3> observers</a></h3>
<pre>value_type value() const;</pre> <pre>int value() const;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>val_</code>.</p> <p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing</p> <p><i>Throws:</i> Nothing</p>
</blockquote> </blockquote>
<pre>const error_category &amp; category() const;</pre> <pre>const error_category &amp; category() const;</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>cat_</code>.</p> <p><i>Returns:</i> <code>*cat_</code>.</p>
<p>Throws: Nothing.</p> <p>Throws: Nothing.</p>
</blockquote> </blockquote>
<pre>string message() const;</pre> <pre>string message() const;</pre>
@ -602,6 +649,36 @@ observers</a></h3>
<code>int</code>) that can occur with <code>bool</code> are not allowed, <code>int</code>) that can occur with <code>bool</code> are not allowed,
eliminating some sources of user error. One possible implementation choice for eliminating some sources of user error. One possible implementation choice for
this type is pointer to member. <i>--end note</i> <i>]</i></p> this type is pointer to member. <i>--end note</i> <i>]</i></p>
</blockquote>
<h2><a name="throws-object"><code>throws</code> object</a></h2>
<pre>extern error_code throws;</pre>
<p>The predefined <code>error_code</code> object <code>throws</code> is supplied
for use as a &quot;throw on error&quot; tag.</p>
<h2><a name="Semantics-of-throws">Semantics of <code>throws</code></a> object</h2>
<p>Functions that specify an argument in the form <code>error_code&amp; ec=throws</code>,
with appropriate namespace qualifiers, have the following error handling
semantics:</p>
<blockquote>
<p><i>Postconditions:</i></p>
<blockquote>
<p>If <code>&amp;ec != &amp;throws</code> and an error occurred:</p>
<ul>
<li> <code>ec.value()</code> returns the implementation specific error
number for the particular error that occurred.</li>
<li><code>ec.category()</code> returns the <code>
<a href="#Class-error_category">error_category</a></code> for <code>ec.value()</code>.</li>
</ul>
<p>if <code>&amp;ec != &amp;throws</code> and an error did not occur, <code>ec.clear()</code>.</p>
</blockquote>
<p><i>Throws:</i></p>
<blockquote>
<p>If an error occurs and <code>&amp;ec == &amp;throws</code>, throws an exception of type
<code><a href="#Class-system_error">system_error</a></code> or of a type
derived from <code><a href="#Class-system_error">system_error</a></code>. The
exception's <code>code()</code> member function returns a reference to an
<code>error_code</code> object with the behavior specified in <i>
Postconditions</i>.</p>
</blockquote>
</blockquote> </blockquote>
<h2><a name="Non-member-functions">Non-member functions</a></h2> <h2><a name="Non-member-functions">Non-member functions</a></h2>
<pre>bool operator==( const error_code &amp; lhs, const error_code &amp; rhs );</pre> <pre>bool operator==( const error_code &amp; lhs, const error_code &amp; rhs );</pre>
@ -657,7 +734,7 @@ bool operator!=( const error_condition &amp; condition, const error_code &amp; c
</blockquote> </blockquote>
<pre>error_condition make_error_condition( errc::errc_t e );</pre> <pre>error_condition make_error_condition( errc::errc_t e );</pre>
<blockquote> <blockquote>
<p><i>Returns:</i> <code>error_condition( e, generic_category)</code>.</p> <p><i>Returns:</i> <code>error_condition( static_cast&lt;int&gt;( e ), generic_category)</code>.</p>
</blockquote> </blockquote>
<pre>template &lt;class charT, class traits&gt; <pre>template &lt;class charT, class traits&gt;
@ -677,8 +754,7 @@ bool operator!=( const error_condition &amp; condition, const error_code &amp; c
<h3><a name="Class-system_error">Class <code> <h3><a name="Class-system_error">Class <code>
system_error</code></a></h3> system_error</code></a></h3>
<p>The class <code>system_error</code> describes an exception object used to <p>The class <code>system_error</code> describes an exception object used to
report error conditions that have an associated error code. Such error report errors that have an associated <code><a href="#Class-error_code">error_code</a></code>. Such errors typically originate from operating system or other low-level
conditions typically originate from the operating system or other low-level
application program interfaces.</p> application program interfaces.</p>
<blockquote> <blockquote>
<pre>namespace boost <pre>namespace boost
@ -691,11 +767,11 @@ application program interfaces.</p>
system_error( error_code ec ); system_error( error_code ec );
system_error( error_code ec, const char * what_arg ); system_error( error_code ec, const char * what_arg );
system_error( error_code ec, const std::string &amp; what_arg ); system_error( error_code ec, const std::string &amp; what_arg );
system_error( error_code::value_type ev, const error_category &amp; ecat, system_error( int ev, const error_category &amp; ecat,
const char * what_arg ); const char * what_arg );
system_error( error_code::value_type ev, const error_category &amp; ecat, system_error( int ev, const error_category &amp; ecat,
const std::string &amp; what_arg ); const std::string &amp; what_arg );
system_error( error_code::value_type ev, const error_category &amp; ecat); system_error( int ev, const error_category &amp; ecat);
const error_code &amp; code() const throw(); const error_code &amp; code() const throw();
const char * what() const throw(); const char * what() const throw();
@ -721,21 +797,21 @@ application program interfaces.</p>
<p><i>Postcondition:</i> <code>code() == ec <br> <p><i>Postcondition:</i> <code>code() == ec <br>
&nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg.c_str() ) == 0</code></p> &nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg.c_str() ) == 0</code></p>
</blockquote> </blockquote>
<pre>system_error( error_code::value_type ev, const error_category &amp; ecat, <pre>system_error( int ev, const error_category &amp; ecat,
const char * what_arg );</pre> const char * what_arg );</pre>
<blockquote> <blockquote>
<p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p> <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
<p><i>Postcondition:</i> <code>code() == error_code( ev, ecat )<br> <p><i>Postcondition:</i> <code>code() == error_code( ev, ecat )<br>
&nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg ) == 0</code></p> &nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg ) == 0</code></p>
</blockquote> </blockquote>
<pre>system_error( error_code::value_type ev, const error_category &amp; ecat, <pre>system_error( int ev, const error_category &amp; ecat,
const std::string &amp; what_arg );</pre> const std::string &amp; what_arg );</pre>
<blockquote> <blockquote>
<p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p> <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
<p><i>Postcondition:</i> <code>code() == error_code( ev, ecat )<br> <p><i>Postcondition:</i> <code>code() == error_code( ev, ecat )<br>
&nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg.c_str() ) == 0</code></p> &nbsp; &amp;&amp; std::strcmp( this-&gt;runtime_error::what(), what_arg.c_str() ) == 0</code></p>
</blockquote> </blockquote>
<pre>system_error( error_code::value_type ev, const error_category &amp; ecat );</pre> <pre>system_error( int ev, const error_category &amp; ecat );</pre>
<blockquote> <blockquote>
<p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p> <p><i>Effects:</i> Constructs an object of class <code>system_error</code>.</p>
<p><i>Postcondition:</i> <code>code() == error_code( ev, ecat )<br> <p><i>Postcondition:</i> <code>code() == error_code( ev, ecat )<br>
@ -754,14 +830,15 @@ application program interfaces.</p>
</blockquote> </blockquote>
<hr> <hr>
<p><EFBFBD> Copyright Beman Dawes, 2006, 2007<br>
Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
<p>Revised <p>Revised
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->June 25, 2008<!--webbot bot="Timestamp" endspan i-checksum="14296" --> </font> <!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->October 11, 2008<!--webbot bot="Timestamp" endspan i-checksum="30976" --> </font>
</p> </p>
<p><EFBFBD> Copyright Beman Dawes, 2006, 2007, 2008</p>
<p>Distributed under the Boost Software License, Version 1.0. See
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
</body> </body>
</html> </html>

View File

@ -224,9 +224,9 @@ namespace boost
error_condition() : m_val(0), m_cat(&get_generic_category()) {} error_condition() : m_val(0), m_cat(&get_generic_category()) {}
error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
template <class ConditionEnum> template <class ErrorConditionEnum>
error_condition(ConditionEnum e, error_condition(ErrorConditionEnum e,
typename boost::enable_if<is_error_condition_enum<ConditionEnum> >::type* = 0) typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0)
{ {
*this = make_error_condition(e); *this = make_error_condition(e);
} }
@ -239,9 +239,9 @@ namespace boost
m_cat = &cat; m_cat = &cat;
} }
template<typename ConditionEnum> template<typename ErrorConditionEnum>
typename boost::enable_if<is_error_condition_enum<ConditionEnum>, error_condition>::type & typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type &
operator=( ConditionEnum val ) operator=( ErrorConditionEnum val )
{ {
*this = make_error_condition(val); *this = make_error_condition(val);
return *this; return *this;
@ -311,9 +311,9 @@ namespace boost
error_code() : m_val(0), m_cat(&get_system_category()) {} error_code() : m_val(0), m_cat(&get_system_category()) {}
error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {} error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
template <class CodeEnum> template <class ErrorCodeEnum>
error_code(CodeEnum e, error_code(ErrorCodeEnum e,
typename boost::enable_if<is_error_code_enum<CodeEnum> >::type* = 0) typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0)
{ {
*this = make_error_code(e); *this = make_error_code(e);
} }
@ -325,9 +325,9 @@ namespace boost
m_cat = &cat; m_cat = &cat;
} }
template<typename CodeEnum> template<typename ErrorCodeEnum>
typename boost::enable_if<is_error_code_enum<CodeEnum>, error_code>::type & typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type &
operator=( CodeEnum val ) operator=( ErrorCodeEnum val )
{ {
*this = make_error_code(val); *this = make_error_code(val);
return *this; return *this;
@ -382,6 +382,9 @@ namespace boost
}; };
// predefined error_code object used as "throw on error" tag
BOOST_SYSTEM_DECL extern error_code throws;
// non-member functions ------------------------------------------------// // non-member functions ------------------------------------------------//
inline bool operator!=( const error_code & lhs, inline bool operator!=( const error_code & lhs,

View File

@ -61,11 +61,12 @@ namespace
const char * generic_error_category::name() const const char * generic_error_category::name() const
{ {
return "GENERIC"; return "generic";
} }
std::string generic_error_category::message( int ev ) const std::string generic_error_category::message( int ev ) const
{ {
static std::string unknown_err( "Unknown error" );
// strerror_r is preferred because it is always thread safe, // strerror_r is preferred because it is always thread safe,
// however, we fallback to strerror in certain cases because: // however, we fallback to strerror in certain cases because:
// -- Windows doesn't provide strerror_r. // -- Windows doesn't provide strerror_r.
@ -81,15 +82,19 @@ namespace
|| (defined(__osf__) && !defined(_REENTRANT))\ || (defined(__osf__) && !defined(_REENTRANT))\
|| (defined(__vms)) || (defined(__vms))
const char * c_str = std::strerror( ev ); const char * c_str = std::strerror( ev );
return std::string( c_str ? c_str : "Unknown error" ); return c_str
# else ? std::string( c_str )
: unknown_err;
# else // use strerror_r
char buf[64]; char buf[64];
char * bp = buf; char * bp = buf;
std::size_t sz = sizeof(buf); std::size_t sz = sizeof(buf);
# if defined(__CYGWIN__) || defined(__USE_GNU) # if defined(__CYGWIN__) || defined(__USE_GNU)
// Oddball version of strerror_r // Oddball version of strerror_r
const char * c_str = strerror_r( ev, bp, sz ); const char * c_str = strerror_r( ev, bp, sz );
return std::string( c_str ? c_str : "Unknown error" ); return c_str
? std::string( c_str )
: unknown_err;
# else # else
// POSIX version of strerror_r // POSIX version of strerror_r
int result; int result;
@ -100,7 +105,9 @@ namespace
# if defined (__sgi) # if defined (__sgi)
const char * c_str = strerror( ev ); const char * c_str = strerror( ev );
result = 0; result = 0;
return std::string( c_str ? c_str : "Unknown error" ); return c_str
? std::string( c_str )
: unknown_err;
# else # else
result = strerror_r( ev, bp, sz ); result = strerror_r( ev, bp, sz );
# endif # endif
@ -119,20 +126,25 @@ namespace
return std::string( "ENOMEM" ); return std::string( "ENOMEM" );
} }
} }
std::string msg;
try try
{ {
std::string msg( ( result == invalid_argument ) ? "Unknown error" : bp ); msg = ( ( result == invalid_argument ) ? "Unknown error" : bp );
}
# ifndef BOOST_NO_EXCEPTIONS
// See ticket #2098
catch(...)
{
// just eat the exception
}
# endif
if ( sz > sizeof(buf) ) std::free( bp ); if ( sz > sizeof(buf) ) std::free( bp );
sz = 0; sz = 0;
return msg; return msg;
} # endif // else POSIX version of strerror_r
catch(...) # endif // else use strerror_r
{
if ( sz > sizeof(buf) ) std::free( bp );
throw;
}
# endif
# endif
} }
// system_error_category implementation --------------------------------// // system_error_category implementation --------------------------------//
@ -154,7 +166,9 @@ namespace
case EADDRNOTAVAIL: return make_error_condition( address_not_available ); case EADDRNOTAVAIL: return make_error_condition( address_not_available );
case EAFNOSUPPORT: return make_error_condition( address_family_not_supported ); case EAFNOSUPPORT: return make_error_condition( address_family_not_supported );
case EAGAIN: return make_error_condition( resource_unavailable_try_again ); case EAGAIN: return make_error_condition( resource_unavailable_try_again );
# if EALREADY != EBUSY // EALREADY and EBUSY are the same on QNX Neutrino
case EALREADY: return make_error_condition( connection_already_in_progress ); case EALREADY: return make_error_condition( connection_already_in_progress );
# endif
case EBADF: return make_error_condition( bad_file_descriptor ); case EBADF: return make_error_condition( bad_file_descriptor );
case EBADMSG: return make_error_condition( bad_message ); case EBADMSG: return make_error_condition( bad_message );
case EBUSY: return make_error_condition( device_or_resource_busy ); case EBUSY: return make_error_condition( device_or_resource_busy );
@ -396,6 +410,12 @@ namespace boost
namespace system namespace system
{ {
BOOST_SYSTEM_DECL error_code throws; // "throw on error" special error_code;
// note that it doesn't matter if this
// isn't initialized before use since
// the only use is to take its
// address for comparison purposes
BOOST_SYSTEM_DECL const error_category & get_system_category() BOOST_SYSTEM_DECL const error_category & get_system_category()
{ {
static const system_error_category system_category_const; static const system_error_category system_category_const;

View File

@ -10,7 +10,6 @@
project project
: requirements : requirements
<library>/boost/system//boost_system <library>/boost/system//boost_system
<define>BOOST_ALL_NO_LIB
<toolset>msvc:<asynch-exceptions>on <toolset>msvc:<asynch-exceptions>on
; ;

View File

@ -0,0 +1,18 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioPropertySheet
ProjectType="Visual C++"
Version="8.00"
Name="common"
>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="../../../../.."
PreprocessorDefinitions="BOOST_ALL_NO_LIB"
ExceptionHandling="2"
/>
<Tool
Name="VCPostBuildEventTool"
Description="Executing test $(TargetName).exe..."
CommandLine="&quot;$(TargetDir)\$(TargetName).exe&quot; --result_code=no --report_level=no"
/>
</VisualStudioPropertySheet>

View File

@ -0,0 +1,199 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="error_code_test"
ProjectGUID="{81960557-E9A9-4E81-AC96-9E11C33CB058}"
RootNamespace="error_code_test"
Keyword="Win32Proj"
TargetFrameworkVersion="196613"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="4"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="2"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\common.vsprops"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="2"
EnableIntrinsicFunctions="true"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
RuntimeLibrary="2"
EnableFunctionLevelLinking="true"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
LinkIncremental="1"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="..\..\..\src\error_code.cpp"
>
</File>
<File
RelativePath="..\..\error_code_test.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -0,0 +1,20 @@

Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "error_code_test", "error_code_test\error_code_test.vcproj", "{81960557-E9A9-4E81-AC96-9E11C33CB058}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Release|Win32 = Release|Win32
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{81960557-E9A9-4E81-AC96-9E11C33CB058}.Debug|Win32.ActiveCfg = Debug|Win32
{81960557-E9A9-4E81-AC96-9E11C33CB058}.Debug|Win32.Build.0 = Debug|Win32
{81960557-E9A9-4E81-AC96-9E11C33CB058}.Release|Win32.ActiveCfg = Release|Win32
{81960557-E9A9-4E81-AC96-9E11C33CB058}.Release|Win32.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal