forked from boostorg/system
Add separate headers for system-specific enums, thus reducing coupling. Suggested by Emil Dotchevski.
[SVN r41033]
This commit is contained in:
@@ -43,6 +43,22 @@
|
|||||||
<a href="#Acknowledgements">Acknowledgements</a>
|
<a href="#Acknowledgements">Acknowledgements</a>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="100%" bgcolor="#D7EEFF" align="center">
|
||||||
|
<b><i>Headers</i></b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td width="100%" bgcolor="#E8F5FF">
|
||||||
|
<a href="reference.html#Header-error_code"><boost/system/error_code.hpp></a><br>
|
||||||
|
<a href="reference.html#Header-system_error">
|
||||||
|
<boost/system/system_error.hpp></a><br>
|
||||||
|
<a href="../../../boost/system/cygwin_error.hpp">
|
||||||
|
<boost/system/cygwin_error.hpp></a><br>
|
||||||
|
<a href="../../../boost/system/linux_error.hpp">
|
||||||
|
<boost/system/linux_error.hpp></a><br>
|
||||||
|
<a href="../../../boost/system/windows_error.hpp">
|
||||||
|
<boost/system/windows_error.hpp></a></td>
|
||||||
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
<h2><a name="Introduction">Introduction</a></h2>
|
<h2><a name="Introduction">Introduction</a></h2>
|
||||||
@@ -73,6 +89,10 @@ than via throwing exceptions. Otherwise, when errors are not exceptional
|
|||||||
occurrences and must be dealt with as they arise, programs become littered with
|
occurrences and must be dealt with as they arise, programs become littered with
|
||||||
try/catch blocks, unreadable, and very inefficient. The Boost System library
|
try/catch blocks, unreadable, and very inefficient. The Boost System library
|
||||||
supports both error reporting by exception and by error code.</p>
|
supports both error reporting by exception and by error code.</p>
|
||||||
|
<p>In addition to portable errors codes and conditions supported by the <code>
|
||||||
|
error_code.hpp</code> header, system-specific headers support the Cygwin, Linux,
|
||||||
|
and Windows platforms. These headers are effectively no-ops if included for
|
||||||
|
platforms other than their intended target.</p>
|
||||||
<h2><a name="Design_Rationale">Design Rationale</a></h2>
|
<h2><a name="Design_Rationale">Design Rationale</a></h2>
|
||||||
<p>Class <code>error_code</code> and <code>error_condition</code> are designed as a value types so
|
<p>Class <code>error_code</code> and <code>error_condition</code> are designed as a value types so
|
||||||
they can be copied
|
they can be copied
|
||||||
@@ -117,7 +137,7 @@ 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>
|
<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 -->September 14, 2007<!--webbot bot="Timestamp" endspan i-checksum="37985" --> </font>
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->November 12, 2007<!--webbot bot="Timestamp" endspan i-checksum="39581" --> </font>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
@@ -38,6 +38,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<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="#Header-error_code">Header <boost/system/error_code.hpp></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">Class <code>error_category</code></a><br>
|
||||||
<a href="#Class-error_category-synopsis">Class <code>error_category</code> synopsis</a><br>
|
<a href="#Class-error_category-synopsis">Class <code>error_category</code> synopsis</a><br>
|
||||||
@@ -68,8 +69,51 @@
|
|||||||
<p>This reference documentation describes components that
|
<p>This reference documentation describes components that
|
||||||
programs may use to report error conditions originating from the operating
|
programs may use to report error conditions originating from the operating
|
||||||
system or other low-level application program interfaces.</p>
|
system or other low-level application program interfaces.</p>
|
||||||
<p>System Library components do not change the value of <code>
|
<p>Boost.System library components never change the value of <code>
|
||||||
errno</code>.</p>
|
errno</code>.</p>
|
||||||
|
<h2><a name="Macros">Macros</a></h2>
|
||||||
|
<p>Users may defined the following macros if desired. Sensible defaults are
|
||||||
|
provided, so users may ignore these macros if they prefer.</p>
|
||||||
|
<table border="1" cellpadding="5" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111">
|
||||||
|
<tr>
|
||||||
|
<td><b><i>Macro Name</i></b></td>
|
||||||
|
<td><b><i>Default</i></b></td>
|
||||||
|
<td><b><i>Effect if defined</i></b></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><code>BOOST_WINDOWS_API</code></td>
|
||||||
|
<td valign="top">Defined if Windows is detected by Boost.System's automatic configuration
|
||||||
|
code, otherwise not defined.</td>
|
||||||
|
<td valign="top">Implementation uses the Microsoft Windows native
|
||||||
|
application program interface (API).</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><code>BOOST_POSIX_API</code></td>
|
||||||
|
<td valign="top">Defined if Windows is not detected by Boost.System's automatic configuration
|
||||||
|
code.</td>
|
||||||
|
<td valign="top">Implementation uses the POSIX native
|
||||||
|
application program interface (API).</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><code>BOOST_SYSTEM_DYN_LINK</code></td>
|
||||||
|
<td valign="top">Defined if <code>BOOST_ALL_DYN_LINK</code> is defined,
|
||||||
|
otherwise not defined.</td>
|
||||||
|
<td valign="top">Boost.System library is dynamically linked. If not defined,
|
||||||
|
static linking is assumed.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><code>BOOST_SYSTEM_NO_LIB</code></td>
|
||||||
|
<td valign="top">Defined if <code>BOOST_ALL_NO_LIB</code> is defined,
|
||||||
|
otherwise not defined.</td>
|
||||||
|
<td valign="top">Boost.System library does not use the Boost auto-link
|
||||||
|
facility.</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td valign="top"><code>BOOST_SYSTEM_NO_DEPRECATED</code></td>
|
||||||
|
<td valign="top">Not defined.</td>
|
||||||
|
<td valign="top">Deprecated features are excluded.</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
<h2><a name="Header-error_code">Header <boost/system/error_code.hpp></a></h2>
|
<h2><a name="Header-error_code">Header <boost/system/error_code.hpp></a></h2>
|
||||||
<h3><boost/system/error_code.hpp> synopsis</h3>
|
<h3><boost/system/error_code.hpp> synopsis</h3>
|
||||||
<blockquote>
|
<blockquote>
|
||||||
@@ -699,7 +743,7 @@ 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>
|
<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 -->October 23, 2007<!--webbot bot="Timestamp" endspan i-checksum="30853" --> </font>
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%B %d, %Y" startspan -->November 12, 2007<!--webbot bot="Timestamp" endspan i-checksum="39581" --> </font>
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
56
include/boost/system/cygwin_error.hpp
Normal file
56
include/boost/system/cygwin_error.hpp
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
// boost/system/cygwin_error.hpp -------------------------------------------//
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2007
|
||||||
|
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#ifndef BOOST_CYGWIN_ERROR_HPP
|
||||||
|
#define BOOST_CYGWIN_ERROR_HPP
|
||||||
|
|
||||||
|
// This header is effectively empty for compiles on operating systems where
|
||||||
|
// it is not applicable.
|
||||||
|
|
||||||
|
# ifdef __CYGWIN__
|
||||||
|
|
||||||
|
#include <boost/system/error_code.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
// To construct an error_code after a API error:
|
||||||
|
//
|
||||||
|
// error_code( errno, system_category )
|
||||||
|
|
||||||
|
// User code should use the portable "posix" enums for POSIX errors; this
|
||||||
|
// allows such code to be portable to non-POSIX systems. For the non-POSIX
|
||||||
|
// errno values that POSIX-based systems typically provide in addition to
|
||||||
|
// POSIX values, use the system specific enums below.
|
||||||
|
|
||||||
|
namespace cygwin_error
|
||||||
|
{
|
||||||
|
enum cygwin_errno
|
||||||
|
{
|
||||||
|
no_net = ENONET,
|
||||||
|
no_package = ENOPKG,
|
||||||
|
no_share = ENOSHARE
|
||||||
|
};
|
||||||
|
} // namespace cygwin_error
|
||||||
|
|
||||||
|
template<> struct is_error_code_enum<cygwin_error::cygwin_errno>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
namespace cygwin_error
|
||||||
|
{
|
||||||
|
inline error_code make_error_code( cygwin_errno e )
|
||||||
|
{ return error_code( e, system_category ); }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // __CYGWIN__
|
||||||
|
|
||||||
|
#endif // BOOST_CYGWIN_ERROR_HPP
|
@@ -25,8 +25,8 @@
|
|||||||
// TODO: undef these macros if not already defined
|
// TODO: undef these macros if not already defined
|
||||||
#include <boost/cerrno.hpp>
|
#include <boost/cerrno.hpp>
|
||||||
|
|
||||||
# ifdef BOOST_WINDOWS_API
|
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
|
||||||
# include <winerror.h>
|
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
#include <boost/config/abi_prefix.hpp> // must be the last #include
|
||||||
@@ -143,6 +143,39 @@ namespace boost
|
|||||||
template<> struct is_error_condition_enum<posix_error::posix_errno>
|
template<> struct is_error_condition_enum<posix_error::posix_errno>
|
||||||
{ static const bool value = true; };
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------//
|
||||||
|
|
||||||
|
// Operating system specific interfaces --------------------------------//
|
||||||
|
|
||||||
|
|
||||||
|
// The interface is divided into general and system-specific portions to
|
||||||
|
// meet these requirements:
|
||||||
|
//
|
||||||
|
// * Code calling an operating system API can create an error_code with
|
||||||
|
// a single category (system_category), even for POSIX-like operating
|
||||||
|
// systems that return some POSIX errno values and some native errno
|
||||||
|
// values. This code should not have to pay the cost of distinguishing
|
||||||
|
// between categories, since it is not yet known if that is needed.
|
||||||
|
//
|
||||||
|
// * Users wishing to write system-specific code should be given enums for
|
||||||
|
// at least the common error cases.
|
||||||
|
//
|
||||||
|
// * System specific code should fail at compile time if moved to another
|
||||||
|
// operating system.
|
||||||
|
|
||||||
|
// The system specific portions of the interface are located in headers
|
||||||
|
// with names reflecting the operating system. For example,
|
||||||
|
//
|
||||||
|
// <boost/system/cygwin_error.hpp>
|
||||||
|
// <boost/system/linux_error.hpp>
|
||||||
|
// <boost/system/windows_error.hpp>
|
||||||
|
//
|
||||||
|
// These headers are effectively empty for compiles on operating systems
|
||||||
|
// where they are not applicable.
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------//
|
||||||
|
|
||||||
// class error_category ------------------------------------------------//
|
// class error_category ------------------------------------------------//
|
||||||
|
|
||||||
class error_category : public noncopyable
|
class error_category : public noncopyable
|
||||||
@@ -448,230 +481,6 @@ namespace boost
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------//
|
|
||||||
|
|
||||||
// Operating system specific interfaces --------------------------------//
|
|
||||||
|
|
||||||
|
|
||||||
// The interface is divided into general and system-specific portions to
|
|
||||||
// meet these requirements:
|
|
||||||
//
|
|
||||||
// * Code calling an operating system API can create an error_code with
|
|
||||||
// a single category (system_category), even for POSIX-like operating
|
|
||||||
// systems that return some POSIX errno values and some native errno
|
|
||||||
// values. This code should not have to pay the cost of distinguishing
|
|
||||||
// between categories, since it is not yet known if that is needed.
|
|
||||||
//
|
|
||||||
// * Users wishing to write system-specific code should be given enums for
|
|
||||||
// at least the common error cases.
|
|
||||||
//
|
|
||||||
// * System specific code should fail at compile time if moved to another
|
|
||||||
// operating system.
|
|
||||||
|
|
||||||
#ifdef BOOST_POSIX_API
|
|
||||||
|
|
||||||
// POSIX-based systems -------------------------------------------------//
|
|
||||||
|
|
||||||
// To construct an error_code after a API error:
|
|
||||||
//
|
|
||||||
// error_code( errno, system_category )
|
|
||||||
|
|
||||||
// User code should use the portable "posix" enums for POSIX errors; this
|
|
||||||
// allows such code to be portable to non-POSIX systems. For the non-POSIX
|
|
||||||
// errno values that POSIX-based systems typically provide in addition to
|
|
||||||
// POSIX values, use the system specific enums below.
|
|
||||||
|
|
||||||
# ifdef __CYGWIN__
|
|
||||||
|
|
||||||
namespace cygwin_error
|
|
||||||
{
|
|
||||||
enum cygwin_errno
|
|
||||||
{
|
|
||||||
no_net = ENONET,
|
|
||||||
no_package = ENOPKG,
|
|
||||||
no_share = ENOSHARE
|
|
||||||
};
|
|
||||||
} // namespace cygwin_error
|
|
||||||
|
|
||||||
template<> struct is_error_code_enum<cygwin_error::cygwin_errno>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
namespace cygwin_error
|
|
||||||
{
|
|
||||||
inline error_code make_error_code( cygwin_errno e )
|
|
||||||
{ return error_code( e, system_category ); }
|
|
||||||
}
|
|
||||||
|
|
||||||
# elif defined(linux) || defined(__linux) || defined(__linux__)
|
|
||||||
|
|
||||||
namespace linux_error
|
|
||||||
{
|
|
||||||
enum linux_errno
|
|
||||||
{
|
|
||||||
advertise_error = EADV,
|
|
||||||
bad_exchange = EBADE,
|
|
||||||
bad_file_number = EBADFD,
|
|
||||||
bad_font_format = EBFONT,
|
|
||||||
bad_request_code = EBADRQC,
|
|
||||||
bad_request_descriptor = EBADR,
|
|
||||||
bad_slot = EBADSLT,
|
|
||||||
channel_range = ECHRNG,
|
|
||||||
communication_error = ECOMM,
|
|
||||||
dot_dot_error = EDOTDOT,
|
|
||||||
exchange_full = EXFULL,
|
|
||||||
host_down = EHOSTDOWN,
|
|
||||||
is_named_file_type= EISNAM,
|
|
||||||
key_expired = EKEYEXPIRED,
|
|
||||||
key_rejected = EKEYREJECTED,
|
|
||||||
key_revoked = EKEYREVOKED,
|
|
||||||
level2_halt= EL2HLT,
|
|
||||||
level2_no_syncronized= EL2NSYNC,
|
|
||||||
level3_halt = EL3HLT,
|
|
||||||
level3_reset = EL3RST,
|
|
||||||
link_range = ELNRNG,
|
|
||||||
medium_type = EMEDIUMTYPE,
|
|
||||||
no_anode= ENOANO,
|
|
||||||
no_block_device = ENOTBLK,
|
|
||||||
no_csi = ENOCSI,
|
|
||||||
no_key = ENOKEY,
|
|
||||||
no_medium = ENOMEDIUM,
|
|
||||||
no_network = ENONET,
|
|
||||||
no_package = ENOPKG,
|
|
||||||
not_avail = ENAVAIL,
|
|
||||||
not_named_file_type= ENOTNAM,
|
|
||||||
not_recoverable = ENOTRECOVERABLE,
|
|
||||||
not_unique = ENOTUNIQ,
|
|
||||||
owner_dead = EOWNERDEAD,
|
|
||||||
protocol_no_supported = EPFNOSUPPORT,
|
|
||||||
remote_address_changed = EREMCHG,
|
|
||||||
remote_io_error = EREMOTEIO,
|
|
||||||
remote_object = EREMOTE,
|
|
||||||
restart_needed = ERESTART,
|
|
||||||
shared_library_access = ELIBACC,
|
|
||||||
shared_library_bad = ELIBBAD,
|
|
||||||
shared_library_execute = ELIBEXEC,
|
|
||||||
shared_library_max_ = ELIBMAX,
|
|
||||||
shared_library_section= ELIBSCN,
|
|
||||||
shutdown = ESHUTDOWN,
|
|
||||||
socket_type_not_supported = ESOCKTNOSUPPORT,
|
|
||||||
srmount_error = ESRMNT,
|
|
||||||
stream_pipe_error = ESTRPIPE,
|
|
||||||
too_many_references = ETOOMANYREFS,
|
|
||||||
too_many_users = EUSERS,
|
|
||||||
unattached = EUNATCH,
|
|
||||||
unclean = EUCLEAN
|
|
||||||
};
|
|
||||||
} // namespace linux_error
|
|
||||||
|
|
||||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
|
||||||
namespace Linux = linux_error;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
template<> struct is_error_code_enum<linux_error::linux_errno>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
namespace linux_error
|
|
||||||
{
|
|
||||||
inline error_code make_error_code( linux_errno e )
|
|
||||||
{ return error_code( e, system_category ); }
|
|
||||||
}
|
|
||||||
|
|
||||||
# endif
|
|
||||||
|
|
||||||
// TODO: Add more POSIX-based operating systems here
|
|
||||||
|
|
||||||
|
|
||||||
#elif defined(BOOST_WINDOWS_API)
|
|
||||||
|
|
||||||
// Microsoft Windows ---------------------------------------------------//
|
|
||||||
|
|
||||||
// To construct an error_code after a API error:
|
|
||||||
//
|
|
||||||
// error_code( ::GetLastError(), system_category )
|
|
||||||
|
|
||||||
namespace windows_error
|
|
||||||
{
|
|
||||||
enum windows_error_code
|
|
||||||
{
|
|
||||||
success = 0,
|
|
||||||
// These names and values are based on Windows winerror.h
|
|
||||||
invalid_function = ERROR_INVALID_FUNCTION,
|
|
||||||
file_not_found = ERROR_FILE_NOT_FOUND,
|
|
||||||
path_not_found = ERROR_PATH_NOT_FOUND,
|
|
||||||
too_many_open_files = ERROR_TOO_MANY_OPEN_FILES,
|
|
||||||
access_denied = ERROR_ACCESS_DENIED,
|
|
||||||
invalid_handle = ERROR_INVALID_HANDLE,
|
|
||||||
arena_trashed = ERROR_ARENA_TRASHED,
|
|
||||||
not_enough_memory = ERROR_NOT_ENOUGH_MEMORY,
|
|
||||||
invalid_block = ERROR_INVALID_BLOCK,
|
|
||||||
bad_environment = ERROR_BAD_ENVIRONMENT,
|
|
||||||
bad_format = ERROR_BAD_FORMAT,
|
|
||||||
invalid_access = ERROR_INVALID_ACCESS,
|
|
||||||
outofmemory = ERROR_OUTOFMEMORY,
|
|
||||||
invalid_drive = ERROR_INVALID_DRIVE,
|
|
||||||
current_directory = ERROR_CURRENT_DIRECTORY,
|
|
||||||
not_same_device = ERROR_NOT_SAME_DEVICE,
|
|
||||||
no_more_files = ERROR_NO_MORE_FILES,
|
|
||||||
write_protect = ERROR_WRITE_PROTECT,
|
|
||||||
bad_unit = ERROR_BAD_UNIT,
|
|
||||||
not_ready = ERROR_NOT_READY,
|
|
||||||
bad_command = ERROR_BAD_COMMAND,
|
|
||||||
crc = ERROR_CRC,
|
|
||||||
bad_length = ERROR_BAD_LENGTH,
|
|
||||||
seek = ERROR_SEEK,
|
|
||||||
not_dos_disk = ERROR_NOT_DOS_DISK,
|
|
||||||
sector_not_found = ERROR_SECTOR_NOT_FOUND,
|
|
||||||
out_of_paper = ERROR_OUT_OF_PAPER,
|
|
||||||
write_fault = ERROR_WRITE_FAULT,
|
|
||||||
read_fault = ERROR_READ_FAULT,
|
|
||||||
gen_failure = ERROR_GEN_FAILURE,
|
|
||||||
sharing_violation = ERROR_SHARING_VIOLATION,
|
|
||||||
lock_violation = ERROR_LOCK_VIOLATION,
|
|
||||||
wrong_disk = ERROR_WRONG_DISK,
|
|
||||||
sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED,
|
|
||||||
handle_eof = ERROR_HANDLE_EOF,
|
|
||||||
handle_disk_full= ERROR_HANDLE_DISK_FULL,
|
|
||||||
rem_not_list = ERROR_REM_NOT_LIST,
|
|
||||||
dup_name = ERROR_DUP_NAME,
|
|
||||||
bad_net_path = ERROR_BAD_NETPATH,
|
|
||||||
network_busy = ERROR_NETWORK_BUSY,
|
|
||||||
// ...
|
|
||||||
file_exists = ERROR_FILE_EXISTS,
|
|
||||||
cannot_make = ERROR_CANNOT_MAKE,
|
|
||||||
// ...
|
|
||||||
broken_pipe = ERROR_BROKEN_PIPE,
|
|
||||||
open_failed = ERROR_OPEN_FAILED,
|
|
||||||
buffer_overflow = ERROR_BUFFER_OVERFLOW,
|
|
||||||
disk_full= ERROR_DISK_FULL,
|
|
||||||
// ...
|
|
||||||
lock_failed = ERROR_LOCK_FAILED,
|
|
||||||
busy = ERROR_BUSY,
|
|
||||||
cancel_violation = ERROR_CANCEL_VIOLATION,
|
|
||||||
already_exists = ERROR_ALREADY_EXISTS
|
|
||||||
// ...
|
|
||||||
|
|
||||||
// TODO: add more Windows errors
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace windows
|
|
||||||
|
|
||||||
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
|
||||||
namespace windows = windows_error;
|
|
||||||
# endif
|
|
||||||
|
|
||||||
template<> struct is_error_code_enum<windows_error::windows_error_code>
|
|
||||||
{ static const bool value = true; };
|
|
||||||
|
|
||||||
namespace windows_error
|
|
||||||
{
|
|
||||||
inline error_code make_error_code( windows_error_code e )
|
|
||||||
{ return error_code( e, system_category ); }
|
|
||||||
}
|
|
||||||
|
|
||||||
#else
|
|
||||||
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace system
|
} // namespace system
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
|
110
include/boost/system/linux_error.hpp
Normal file
110
include/boost/system/linux_error.hpp
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
// boost/system/linux_error.hpp -------------------------------------------//
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2007
|
||||||
|
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#ifndef BOOST_LINUX_ERROR_HPP
|
||||||
|
#define BOOST_LINUX_ERROR_HPP
|
||||||
|
|
||||||
|
// This header is effectively empty for compiles on operating systems where
|
||||||
|
// it is not applicable.
|
||||||
|
|
||||||
|
#if defined(linux) || defined(__linux) || defined(__linux__)
|
||||||
|
|
||||||
|
#include <boost/system/error_code.hpp>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
// To construct an error_code after a API error:
|
||||||
|
//
|
||||||
|
// error_code( errno, system_category )
|
||||||
|
|
||||||
|
// User code should use the portable "posix" enums for POSIX errors; this
|
||||||
|
// allows such code to be portable to non-POSIX systems. For the non-POSIX
|
||||||
|
// errno values that POSIX-based systems typically provide in addition to
|
||||||
|
// POSIX values, use the system specific enums below.
|
||||||
|
|
||||||
|
namespace linux_error
|
||||||
|
{
|
||||||
|
enum linux_errno
|
||||||
|
{
|
||||||
|
advertise_error = EADV,
|
||||||
|
bad_exchange = EBADE,
|
||||||
|
bad_file_number = EBADFD,
|
||||||
|
bad_font_format = EBFONT,
|
||||||
|
bad_request_code = EBADRQC,
|
||||||
|
bad_request_descriptor = EBADR,
|
||||||
|
bad_slot = EBADSLT,
|
||||||
|
channel_range = ECHRNG,
|
||||||
|
communication_error = ECOMM,
|
||||||
|
dot_dot_error = EDOTDOT,
|
||||||
|
exchange_full = EXFULL,
|
||||||
|
host_down = EHOSTDOWN,
|
||||||
|
is_named_file_type= EISNAM,
|
||||||
|
key_expired = EKEYEXPIRED,
|
||||||
|
key_rejected = EKEYREJECTED,
|
||||||
|
key_revoked = EKEYREVOKED,
|
||||||
|
level2_halt= EL2HLT,
|
||||||
|
level2_no_syncronized= EL2NSYNC,
|
||||||
|
level3_halt = EL3HLT,
|
||||||
|
level3_reset = EL3RST,
|
||||||
|
link_range = ELNRNG,
|
||||||
|
medium_type = EMEDIUMTYPE,
|
||||||
|
no_anode= ENOANO,
|
||||||
|
no_block_device = ENOTBLK,
|
||||||
|
no_csi = ENOCSI,
|
||||||
|
no_key = ENOKEY,
|
||||||
|
no_medium = ENOMEDIUM,
|
||||||
|
no_network = ENONET,
|
||||||
|
no_package = ENOPKG,
|
||||||
|
not_avail = ENAVAIL,
|
||||||
|
not_named_file_type= ENOTNAM,
|
||||||
|
not_recoverable = ENOTRECOVERABLE,
|
||||||
|
not_unique = ENOTUNIQ,
|
||||||
|
owner_dead = EOWNERDEAD,
|
||||||
|
protocol_no_supported = EPFNOSUPPORT,
|
||||||
|
remote_address_changed = EREMCHG,
|
||||||
|
remote_io_error = EREMOTEIO,
|
||||||
|
remote_object = EREMOTE,
|
||||||
|
restart_needed = ERESTART,
|
||||||
|
shared_library_access = ELIBACC,
|
||||||
|
shared_library_bad = ELIBBAD,
|
||||||
|
shared_library_execute = ELIBEXEC,
|
||||||
|
shared_library_max_ = ELIBMAX,
|
||||||
|
shared_library_section= ELIBSCN,
|
||||||
|
shutdown = ESHUTDOWN,
|
||||||
|
socket_type_not_supported = ESOCKTNOSUPPORT,
|
||||||
|
srmount_error = ESRMNT,
|
||||||
|
stream_pipe_error = ESTRPIPE,
|
||||||
|
too_many_references = ETOOMANYREFS,
|
||||||
|
too_many_users = EUSERS,
|
||||||
|
unattached = EUNATCH,
|
||||||
|
unclean = EUCLEAN
|
||||||
|
};
|
||||||
|
} // namespace linux_error
|
||||||
|
|
||||||
|
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
|
namespace Linux = linux_error;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
template<> struct is_error_code_enum<linux_error::linux_errno>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
namespace linux_error
|
||||||
|
{
|
||||||
|
inline error_code make_error_code( linux_errno e )
|
||||||
|
{ return error_code( e, system_category ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // Linux
|
||||||
|
|
||||||
|
#endif // BOOST_LINUX_ERROR_HPP
|
118
include/boost/system/windows_error.hpp
Normal file
118
include/boost/system/windows_error.hpp
Normal file
@@ -0,0 +1,118 @@
|
|||||||
|
// boost/system/windows_error.hpp ------------------------------------------//
|
||||||
|
|
||||||
|
// Copyright Beman Dawes 2007
|
||||||
|
|
||||||
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||||
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#ifndef BOOST_WINDOWS_ERROR_HPP
|
||||||
|
#define BOOST_WINDOWS_ERROR_HPP
|
||||||
|
|
||||||
|
// This header is effectively empty for compiles on operating systems where
|
||||||
|
// it is not applicable.
|
||||||
|
|
||||||
|
#include <boost/system/config.hpp>
|
||||||
|
|
||||||
|
#ifdef BOOST_WINDOWS_API
|
||||||
|
|
||||||
|
#include <boost/system/error_code.hpp>
|
||||||
|
#include <winerror.h>
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
// Microsoft Windows ---------------------------------------------------//
|
||||||
|
|
||||||
|
// To construct an error_code after a API error:
|
||||||
|
//
|
||||||
|
// error_code( ::GetLastError(), system_category )
|
||||||
|
|
||||||
|
namespace windows_error
|
||||||
|
{
|
||||||
|
enum windows_error_code
|
||||||
|
{
|
||||||
|
success = 0,
|
||||||
|
// These names and values are based on Windows winerror.h
|
||||||
|
invalid_function = ERROR_INVALID_FUNCTION,
|
||||||
|
file_not_found = ERROR_FILE_NOT_FOUND,
|
||||||
|
path_not_found = ERROR_PATH_NOT_FOUND,
|
||||||
|
too_many_open_files = ERROR_TOO_MANY_OPEN_FILES,
|
||||||
|
access_denied = ERROR_ACCESS_DENIED,
|
||||||
|
invalid_handle = ERROR_INVALID_HANDLE,
|
||||||
|
arena_trashed = ERROR_ARENA_TRASHED,
|
||||||
|
not_enough_memory = ERROR_NOT_ENOUGH_MEMORY,
|
||||||
|
invalid_block = ERROR_INVALID_BLOCK,
|
||||||
|
bad_environment = ERROR_BAD_ENVIRONMENT,
|
||||||
|
bad_format = ERROR_BAD_FORMAT,
|
||||||
|
invalid_access = ERROR_INVALID_ACCESS,
|
||||||
|
outofmemory = ERROR_OUTOFMEMORY,
|
||||||
|
invalid_drive = ERROR_INVALID_DRIVE,
|
||||||
|
current_directory = ERROR_CURRENT_DIRECTORY,
|
||||||
|
not_same_device = ERROR_NOT_SAME_DEVICE,
|
||||||
|
no_more_files = ERROR_NO_MORE_FILES,
|
||||||
|
write_protect = ERROR_WRITE_PROTECT,
|
||||||
|
bad_unit = ERROR_BAD_UNIT,
|
||||||
|
not_ready = ERROR_NOT_READY,
|
||||||
|
bad_command = ERROR_BAD_COMMAND,
|
||||||
|
crc = ERROR_CRC,
|
||||||
|
bad_length = ERROR_BAD_LENGTH,
|
||||||
|
seek = ERROR_SEEK,
|
||||||
|
not_dos_disk = ERROR_NOT_DOS_DISK,
|
||||||
|
sector_not_found = ERROR_SECTOR_NOT_FOUND,
|
||||||
|
out_of_paper = ERROR_OUT_OF_PAPER,
|
||||||
|
write_fault = ERROR_WRITE_FAULT,
|
||||||
|
read_fault = ERROR_READ_FAULT,
|
||||||
|
gen_failure = ERROR_GEN_FAILURE,
|
||||||
|
sharing_violation = ERROR_SHARING_VIOLATION,
|
||||||
|
lock_violation = ERROR_LOCK_VIOLATION,
|
||||||
|
wrong_disk = ERROR_WRONG_DISK,
|
||||||
|
sharing_buffer_exceeded = ERROR_SHARING_BUFFER_EXCEEDED,
|
||||||
|
handle_eof = ERROR_HANDLE_EOF,
|
||||||
|
handle_disk_full= ERROR_HANDLE_DISK_FULL,
|
||||||
|
rem_not_list = ERROR_REM_NOT_LIST,
|
||||||
|
dup_name = ERROR_DUP_NAME,
|
||||||
|
bad_net_path = ERROR_BAD_NETPATH,
|
||||||
|
network_busy = ERROR_NETWORK_BUSY,
|
||||||
|
// ...
|
||||||
|
file_exists = ERROR_FILE_EXISTS,
|
||||||
|
cannot_make = ERROR_CANNOT_MAKE,
|
||||||
|
// ...
|
||||||
|
broken_pipe = ERROR_BROKEN_PIPE,
|
||||||
|
open_failed = ERROR_OPEN_FAILED,
|
||||||
|
buffer_overflow = ERROR_BUFFER_OVERFLOW,
|
||||||
|
disk_full= ERROR_DISK_FULL,
|
||||||
|
// ...
|
||||||
|
lock_failed = ERROR_LOCK_FAILED,
|
||||||
|
busy = ERROR_BUSY,
|
||||||
|
cancel_violation = ERROR_CANCEL_VIOLATION,
|
||||||
|
already_exists = ERROR_ALREADY_EXISTS
|
||||||
|
// ...
|
||||||
|
|
||||||
|
// TODO: add more Windows errors
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace windows
|
||||||
|
|
||||||
|
# ifndef BOOST_SYSTEM_NO_DEPRECATED
|
||||||
|
namespace windows = windows_error;
|
||||||
|
# endif
|
||||||
|
|
||||||
|
template<> struct is_error_code_enum<windows_error::windows_error_code>
|
||||||
|
{ static const bool value = true; };
|
||||||
|
|
||||||
|
namespace windows_error
|
||||||
|
{
|
||||||
|
inline error_code make_error_code( windows_error_code e )
|
||||||
|
{ return error_code( e, system_category ); }
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
} // namespace boost
|
||||||
|
|
||||||
|
#endif // BOOST_WINDOWS_API
|
||||||
|
|
||||||
|
#endif // BOOST_WINDOWS_ERROR_HPP
|
@@ -42,7 +42,7 @@ namespace
|
|||||||
BOOST_CHECK( ex.code().category() == system_category );
|
BOOST_CHECK( ex.code().category() == system_category );
|
||||||
# ifdef BOOST_WINDOWS_API
|
# ifdef BOOST_WINDOWS_API
|
||||||
LANGID language_id;
|
LANGID language_id;
|
||||||
# ifndef __MINGW32__
|
# if !defined(__MINGW32__) && !defined(__CYGWIN__)
|
||||||
language_id = ::GetUserDefaultUILanguage();
|
language_id = ::GetUserDefaultUILanguage();
|
||||||
# else
|
# else
|
||||||
language_id = 0x0409; // Assume US English
|
language_id = 0x0409; // Assume US English
|
||||||
|
Reference in New Issue
Block a user