|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r49292 - in branches/release: boost/system libs/system/doc libs/system/src libs/system/test libs/system/test/msvc_system libs/system/test/msvc_system/error_code_test
From: bdawes_at_[hidden]
Date: 2008-10-12 09:51:48
Author: bemandawes
Date: 2008-10-12 09:51:47 EDT (Sun, 12 Oct 2008)
New Revision: 49292
URL: http://svn.boost.org/trac/boost/changeset/49292
Log:
System: merge accumulated changes from trunk
Added:
branches/release/libs/system/test/msvc_system/
- copied from r49291, /trunk/libs/system/test/msvc_system/
branches/release/libs/system/test/msvc_system/common.vsprops
- copied unchanged from r49291, /trunk/libs/system/test/msvc_system/common.vsprops
branches/release/libs/system/test/msvc_system/error_code_test/
- copied from r49291, /trunk/libs/system/test/msvc_system/error_code_test/
branches/release/libs/system/test/msvc_system/error_code_test/error_code_test.vcproj
- copied unchanged from r49291, /trunk/libs/system/test/msvc_system/error_code_test/error_code_test.vcproj
branches/release/libs/system/test/msvc_system/msvc_system.sln
- copied unchanged from r49291, /trunk/libs/system/test/msvc_system/msvc_system.sln
Text files modified:
branches/release/boost/system/error_code.hpp | 27 ++++---
branches/release/libs/system/doc/reference.html | 143 ++++++++++++++++++++++++++++++---------
branches/release/libs/system/src/error_code.cpp | 54 ++++++++++----
branches/release/libs/system/test/Jamfile.v2 | 1
4 files changed, 162 insertions(+), 63 deletions(-)
Modified: branches/release/boost/system/error_code.hpp
==============================================================================
--- branches/release/boost/system/error_code.hpp (original)
+++ branches/release/boost/system/error_code.hpp 2008-10-12 09:51:47 EDT (Sun, 12 Oct 2008)
@@ -224,9 +224,9 @@
error_condition() : m_val(0), m_cat(&get_generic_category()) {}
error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
- template <class ConditionEnum>
- error_condition(ConditionEnum e,
- typename boost::enable_if<is_error_condition_enum<ConditionEnum> >::type* = 0)
+ template <class ErrorConditionEnum>
+ error_condition(ErrorConditionEnum e,
+ typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum> >::type* = 0)
{
*this = make_error_condition(e);
}
@@ -239,9 +239,9 @@
m_cat = &cat;
}
- template<typename ConditionEnum>
- typename boost::enable_if<is_error_condition_enum<ConditionEnum>, error_condition>::type &
- operator=( ConditionEnum val )
+ template<typename ErrorConditionEnum>
+ typename boost::enable_if<is_error_condition_enum<ErrorConditionEnum>, error_condition>::type &
+ operator=( ErrorConditionEnum val )
{
*this = make_error_condition(val);
return *this;
@@ -311,9 +311,9 @@
error_code() : m_val(0), m_cat(&get_system_category()) {}
error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
- template <class CodeEnum>
- error_code(CodeEnum e,
- typename boost::enable_if<is_error_code_enum<CodeEnum> >::type* = 0)
+ template <class ErrorCodeEnum>
+ error_code(ErrorCodeEnum e,
+ typename boost::enable_if<is_error_code_enum<ErrorCodeEnum> >::type* = 0)
{
*this = make_error_code(e);
}
@@ -325,9 +325,9 @@
m_cat = &cat;
}
- template<typename CodeEnum>
- typename boost::enable_if<is_error_code_enum<CodeEnum>, error_code>::type &
- operator=( CodeEnum val )
+ template<typename ErrorCodeEnum>
+ typename boost::enable_if<is_error_code_enum<ErrorCodeEnum>, error_code>::type &
+ operator=( ErrorCodeEnum val )
{
*this = make_error_code(val);
return *this;
@@ -382,6 +382,9 @@
};
+ // predefined error_code object used as "throw on error" tag
+ BOOST_SYSTEM_DECL extern error_code throws;
+
// non-member functions ------------------------------------------------//
inline bool operator!=( const error_code & lhs,
Modified: branches/release/libs/system/doc/reference.html
==============================================================================
--- branches/release/libs/system/doc/reference.html (original)
+++ branches/release/libs/system/doc/reference.html 2008-10-12 09:51:47 EDT (Sun, 12 Oct 2008)
@@ -39,6 +39,7 @@
<td width="100%" bgcolor="#E8F5FF">
<a href="#Introduction">Introduction</a><br>
<a href="#Macros">Macros</a><br>
+ Deprecated names<br>
<a href="#Header-error_code">Header <boost/system/error_code.hpp></a><br>
<a href="#Class-error_category">Class <code>error_category</code></a><br>
Class error_category
synopsis<br>
@@ -57,6 +58,8 @@
Class error_condition
constructors<br>
Class error_condition
modifiers<br>
Class error_condition
observers<br>
+ throws
object<br>
+ Semantics of throws
object<br>
<a href="#Non-member-functions">Non-member functions</a><br>
<a href="#Header-system_error">Header <boost/system/system_error.hpp></a><br>
Class system_error
<br>
@@ -114,6 +117,45 @@
<td valign="top">Deprecated features are excluded.</td>
</tr>
</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 <boost/system/error_code.hpp></a></h2>
<h3><boost/system/error_code.hpp> synopsis</h3>
<blockquote>
@@ -223,6 +265,11 @@
template<> struct is_error_condition_enum<posix::posix_errno><errc::errc_t>
{ static const bool value = true; };
+ // predefined error_code object used as "throw on error" tag
+ extern error_code throws;
+
+ // non-member functions
+
bool operator==( const error_code & lhs, const error_code & rhs );
bool operator==( const error_code & code, const error_condition & condition );
bool operator==( const error_condition & condition, const error_code & code );
@@ -279,7 +326,7 @@
virtual ~error_category();
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 bool equivalent( int code, const error_condition & condition ) const;
virtual bool equivalent( const error_code & code, int condition ) const;
@@ -305,7 +352,7 @@
<p><i>Returns: </i>a string naming the error category.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
-<pre>virtual string message( error_code::value_type ev ) const=0;</pre>
+<pre>virtual string message( int ev ) const=0;</pre>
<blockquote>
<p><i>Returns:</i> A string that describes the error denoted by
<code>ev</code>.</p>
@@ -370,7 +417,7 @@
<h3><a name="Class-error_category-predefined-objects">Class <code>error_category</code>
predefined objects</a></h3>
<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>
error_code</code></a></h2>
<p>The class <code>error_code</code> describes an object used to hold error code
@@ -392,7 +439,7 @@
error_code();
error_code( val, const error_category & cat );
template <class <code>ErrorCodeEnum</code>>
- error_code(<code> errorCodeEnum</code> e,
+ error_code(<code> ErrorCodeEnum</code> e,
typename enable_if<is_error_code_enum<<code>ErrorCodeEnum</code>> >::type* = 0);
// modifiers:
@@ -411,7 +458,7 @@
private:
int val_; // <i>exposition only</i>
- const error_category & cat_; // <i>exposition only</i>
+ const error_category * cat_; // <i>exposition only</i>
};
}
}</pre>
@@ -442,7 +489,7 @@
error_code</code> modifiers</a></h3>
<pre>void assign( int val, const error_category & cat );</pre>
<blockquote>
- <p><i>Postconditions:</i> <code>val_ == val && cat_ == cat</code>.</p>
+ <p><i>Postconditions:</i> <code>val_ == val && cat_ == &cat</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template<typename <code>ErrorCodeEnum</code>>
@@ -463,9 +510,9 @@
<p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
- <p><code>error_category category() const;</code></p>
+ <p><code>const error_category & category() const;</code></p>
<blockquote>
-<p><i>Returns:</i> <code>cat_</code>.</p>
+<p><i>Returns:</i> <code>*cat_</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>error_condition default_error_condition() const;</pre>
@@ -480,7 +527,7 @@
</blockquote>
<p><code>operator <i>unspecified-bool-type</i>() const;</code></p>
<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
evaluate <code>false</code> in a boolean context. The value type returned shall
not be convertible to <code>int</code>.</p>
@@ -527,8 +574,8 @@
operator unspecified-bool-type () const;
private:
- int val_; // <i>exposition only</i>
- const error_category & cat_; // <i>exposition only</i>
+ int val_; // <i>exposition only</i>
+ const error_category * cat_; // <i>exposition only</i>
};
}
}</pre>
@@ -538,13 +585,13 @@
<pre>error_condition(); </pre>
<blockquote>
<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_ == &generic_category</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
-<pre>error_condition( value_type val, const error_category & cat );</pre>
+<pre>error_condition( int val, const error_category & cat );</pre>
<blockquote>
<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_ == &cat</code>.</p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template <class ErrorConditionEnum>
@@ -557,9 +604,9 @@
</blockquote>
<h3><a name="Class-error_condition-modifiers">Class <code>error_condition</code>
modifiers</a></h3>
-<pre>void assign( value_type val, const error_category & cat ); </pre>
+<pre>void assign( int val, const error_category & cat ); </pre>
<blockquote>
- <p><i>Postconditions:</i> <code>val_ == val and cat_ == cat</code>. </p>
+ <p><i>Postconditions:</i> <code>val_ == val and cat_ == &cat</code>. </p>
<p><i>Throws:</i> Nothing.</p>
</blockquote>
<pre>template<typename ErrorConditionEnum>
@@ -575,14 +622,14 @@
</blockquote>
<h3><a name="Class-error_condition-observers">Class <code>error_condition</code>
observers</a></h3>
-<pre>value_type value() const;</pre>
+<pre>int value() const;</pre>
<blockquote>
<p><i>Returns:</i> <code>val_</code>.</p>
<p><i>Throws:</i> Nothing</p>
</blockquote>
<pre>const error_category & category() const;</pre>
<blockquote>
- <p><i>Returns:</i> <code>cat_</code>.</p>
+ <p><i>Returns:</i> <code>*cat_</code>.</p>
<p>Throws: Nothing.</p>
</blockquote>
<pre>string message() const;</pre>
@@ -603,7 +650,37 @@
eliminating some sources of user error. One possible implementation choice for
this type is pointer to member. <i>--end note</i> <i>]</i></p>
</blockquote>
- <h2><a name="Non-member-functions">Non-member functions</a></h2>
+ <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 "throw on error" 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& ec=throws</code>,
+with appropriate namespace qualifiers, have the following error handling
+semantics:</p>
+<blockquote>
+ <p><i>Postconditions:</i></p>
+ <blockquote>
+ <p>If <code>&ec != &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>
+ error_category</code> for <code>ec.value()</code>.</li>
+ </ul>
+ <p>if <code>&ec != &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>&ec == &throws</code>, throws an exception of type
+ <code>system_error</code> or of a type
+ derived from <code>system_error</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>
+<h2><a name="Non-member-functions">Non-member functions</a></h2>
<pre>bool operator==( const error_code & lhs, const error_code & rhs );</pre>
<blockquote>
<p><i>Returns:</i> <code>lhs.category() == rhs.category() && lhs.value() ==
@@ -657,7 +734,7 @@
</blockquote>
<pre>error_condition make_error_condition( errc::errc_t e );</pre>
<blockquote>
- <p><i>Returns:</i> <code>error_condition( e, generic_category)</code>.</p>
+ <p><i>Returns:</i> <code>error_condition( static_cast<int>( e ), generic_category)</code>.</p>
</blockquote>
<pre>template <class charT, class traits>
@@ -677,8 +754,7 @@
<h3><a name="Class-system_error">Class <code>
system_error</code></a></h3>
<p>The class <code>system_error</code> describes an exception object used to
-report error conditions that have an associated error code. Such error
-conditions typically originate from the operating system or other low-level
+report errors that have an associated <code>error_code</code>. Such errors typically originate from operating system or other low-level
application program interfaces.</p>
<blockquote>
<pre>namespace boost
@@ -691,11 +767,11 @@
system_error( error_code ec );
system_error( error_code ec, const char * what_arg );
system_error( error_code ec, const std::string & what_arg );
- system_error( error_code::value_type ev, const error_category & ecat,
+ system_error( int ev, const error_category & ecat,
const char * what_arg );
- system_error( error_code::value_type ev, const error_category & ecat,
+ system_error( int ev, const error_category & ecat,
const std::string & what_arg );
- system_error( error_code::value_type ev, const error_category & ecat);
+ system_error( int ev, const error_category & ecat);
const error_code & code() const throw();
const char * what() const throw();
@@ -721,21 +797,21 @@
<p><i>Postcondition:</i> <code>code() == ec <br>
&& std::strcmp( this->runtime_error::what(), what_arg.c_str() ) == 0</code></p>
</blockquote>
-<pre>system_error( error_code::value_type ev, const error_category & ecat,
+<pre>system_error( int ev, const error_category & ecat,
const char * what_arg );</pre>
<blockquote>
<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>
&& std::strcmp( this->runtime_error::what(), what_arg ) == 0</code></p>
</blockquote>
-<pre>system_error( error_code::value_type ev, const error_category & ecat,
+<pre>system_error( int ev, const error_category & ecat,
const std::string & what_arg );</pre>
<blockquote>
<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>
&& std::strcmp( this->runtime_error::what(), what_arg.c_str() ) == 0</code></p>
</blockquote>
-<pre>system_error( error_code::value_type ev, const error_category & ecat );</pre>
+<pre>system_error( int ev, const error_category & ecat );</pre>
<blockquote>
<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>
@@ -754,14 +830,15 @@
</blockquote>
<hr>
-<p>© Copyright Beman Dawes, 2006, 2007<br>
-Distributed under the Boost Software License, Version 1.0. See
-www.boost.org/LICENSE_1_0.txt</p>
-
<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>© Copyright Beman Dawes, 2006, 2007, 2008</p>
+
+<p>Distributed under the Boost Software License, Version 1.0. See
+www.boost.org/LICENSE_1_0.txt</p>
+
</body>
</html>
\ No newline at end of file
Modified: branches/release/libs/system/src/error_code.cpp
==============================================================================
--- branches/release/libs/system/src/error_code.cpp (original)
+++ branches/release/libs/system/src/error_code.cpp 2008-10-12 09:51:47 EDT (Sun, 12 Oct 2008)
@@ -61,11 +61,12 @@
const char * generic_error_category::name() const
{
- return "GENERIC";
+ return "generic";
}
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,
// however, we fallback to strerror in certain cases because:
// -- Windows doesn't provide strerror_r.
@@ -81,15 +82,19 @@
|| (defined(__osf__) && !defined(_REENTRANT))\
|| (defined(__vms))
const char * c_str = std::strerror( ev );
- return std::string( c_str ? c_str : "Unknown error" );
- # else
+ return c_str
+ ? std::string( c_str )
+ : unknown_err;
+ # else // use strerror_r
char buf[64];
char * bp = buf;
std::size_t sz = sizeof(buf);
# if defined(__CYGWIN__) || defined(__USE_GNU)
// Oddball version of strerror_r
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
// POSIX version of strerror_r
int result;
@@ -100,7 +105,9 @@
# if defined (__sgi)
const char * c_str = strerror( ev );
result = 0;
- return std::string( c_str ? c_str : "Unknown error" );
+ return c_str
+ ? std::string( c_str )
+ : unknown_err;
# else
result = strerror_r( ev, bp, sz );
# endif
@@ -113,26 +120,31 @@
result = errno;
# endif
if ( result != ERANGE ) break;
- if ( sz > sizeof(buf) ) std::free( bp );
- sz *= 2;
- if ( (bp = static_cast<char*>(std::malloc( sz ))) == 0 )
- return std::string( "ENOMEM" );
+ if ( sz > sizeof(buf) ) std::free( bp );
+ sz *= 2;
+ if ( (bp = static_cast<char*>(std::malloc( sz ))) == 0 )
+ return std::string( "ENOMEM" );
}
}
+ std::string msg;
try
{
- std::string msg( ( result == invalid_argument ) ? "Unknown error" : bp );
- if ( sz > sizeof(buf) ) std::free( bp );
- sz = 0;
- return msg;
+ msg = ( ( result == invalid_argument ) ? "Unknown error" : bp );
}
+
+# ifndef BOOST_NO_EXCEPTIONS
+ // See ticket #2098
catch(...)
{
- if ( sz > sizeof(buf) ) std::free( bp );
- throw;
+ // just eat the exception
}
- # endif
- # endif
+# endif
+
+ if ( sz > sizeof(buf) ) std::free( bp );
+ sz = 0;
+ return msg;
+ # endif // else POSIX version of strerror_r
+ # endif // else use strerror_r
}
// system_error_category implementation --------------------------------//
@@ -154,7 +166,9 @@
case EADDRNOTAVAIL: return make_error_condition( address_not_available );
case EAFNOSUPPORT: return make_error_condition( address_family_not_supported );
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 );
+# endif
case EBADF: return make_error_condition( bad_file_descriptor );
case EBADMSG: return make_error_condition( bad_message );
case EBUSY: return make_error_condition( device_or_resource_busy );
@@ -396,6 +410,12 @@
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()
{
static const system_error_category system_category_const;
Modified: branches/release/libs/system/test/Jamfile.v2
==============================================================================
--- branches/release/libs/system/test/Jamfile.v2 (original)
+++ branches/release/libs/system/test/Jamfile.v2 2008-10-12 09:51:47 EDT (Sun, 12 Oct 2008)
@@ -10,7 +10,6 @@
project
: requirements
<library>/boost/system//boost_system
- <define>BOOST_ALL_NO_LIB
<toolset>msvc:<asynch-exceptions>on
;
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk