forked from boostorg/system
Upgrade system and filesystem to conform system_category and generic_category interface to N3090, the current C++0x working paper, section 19.5, System error support.
Refactor API macros into a new header, boost/system/api_config.hpp. Prohibit user definition of API macros. Rationale: ensure all translation units use same definitions, cut number of environments that need to be tested. [SVN r62313]
This commit is contained in:
1 parent
2565e5307b
commit
baae3a392a
15 files changed
+248
-196
No files matched your search
@@ -0,0 +1,42 @@
|
||||
// boost/system/api_config.hpp -------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2003, 2006, 2010
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
// See http://www.boost.org/libs/system for documentation.
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
// Boost.System calls operating system API functions to implement system error category
|
||||
// functions. Usually there is no question as to which API is to be used.
|
||||
//
|
||||
// In the case of MinGW or Cygwin/MinGW, however, both POSIX and Windows API's are
|
||||
// available. Chaos ensues if other code thinks one is in use when Boost.System was
|
||||
// actually built with the other. This header centralizes the API choice and prevents
|
||||
// user definition of API macros, thus elminating the possibility of mismatches and the
|
||||
// need to test configurations with little or no practical value.
|
||||
//
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_SYSTEM_API_CONFIG_HPP
|
||||
#define BOOST_SYSTEM_API_CONFIG_HPP
|
||||
|
||||
# if defined(BOOST_POSIX_API) || defined(BOOST_WINDOWS_API)
|
||||
# error user defined BOOST_POSIX_API or BOOST_WINDOWS_API not supported
|
||||
# endif
|
||||
|
||||
// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use
|
||||
// Cygwin/MinGW does not predefine _WIN32.
|
||||
// Standalone MinGW and all other known Windows compilers do predefine _WIN32
|
||||
// Compilers that predefine _WIN32 or __MINGW32__ do so for Windows 64-bit builds too.
|
||||
|
||||
# if defined(_WIN32) || defined(__CYGWIN__) // Windows default, including MinGW and Cygwin
|
||||
# define BOOST_WINDOWS_API
|
||||
# else
|
||||
# define BOOST_POSIX_API
|
||||
# endif
|
||||
|
||||
#endif // BOOST_SYSTEM_API_CONFIG_HPP
|
||||
@@ -11,22 +11,10 @@
|
||||
#define BOOST_SYSTEM_CONFIG_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
|
||||
|
||||
// BOOST_POSIX_API or BOOST_WINDOWS_API specify which API to use.
|
||||
// If not specified, a sensible default will be applied.
|
||||
|
||||
# if defined( BOOST_WINDOWS_API ) && defined( BOOST_POSIX_API )
|
||||
# error both BOOST_WINDOWS_API and BOOST_POSIX_API are defined
|
||||
# elif !defined( BOOST_WINDOWS_API ) && !defined( BOOST_POSIX_API )
|
||||
# if defined(_WIN32) || defined(__WIN32__) || defined(WIN32)
|
||||
// All Win32 development environments, including 64-bit Windows and MinGW, define
|
||||
// _WIN32 or one of its variant spellings. Note that Cygwin is a POSIX environment,
|
||||
// so does not define _WIN32 or its variants.
|
||||
# define BOOST_WINDOWS_API
|
||||
# else
|
||||
# define BOOST_POSIX_API
|
||||
# endif
|
||||
# endif
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
// enable dynamic or static linking as requested --------------------------------------//
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace boost
|
||||
{
|
||||
// To construct an error_code after a API error:
|
||||
//
|
||||
// error_code( errno, system_category )
|
||||
// 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
|
||||
@@ -46,7 +46,7 @@ namespace boost
|
||||
namespace cygwin_error
|
||||
{
|
||||
inline error_code make_error_code( cygwin_errno e )
|
||||
{ return error_code( e, get_system_category() ); }
|
||||
{ return error_code( e, system_category() ); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -202,18 +202,18 @@ namespace boost
|
||||
|
||||
// predefined error categories -----------------------------------------//
|
||||
|
||||
BOOST_SYSTEM_DECL const error_category & get_system_category();
|
||||
BOOST_SYSTEM_DECL const error_category & get_generic_category();
|
||||
BOOST_SYSTEM_DECL const error_category & system_category();
|
||||
BOOST_SYSTEM_DECL const error_category & generic_category();
|
||||
|
||||
// deprecated synonyms --------------------------------------------------//
|
||||
|
||||
static const error_category & system_category = get_system_category();
|
||||
static const error_category & generic_category = get_generic_category();
|
||||
|
||||
# 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();
|
||||
inline const error_category & get_system_category() { return system_category(); }
|
||||
inline const error_category & get_generic_category() { return generic_category(); }
|
||||
inline const error_category & get_posix_category() { return generic_category(); }
|
||||
static const error_category & posix_category = generic_category();
|
||||
static const error_category & errno_ecat = generic_category();
|
||||
static const error_category & native_ecat = system_category();
|
||||
# endif
|
||||
|
||||
// class error_condition -----------------------------------------------//
|
||||
@@ -225,7 +225,7 @@ namespace boost
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
error_condition() : m_val(0), m_cat(&get_generic_category()) {}
|
||||
error_condition() : m_val(0), m_cat(&generic_category()) {}
|
||||
error_condition( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
|
||||
|
||||
template <class ErrorConditionEnum>
|
||||
@@ -254,7 +254,7 @@ namespace boost
|
||||
void clear()
|
||||
{
|
||||
m_val = 0;
|
||||
m_cat = &get_generic_category();
|
||||
m_cat = &generic_category();
|
||||
}
|
||||
|
||||
// observers:
|
||||
@@ -312,7 +312,7 @@ namespace boost
|
||||
public:
|
||||
|
||||
// constructors:
|
||||
error_code() : m_val(0), m_cat(&get_system_category()) {}
|
||||
error_code() : m_val(0), m_cat(&system_category()) {}
|
||||
error_code( int val, const error_category & cat ) : m_val(val), m_cat(&cat) {}
|
||||
|
||||
template <class ErrorCodeEnum>
|
||||
@@ -340,7 +340,7 @@ namespace boost
|
||||
void clear()
|
||||
{
|
||||
m_val = 0;
|
||||
m_cat = &get_system_category();
|
||||
m_cat = &system_category();
|
||||
}
|
||||
|
||||
// observers:
|
||||
@@ -473,11 +473,11 @@ namespace boost
|
||||
{
|
||||
// explicit conversion:
|
||||
inline error_code make_error_code( errc_t e )
|
||||
{ return error_code( e, get_generic_category() ); }
|
||||
{ return error_code( e, generic_category() ); }
|
||||
|
||||
// implicit conversion:
|
||||
inline error_condition make_error_condition( errc_t e )
|
||||
{ return error_condition( e, get_generic_category() ); }
|
||||
{ return error_condition( e, generic_category() ); }
|
||||
}
|
||||
|
||||
// error_category default implementation -------------------------------//
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace boost
|
||||
{
|
||||
// To construct an error_code after a API error:
|
||||
//
|
||||
// error_code( errno, system_category )
|
||||
// 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
|
||||
@@ -99,7 +99,7 @@ namespace boost
|
||||
namespace linux_error
|
||||
{
|
||||
inline error_code make_error_code( linux_errno e )
|
||||
{ return error_code( e, get_system_category() ); }
|
||||
{ return error_code( e, system_category() ); }
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace boost
|
||||
|
||||
// To construct an error_code after a API error:
|
||||
//
|
||||
// error_code( ::GetLastError(), system_category )
|
||||
// error_code( ::GetLastError(), system_category() )
|
||||
|
||||
namespace windows_error
|
||||
{
|
||||
@@ -107,7 +107,7 @@ namespace boost
|
||||
namespace windows_error
|
||||
{
|
||||
inline error_code make_error_code( windows_error_code e )
|
||||
{ return error_code( e, get_system_category() ); }
|
||||
{ return error_code( e, system_category() ); }
|
||||
}
|
||||
|
||||
} // namespace system
|
||||
|
||||
Reference in new issue
Block a user