mirror of
https://github.com/boostorg/system.git
synced 2026-04-18 07:38:38 +02:00
Compare commits
35 Commits
boost-1.36
...
boost-1.41
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c7ab2022e8 | ||
|
|
cf8fbe855f | ||
|
|
691fb5522c | ||
|
|
e8e4f47902 | ||
|
|
078a1f23c4 | ||
|
|
accf4f8414 | ||
|
|
3f26239374 | ||
|
|
fd0605bd7e | ||
|
|
83db702d99 | ||
|
|
e6f66bfc95 | ||
|
|
f1cdde273a | ||
|
|
5bc362e4f3 | ||
|
|
40612c12db | ||
|
|
a6728e5fb9 | ||
|
|
99ee7ddaab | ||
|
|
3e8a2633f4 | ||
|
|
888786e838 | ||
|
|
726478b372 | ||
|
|
dca57ac132 | ||
|
|
d19e139e11 | ||
|
|
4dc986ca03 | ||
|
|
214ed40b22 | ||
|
|
b4cc289238 | ||
|
|
a753ffd26f | ||
|
|
ee16863a40 | ||
|
|
463cefcf94 | ||
|
|
84ff2d0f04 | ||
|
|
b7cd247b64 | ||
|
|
d6446d1cfb | ||
|
|
a97517585c | ||
|
|
2953464e99 | ||
|
|
69d2a2234c | ||
|
|
98a757dbf7 | ||
|
|
51e9c56427 | ||
|
|
fcdecd4c96 |
@@ -39,6 +39,7 @@
|
||||
<td width="100%" bgcolor="#E8F5FF">
|
||||
<a href="#Introduction">Introduction</a><br>
|
||||
<a href="#Macros">Macros</a><br>
|
||||
<a href="#Deprecated-names">Deprecated names</a><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>
|
||||
<a href="#Class-error_category-synopsis">Class <code>error_category</code> synopsis</a><br>
|
||||
@@ -57,6 +58,8 @@
|
||||
<a href="#Class-error_condition-constructors">Class <code>error_condition</code> constructors</a><br>
|
||||
<a href="#Class-error_condition-modifiers">Class <code>error_condition</code> modifiers</a><br>
|
||||
<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="#Header-system_error">Header <boost/system/system_error.hpp></a><br>
|
||||
<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>
|
||||
</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 @@ provided, so users may ignore these macros if they prefer.</p>
|
||||
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 <a href="#throws-object">throws</a>;
|
||||
|
||||
// <a href="#Non-member-functions">non-member functions</a>
|
||||
|
||||
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 @@ types should create a single object of each such type. <i>
|
||||
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 @@ this subclause.</p>
|
||||
<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 @@ non-member functions</a></h3>
|
||||
<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</code> synopsis</a></h3>
|
||||
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 @@ error_code</code> synopsis</a></h3>
|
||||
|
||||
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> constructors</a></h3>
|
||||
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 @@ error_code</code> observers</a></h3>
|
||||
<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 @@ error_code</code> observers</a></h3>
|
||||
</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 @@ implementation specific. <i>--end note ]</i></p>
|
||||
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 @@ constructors</a></h3>
|
||||
<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 @@ constructors</a></h3>
|
||||
</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 @@ modifiers</a></h3>
|
||||
</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 @@ observers</a></h3>
|
||||
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>
|
||||
<a href="#Class-error_category">error_category</a></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><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>
|
||||
<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 @@ bool operator!=( const error_condition & condition, const error_code & c
|
||||
</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 @@ bool operator!=( const error_condition & condition, const error_code & c
|
||||
<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><a href="#Class-error_code">error_code</a></code>. Such errors typically originate from operating system or other low-level
|
||||
application program interfaces.</p>
|
||||
<blockquote>
|
||||
<pre>namespace boost
|
||||
@@ -691,11 +767,11 @@ application program interfaces.</p>
|
||||
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 @@ application program interfaces.</p>
|
||||
<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 @@ application program interfaces.</p>
|
||||
</blockquote>
|
||||
<hr>
|
||||
|
||||
<p>© 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
|
||||
<!--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
|
||||
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/LICENSE_1_0.txt</a></p>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -183,11 +183,14 @@ namespace boost
|
||||
{
|
||||
public:
|
||||
virtual ~error_category(){}
|
||||
virtual inline const char * name() const; // see implementation note below
|
||||
virtual inline std::string message( int ev ) const; // see implementation note below
|
||||
virtual inline error_condition default_error_condition( int ev ) const;
|
||||
virtual inline bool equivalent( int code, const error_condition & condition ) const;
|
||||
virtual inline bool equivalent( const error_code & code, int condition ) const;
|
||||
|
||||
virtual const char * name() const = 0;
|
||||
virtual std::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;
|
||||
|
||||
bool operator==(const error_category & rhs) const { return this == &rhs; }
|
||||
bool operator!=(const error_category & rhs) const { return this != &rhs; }
|
||||
@@ -207,6 +210,7 @@ namespace boost
|
||||
|
||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||
// deprecated synonyms
|
||||
inline const error_category & get_posix_category() { return get_generic_category(); }
|
||||
static const error_category & posix_category = get_generic_category();
|
||||
static const error_category & errno_ecat = get_generic_category();
|
||||
static const error_category & native_ecat = get_system_category();
|
||||
@@ -214,7 +218,7 @@ namespace boost
|
||||
|
||||
// class error_condition -----------------------------------------------//
|
||||
|
||||
// error_conditions are portable, error_codes are system or lib specific
|
||||
// error_conditions are portable, error_codes are system or library specific
|
||||
|
||||
class error_condition
|
||||
{
|
||||
@@ -224,9 +228,9 @@ namespace boost
|
||||
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 +243,9 @@ namespace boost
|
||||
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 +315,9 @@ namespace boost
|
||||
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 +329,9 @@ namespace boost
|
||||
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 +386,31 @@ namespace boost
|
||||
|
||||
};
|
||||
|
||||
// predefined error_code object used as "throw on error" tag
|
||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||
BOOST_SYSTEM_DECL extern error_code throws;
|
||||
# endif
|
||||
|
||||
// Moving from a "throws" object to a "throws" function without breaking
|
||||
// existing code is a bit of a problem. The workaround is to place the
|
||||
// "throws" function in namespace boost rather than namespace boost::system.
|
||||
|
||||
} // namespace system
|
||||
|
||||
namespace detail { inline system::error_code * throws() { return 0; } }
|
||||
// Misuse of the error_code object is turned into a noisy failure by
|
||||
// poisoning the reference. This particular implementation doesn't
|
||||
// produce warnings or errors from popular compilers, is very efficient
|
||||
// (as determined by inspecting generated code), and does not suffer
|
||||
// from order of initialization problems. In practice, it also seems
|
||||
// cause user function error handling implementation errors to be detected
|
||||
// very early in the development cycle.
|
||||
|
||||
inline system::error_code & throws()
|
||||
{ return *detail::throws(); }
|
||||
|
||||
namespace system
|
||||
{
|
||||
// non-member functions ------------------------------------------------//
|
||||
|
||||
inline bool operator!=( const error_code & lhs,
|
||||
@@ -470,19 +499,6 @@ namespace boost
|
||||
return *this == code.category() && code.value() == condition;
|
||||
}
|
||||
|
||||
// error_category implementation note: VC++ 8.0 objects to name() and
|
||||
// message() being pure virtual functions. Thus these implementations.
|
||||
inline const char * error_category::name() const
|
||||
{
|
||||
return "error: should never be called";
|
||||
}
|
||||
|
||||
inline std::string error_category::message( int ) const
|
||||
{
|
||||
static std::string s("error: should never be called");
|
||||
return s;
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
} // namespace boost
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include <cassert>
|
||||
|
||||
using namespace boost::system;
|
||||
using namespace boost::system::posix_error;
|
||||
using namespace boost::system::errc;
|
||||
|
||||
#include <cstring> // for strerror/strerror_r
|
||||
|
||||
@@ -61,11 +61,12 @@ namespace
|
||||
|
||||
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.
|
||||
@@ -79,17 +80,22 @@ namespace
|
||||
# if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\
|
||||
|| (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\
|
||||
|| (defined(__osf__) && !defined(_REENTRANT))\
|
||||
|| (defined(__vms))
|
||||
|| (defined(__vms))\
|
||||
|| (defined(__QNXNTO__))
|
||||
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 +106,9 @@ namespace
|
||||
# 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 +121,31 @@ namespace
|
||||
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 +167,9 @@ namespace
|
||||
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 +411,14 @@ namespace boost
|
||||
namespace system
|
||||
{
|
||||
|
||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||
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
|
||||
# endif
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & get_system_category()
|
||||
{
|
||||
static const system_error_category system_category_const;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
project
|
||||
: requirements
|
||||
<library>/boost/system//boost_system
|
||||
<define>BOOST_ALL_NO_LIB
|
||||
<toolset>msvc:<asynch-exceptions>on
|
||||
;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <boost/config/warning_disable.hpp>
|
||||
|
||||
#include <boost/test/minimal.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <boost/system/error_code.hpp>
|
||||
#include <boost/system/cygwin_error.hpp>
|
||||
#include <boost/system/linux_error.hpp>
|
||||
@@ -45,100 +45,100 @@ namespace
|
||||
|
||||
ss << ec;
|
||||
ss >> s;
|
||||
BOOST_CHECK( s == expected );
|
||||
BOOST_TEST( s == expected );
|
||||
}
|
||||
}
|
||||
|
||||
// test_main ---------------------------------------------------------------//
|
||||
// main ------------------------------------------------------------------------------//
|
||||
|
||||
// TODO: add hash_value tests
|
||||
|
||||
int test_main( int, char ** )
|
||||
int main( int, char ** )
|
||||
{
|
||||
|
||||
std::cout << "General tests...\n";
|
||||
// unit tests:
|
||||
|
||||
BOOST_CHECK( posix_category == posix_category );
|
||||
BOOST_CHECK( system_category == system_category );
|
||||
BOOST_CHECK( posix_category != system_category );
|
||||
BOOST_CHECK( system_category != posix_category );
|
||||
BOOST_TEST( posix_category == posix_category );
|
||||
BOOST_TEST( system_category == system_category );
|
||||
BOOST_TEST( posix_category != system_category );
|
||||
BOOST_TEST( system_category != posix_category );
|
||||
|
||||
if ( std::less<const error_category*>()( &posix_category, &system_category ) )
|
||||
{
|
||||
BOOST_CHECK( posix_category < system_category );
|
||||
BOOST_CHECK( !(system_category < posix_category) );
|
||||
BOOST_TEST( posix_category < system_category );
|
||||
BOOST_TEST( !(system_category < posix_category) );
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_CHECK( system_category < posix_category );
|
||||
BOOST_CHECK( !(posix_category < system_category) );
|
||||
BOOST_TEST( system_category < posix_category );
|
||||
BOOST_TEST( !(posix_category < system_category) );
|
||||
}
|
||||
|
||||
|
||||
error_code ec;
|
||||
error_condition dec;
|
||||
BOOST_CHECK( !ec );
|
||||
BOOST_CHECK( ec.value() == 0 );
|
||||
BOOST_TEST( !ec );
|
||||
BOOST_TEST( ec.value() == 0 );
|
||||
dec = ec.default_error_condition();
|
||||
BOOST_CHECK( dec.value() == 0 );
|
||||
BOOST_CHECK( dec.category() == posix_category );
|
||||
BOOST_CHECK( ec == posix::success );
|
||||
BOOST_CHECK( ec.category() == system_category );
|
||||
BOOST_CHECK( std::strcmp( ec.category().name(), "system") == 0 );
|
||||
BOOST_CHECK( !(ec < error_code( 0, system_category )) );
|
||||
BOOST_CHECK( !(error_code( 0, system_category ) < ec) );
|
||||
BOOST_CHECK( ec < error_code( 1, system_category ) );
|
||||
BOOST_CHECK( !(error_code( 1, system_category ) < ec) );
|
||||
BOOST_TEST( dec.value() == 0 );
|
||||
BOOST_TEST( dec.category() == posix_category );
|
||||
BOOST_TEST( ec == posix::success );
|
||||
BOOST_TEST( ec.category() == system_category );
|
||||
BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 );
|
||||
BOOST_TEST( !(ec < error_code( 0, system_category )) );
|
||||
BOOST_TEST( !(error_code( 0, system_category ) < ec) );
|
||||
BOOST_TEST( ec < error_code( 1, system_category ) );
|
||||
BOOST_TEST( !(error_code( 1, system_category ) < ec) );
|
||||
|
||||
error_code ec_0_system( 0, system_category );
|
||||
BOOST_CHECK( !ec_0_system );
|
||||
BOOST_CHECK( ec_0_system.value() == 0 );
|
||||
BOOST_TEST( !ec_0_system );
|
||||
BOOST_TEST( ec_0_system.value() == 0 );
|
||||
dec = ec_0_system.default_error_condition();
|
||||
BOOST_CHECK( dec.value() == 0 );
|
||||
BOOST_CHECK( dec.category() == posix_category );
|
||||
BOOST_CHECK( ec_0_system == posix::success );
|
||||
BOOST_CHECK( ec_0_system.category() == system_category );
|
||||
BOOST_CHECK( std::strcmp( ec_0_system.category().name(), "system") == 0 );
|
||||
BOOST_TEST( dec.value() == 0 );
|
||||
BOOST_TEST( dec.category() == posix_category );
|
||||
BOOST_TEST( ec_0_system == posix::success );
|
||||
BOOST_TEST( ec_0_system.category() == system_category );
|
||||
BOOST_TEST( std::strcmp( ec_0_system.category().name(), "system") == 0 );
|
||||
check_ostream( ec_0_system, "system:0" );
|
||||
|
||||
BOOST_CHECK( ec_0_system == ec );
|
||||
BOOST_TEST( ec_0_system == ec );
|
||||
|
||||
error_code ec_1_system( 1, system_category );
|
||||
BOOST_CHECK( ec_1_system );
|
||||
BOOST_CHECK( ec_1_system.value() == 1 );
|
||||
BOOST_CHECK( ec_1_system.value() != 0 );
|
||||
BOOST_CHECK( ec != ec_1_system );
|
||||
BOOST_CHECK( ec_0_system != ec_1_system );
|
||||
BOOST_TEST( ec_1_system );
|
||||
BOOST_TEST( ec_1_system.value() == 1 );
|
||||
BOOST_TEST( ec_1_system.value() != 0 );
|
||||
BOOST_TEST( ec != ec_1_system );
|
||||
BOOST_TEST( ec_0_system != ec_1_system );
|
||||
check_ostream( ec_1_system, "system:1" );
|
||||
|
||||
ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category );
|
||||
BOOST_CHECK( ec );
|
||||
BOOST_CHECK( ec.value() == BOOST_ACCESS_ERROR_MACRO );
|
||||
BOOST_TEST( ec );
|
||||
BOOST_TEST( ec.value() == BOOST_ACCESS_ERROR_MACRO );
|
||||
dec = ec.default_error_condition();
|
||||
BOOST_CHECK( dec.value() == static_cast<int>(posix::permission_denied) );
|
||||
BOOST_CHECK( dec.category() == posix_category );
|
||||
BOOST_CHECK( dec == error_condition( posix::permission_denied, posix_category ) );
|
||||
BOOST_CHECK( dec == posix::permission_denied );
|
||||
BOOST_CHECK( posix::permission_denied == dec );
|
||||
BOOST_CHECK( ec == posix::permission_denied );
|
||||
BOOST_CHECK( ec.category() == system_category );
|
||||
BOOST_CHECK( std::strcmp( ec.category().name(), "system") == 0 );
|
||||
BOOST_TEST( dec.value() == static_cast<int>(posix::permission_denied) );
|
||||
BOOST_TEST( dec.category() == posix_category );
|
||||
BOOST_TEST( dec == error_condition( posix::permission_denied, posix_category ) );
|
||||
BOOST_TEST( dec == posix::permission_denied );
|
||||
BOOST_TEST( posix::permission_denied == dec );
|
||||
BOOST_TEST( ec == posix::permission_denied );
|
||||
BOOST_TEST( ec.category() == system_category );
|
||||
BOOST_TEST( std::strcmp( ec.category().name(), "system") == 0 );
|
||||
|
||||
// test the explicit make_error_code conversion for posix
|
||||
ec = make_error_code( posix::bad_message );
|
||||
BOOST_CHECK( ec );
|
||||
BOOST_CHECK( ec == posix::bad_message );
|
||||
BOOST_CHECK( posix::bad_message == ec );
|
||||
BOOST_CHECK( ec != posix::permission_denied );
|
||||
BOOST_CHECK( posix::permission_denied != ec );
|
||||
BOOST_CHECK( ec.category() == posix_category );
|
||||
BOOST_TEST( ec );
|
||||
BOOST_TEST( ec == posix::bad_message );
|
||||
BOOST_TEST( posix::bad_message == ec );
|
||||
BOOST_TEST( ec != posix::permission_denied );
|
||||
BOOST_TEST( posix::permission_denied != ec );
|
||||
BOOST_TEST( ec.category() == posix_category );
|
||||
|
||||
// test the deprecated predefined error_category synonyms
|
||||
BOOST_CHECK( &system_category == &native_ecat );
|
||||
BOOST_CHECK( &posix_category == &errno_ecat );
|
||||
BOOST_CHECK( system_category == native_ecat );
|
||||
BOOST_CHECK( posix_category == errno_ecat );
|
||||
BOOST_TEST( &system_category == &native_ecat );
|
||||
BOOST_TEST( &posix_category == &errno_ecat );
|
||||
BOOST_TEST( system_category == native_ecat );
|
||||
BOOST_TEST( posix_category == errno_ecat );
|
||||
|
||||
// test error_code and error_condition message();
|
||||
// see Boost.Filesystem operations_test for code specific message() tests
|
||||
@@ -146,120 +146,120 @@ int test_main( int, char ** )
|
||||
std::cout << "error_code message for -1 is \"" << ec.message() << "\"\n";
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
// Borland appends newline, so just check text
|
||||
BOOST_CHECK( ec.message().substr(0,13) == "Unknown error" );
|
||||
BOOST_TEST( ec.message().substr(0,13) == "Unknown error" );
|
||||
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||
// Linux appends value to message as unsigned, so it varies with # of bits
|
||||
BOOST_CHECK( ec.message().substr(0,13) == "Unknown error" );
|
||||
BOOST_TEST( ec.message().substr(0,13) == "Unknown error" );
|
||||
#elif defined(__hpux)
|
||||
BOOST_CHECK( ec.message() == "" );
|
||||
BOOST_TEST( ec.message() == "" );
|
||||
#elif defined(__osf__)
|
||||
BOOST_CHECK( ec.message() == "Error -1 occurred." );
|
||||
BOOST_TEST( ec.message() == "Error -1 occurred." );
|
||||
#elif defined(__vms)
|
||||
BOOST_CHECK( ec.message() == "error -1" );
|
||||
BOOST_TEST( ec.message() == "error -1" );
|
||||
#endif
|
||||
|
||||
ec = error_code( BOOST_ACCESS_ERROR_MACRO, system_category );
|
||||
BOOST_CHECK( ec.message() != "" );
|
||||
BOOST_CHECK( ec.message().substr( 0, 13) != "Unknown error" );
|
||||
BOOST_TEST( ec.message() != "" );
|
||||
BOOST_TEST( ec.message().substr( 0, 13) != "Unknown error" );
|
||||
|
||||
dec = error_condition( -1, posix_category );
|
||||
std::cout << "error_condition message for -1 is \"" << dec.message() << "\"\n";
|
||||
#if defined(BOOST_WINDOWS_API)
|
||||
// Borland appends newline, so just check text
|
||||
BOOST_CHECK( dec.message().substr(0,13) == "Unknown error" );
|
||||
BOOST_TEST( dec.message().substr(0,13) == "Unknown error" );
|
||||
#elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||
// Linux appends value to message as unsigned, so it varies with # of bits
|
||||
BOOST_CHECK( dec.message().substr(0,13) == "Unknown error" );
|
||||
BOOST_TEST( dec.message().substr(0,13) == "Unknown error" );
|
||||
#elif defined(__hpux)
|
||||
BOOST_CHECK( dec.message() == "" );
|
||||
BOOST_TEST( dec.message() == "" );
|
||||
#elif defined(__osf__)
|
||||
BOOST_CHECK( dec.message() == "Error -1 occurred." );
|
||||
BOOST_TEST( dec.message() == "Error -1 occurred." );
|
||||
#elif defined(__vms)
|
||||
BOOST_CHECK( dec.message() == "error -1" );
|
||||
BOOST_TEST( dec.message() == "error -1" );
|
||||
#endif
|
||||
|
||||
dec = error_condition( BOOST_ACCESS_ERROR_MACRO, posix_category );
|
||||
BOOST_CHECK( dec.message() != "" );
|
||||
BOOST_CHECK( dec.message().substr( 0, 13) != "Unknown error" );
|
||||
BOOST_TEST( dec.message() != "" );
|
||||
BOOST_TEST( dec.message().substr( 0, 13) != "Unknown error" );
|
||||
|
||||
#ifdef BOOST_WINDOWS_API
|
||||
std::cout << "Windows tests...\n";
|
||||
// these tests probe the Windows posix decoder
|
||||
// test the first entry in the decoder table:
|
||||
ec = error_code( ERROR_ACCESS_DENIED, system_category );
|
||||
BOOST_CHECK( ec.value() == ERROR_ACCESS_DENIED );
|
||||
BOOST_CHECK( ec == posix::permission_denied );
|
||||
BOOST_CHECK( ec.default_error_condition().value() == posix::permission_denied );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == posix_category );
|
||||
BOOST_TEST( ec.value() == ERROR_ACCESS_DENIED );
|
||||
BOOST_TEST( ec == posix::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == posix_category );
|
||||
|
||||
// test the second entry in the decoder table:
|
||||
ec = error_code( ERROR_ALREADY_EXISTS, system_category );
|
||||
BOOST_CHECK( ec.value() == ERROR_ALREADY_EXISTS );
|
||||
BOOST_CHECK( ec == posix::file_exists );
|
||||
BOOST_CHECK( ec.default_error_condition().value() == posix::file_exists );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == posix_category );
|
||||
BOOST_TEST( ec.value() == ERROR_ALREADY_EXISTS );
|
||||
BOOST_TEST( ec == posix::file_exists );
|
||||
BOOST_TEST( ec.default_error_condition().value() == posix::file_exists );
|
||||
BOOST_TEST( ec.default_error_condition().category() == posix_category );
|
||||
|
||||
// test the third entry in the decoder table:
|
||||
ec = error_code( ERROR_BAD_UNIT, system_category );
|
||||
BOOST_CHECK( ec.value() == ERROR_BAD_UNIT );
|
||||
BOOST_CHECK( ec == posix::no_such_device );
|
||||
BOOST_CHECK( ec.default_error_condition().value() == posix::no_such_device );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == posix_category );
|
||||
BOOST_TEST( ec.value() == ERROR_BAD_UNIT );
|
||||
BOOST_TEST( ec == posix::no_such_device );
|
||||
BOOST_TEST( ec.default_error_condition().value() == posix::no_such_device );
|
||||
BOOST_TEST( ec.default_error_condition().category() == posix_category );
|
||||
|
||||
// test the last non-Winsock entry in the decoder table:
|
||||
ec = error_code( ERROR_WRITE_PROTECT, system_category );
|
||||
BOOST_CHECK( ec.value() == ERROR_WRITE_PROTECT );
|
||||
BOOST_CHECK( ec == posix::permission_denied );
|
||||
BOOST_CHECK( ec.default_error_condition().value() == posix::permission_denied );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == posix_category );
|
||||
BOOST_TEST( ec.value() == ERROR_WRITE_PROTECT );
|
||||
BOOST_TEST( ec == posix::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == posix_category );
|
||||
|
||||
// test the last Winsock entry in the decoder table:
|
||||
ec = error_code( WSAEWOULDBLOCK, system_category );
|
||||
BOOST_CHECK( ec.value() == WSAEWOULDBLOCK );
|
||||
BOOST_CHECK( ec == posix::operation_would_block );
|
||||
BOOST_CHECK( ec.default_error_condition().value() == posix::operation_would_block );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == posix_category );
|
||||
BOOST_TEST( ec.value() == WSAEWOULDBLOCK );
|
||||
BOOST_TEST( ec == posix::operation_would_block );
|
||||
BOOST_TEST( ec.default_error_condition().value() == posix::operation_would_block );
|
||||
BOOST_TEST( ec.default_error_condition().category() == posix_category );
|
||||
|
||||
// test not-in-table condition:
|
||||
ec = error_code( 1234567890, system_category );
|
||||
BOOST_CHECK( ec.value() == 1234567890 );
|
||||
BOOST_CHECK( ec.default_error_condition().value() == 1234567890 );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == system_category );
|
||||
BOOST_TEST( ec.value() == 1234567890 );
|
||||
BOOST_TEST( ec.default_error_condition().value() == 1234567890 );
|
||||
BOOST_TEST( ec.default_error_condition().category() == system_category );
|
||||
|
||||
#else // POSIX
|
||||
|
||||
std::cout << "POSIX tests...\n";
|
||||
ec = error_code( EACCES, system_category );
|
||||
BOOST_CHECK( ec == error_code( posix::permission_denied, system_category ) );
|
||||
BOOST_CHECK( error_code( posix::permission_denied, system_category ) == ec );
|
||||
BOOST_CHECK( ec == posix::permission_denied );
|
||||
BOOST_CHECK( posix::permission_denied == ec );
|
||||
BOOST_CHECK( ec.default_error_condition().value() == posix::permission_denied );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == posix_category );
|
||||
BOOST_TEST( ec == error_code( posix::permission_denied, system_category ) );
|
||||
BOOST_TEST( error_code( posix::permission_denied, system_category ) == ec );
|
||||
BOOST_TEST( ec == posix::permission_denied );
|
||||
BOOST_TEST( posix::permission_denied == ec );
|
||||
BOOST_TEST( ec.default_error_condition().value() == posix::permission_denied );
|
||||
BOOST_TEST( ec.default_error_condition().category() == posix_category );
|
||||
|
||||
# ifdef __CYGWIN__
|
||||
|
||||
std::cout << "Cygwin tests...\n";
|
||||
ec = cygwin_error::no_package;
|
||||
BOOST_CHECK( ec == cygwin_error::no_package );
|
||||
BOOST_CHECK( ec == error_code( ENOPKG, system_category ) );
|
||||
BOOST_CHECK( ec == error_code( cygwin_error::no_package, system_category ) );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == system_category );
|
||||
BOOST_TEST( ec == cygwin_error::no_package );
|
||||
BOOST_TEST( ec == error_code( ENOPKG, system_category ) );
|
||||
BOOST_TEST( ec == error_code( cygwin_error::no_package, system_category ) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == system_category );
|
||||
|
||||
# elif defined(linux) || defined(__linux) || defined(__linux__)
|
||||
|
||||
std::cout << "Linux tests...\n";
|
||||
ec = linux_error::dot_dot_error;
|
||||
BOOST_CHECK( ec == linux_error::dot_dot_error );
|
||||
BOOST_CHECK( ec == error_code( EDOTDOT, system_category ) );
|
||||
BOOST_CHECK( ec == error_code( linux_error::dot_dot_error, system_category ) );
|
||||
BOOST_CHECK( ec.default_error_condition().category() == system_category );
|
||||
BOOST_TEST( ec == linux_error::dot_dot_error );
|
||||
BOOST_TEST( ec == error_code( EDOTDOT, system_category ) );
|
||||
BOOST_TEST( ec == error_code( linux_error::dot_dot_error, system_category ) );
|
||||
BOOST_TEST( ec.default_error_condition().category() == system_category );
|
||||
|
||||
# endif
|
||||
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
return ::boost::report_errors();
|
||||
}
|
||||
|
||||
|
||||
|
||||
18
test/system_msvc/common.vsprops
Normal file
18
test/system_msvc/common.vsprops
Normal 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=""$(TargetDir)\$(TargetName).exe" --result_code=no --report_level=no"
|
||||
/>
|
||||
</VisualStudioPropertySheet>
|
||||
199
test/system_msvc/error_code_test/error_code_test.vcproj
Normal file
199
test/system_msvc/error_code_test/error_code_test.vcproj
Normal 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>
|
||||
20
test/system_msvc/system_msvc.sln
Normal file
20
test/system_msvc/system_msvc.sln
Normal 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
|
||||
Reference in New Issue
Block a user