diff --git a/include/boost/system/detail/error_code.ipp b/include/boost/system/detail/error_code.ipp index e686fd3..f5fed6a 100644 --- a/include/boost/system/detail/error_code.ipp +++ b/include/boost/system/detail/error_code.ipp @@ -1,4 +1,4 @@ -// error_code support implementation file ----------------------------------// +// error_code support implementation file --------------------------------------------// // Copyright Beman Dawes 2002, 2006 // Copyright (c) Microsoft Corporation 2014 @@ -7,7 +7,7 @@ // See library home page at http://www.boost.org/libs/system -//----------------------------------------------------------------------------// +//--------------------------------------------------------------------------------------// #include @@ -31,7 +31,7 @@ # endif # endif -//----------------------------------------------------------------------------// +//--------------------------------------------------------------------------------------// namespace boost { namespace system @@ -40,7 +40,7 @@ namespace boost namespace { - // standard error categories ---------------------------------------------// + // standard error categories -------------------------------------------------------// class generic_error_category : public error_category { @@ -85,7 +85,8 @@ namespace // -- VMS doesn't provide strerror_r, but on this platform, strerror is // thread safe. # if defined(BOOST_WINDOWS_API) || defined(__hpux) || defined(__sun)\ - || (defined(__linux) && (!defined(__USE_XOPEN2K) || defined(BOOST_SYSTEM_USE_STRERROR)))\ + || (defined(__linux) && (!defined(__USE_XOPEN2K)\ + || defined(BOOST_SYSTEM_USE_STRERROR)))\ || (defined(__osf__) && !defined(_REENTRANT))\ || (defined(__INTEGRITY))\ || (defined(__vms))\ @@ -157,14 +158,15 @@ namespace # endif // else POSIX version of strerror_r # endif // else use strerror_r } - // system_error_category implementation --------------------------------// + // system_error_category implementation --------------------------------------------// const char * system_error_category::name() const BOOST_SYSTEM_NOEXCEPT { return "system"; } - error_condition system_error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + error_condition system_error_category::default_error_condition( int ev ) const + BOOST_SYSTEM_NOEXCEPT { using namespace boost::system::errc; #if defined(__PGI) @@ -186,7 +188,7 @@ namespace { case 0: return make_error_condition( success ); # if defined(BOOST_POSIX_API) - // POSIX-like O/S -> posix_errno decode table ---------------------------// + // POSIX-like O/S -> posix_errno decode table -------------------------------------// case E2BIG: return make_error_condition( argument_list_too_long ); case EACCES: return make_error_condition( permission_denied ); case EADDRINUSE: return make_error_condition( address_in_use ); @@ -294,7 +296,8 @@ namespace case ERROR_DEV_NOT_EXIST: return make_error_condition( no_such_device ); case ERROR_DEVICE_IN_USE: return make_error_condition( device_or_resource_busy ); case ERROR_DIR_NOT_EMPTY: return make_error_condition( directory_not_empty ); - case ERROR_DIRECTORY: return make_error_condition( invalid_argument ); // WinError.h: "The directory name is invalid" + case ERROR_DIRECTORY: return make_error_condition( invalid_argument ); // WinError.h: + "The directory name is invalid" case ERROR_DISK_FULL: return make_error_condition( no_space_on_device ); case ERROR_FILE_EXISTS: return make_error_condition( file_exists ); case ERROR_FILE_NOT_FOUND: return make_error_condition( no_such_file_or_directory ); @@ -378,7 +381,8 @@ namespace boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_, NULL, ev, - boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language + boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, + boost::detail::winapi::SUBLANG_DEFAULT_), // Default language &buf[0], buf.size(), NULL @@ -389,7 +393,8 @@ namespace buf.resize(retval); break; } - else if (boost::detail::winapi::GetLastError() != boost::detail::winapi::ERROR_INSUFFICIENT_BUFFER_) + else if (boost::detail::winapi::GetLastError() != + boost::detail::winapi::ERROR_INSUFFICIENT_BUFFER_) { return std::string("Unknown error"); } @@ -400,8 +405,10 @@ namespace } int num_chars = (buf.size() + 1) * 2; - boost::detail::winapi::LPSTR_ narrow_buffer = (boost::detail::winapi::LPSTR_)_alloca(num_chars); - if (boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_ACP_, 0, buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) + boost::detail::winapi::LPSTR_ narrow_buffer = + (boost::detail::winapi::LPSTR_)_alloca(num_chars); + if (boost::detail::winapi::WideCharToMultiByte(boost::detail::winapi::CP_ACP_, 0, + buf.c_str(), -1, narrow_buffer, num_chars, NULL, NULL) == 0) { return std::string("Unknown error"); } @@ -415,7 +422,8 @@ namespace boost::detail::winapi::FORMAT_MESSAGE_IGNORE_INSERTS_, NULL, ev, - boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, boost::detail::winapi::SUBLANG_DEFAULT_), // Default language + boost::detail::winapi::MAKELANGID_(boost::detail::winapi::LANG_NEUTRAL_, + boost::detail::winapi::SUBLANG_DEFAULT_), // Default language (boost::detail::winapi::LPSTR_) &lpMsgBuf, 0, NULL diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 70a41cd..dd585d7 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -1,4 +1,4 @@ -// boost/system/error_code.hpp ---------------------------------------------// +// boost/system/error_code.hpp -------------------------------------------------------// // Copyright Beman Dawes 2006, 2007 // Copyright Christoper Kohlhoff 2007 @@ -47,7 +47,7 @@ namespace boost class error_condition; // portable generic values defined below, but ultimately // based on the POSIX standard - // "Concept" helpers ---------------------------------------------------// + // "Concept" helpers -------------------------------------------------------------// template< class T > struct is_error_code_enum { static const bool value = false; }; @@ -55,7 +55,7 @@ namespace boost template< class T > struct is_error_condition_enum { static const bool value = false; }; - // generic error_conditions --------------------------------------------// + // generic error_conditions ------------------------------------------------------// namespace errc { @@ -153,9 +153,9 @@ namespace boost { static const bool value = true; }; - // ----------------------------------------------------------------------// + // --------------------------------------------------------------------------------// - // Operating system specific interfaces --------------------------------// + // Operating system specific interfaces ------------------------------------------// // The interface is divided into general and system-specific portions to @@ -183,11 +183,11 @@ namespace boost // These headers are effectively empty for compiles on operating systems // where they are not applicable. - // ----------------------------------------------------------------------// + // --------------------------------------------------------------------------------// class error_category; - // predefined error categories -----------------------------------------// + // predefined error categories ---------------------------------------------------// #ifdef BOOST_ERROR_CODE_HEADER_ONLY inline const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; @@ -196,15 +196,18 @@ namespace boost BOOST_SYSTEM_DECL const error_category & system_category() BOOST_SYSTEM_NOEXCEPT; BOOST_SYSTEM_DECL const error_category & generic_category() BOOST_SYSTEM_NOEXCEPT; #endif - // deprecated synonyms --------------------------------------------------// + // deprecated synonyms ------------------------------------------------------------// #ifndef BOOST_SYSTEM_NO_DEPRECATED 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 BOOST_ATTRIBUTE_UNUSED = generic_category(); - static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED = generic_category(); - static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED = system_category(); + static const error_category & posix_category BOOST_ATTRIBUTE_UNUSED + = generic_category(); + static const error_category & errno_ecat BOOST_ATTRIBUTE_UNUSED + = generic_category(); + static const error_category & native_ecat BOOST_ATTRIBUTE_UNUSED + = system_category(); #endif // class error_category ------------------------------------------------// @@ -237,9 +240,12 @@ namespace boost return pc_->message( ev ); } - virtual std::error_condition default_error_condition( int ev ) const BOOST_NOEXCEPT; - virtual bool equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT; - virtual bool equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT; + virtual std::error_condition default_error_condition( int ev ) const + BOOST_NOEXCEPT; + virtual bool equivalent( int code, const std::error_condition & condition ) const + BOOST_NOEXCEPT; + virtual bool equivalent( const std::error_code & code, int condition ) const + BOOST_NOEXCEPT; }; std_category std_cat_; @@ -263,21 +269,23 @@ namespace boost virtual const char * name() const BOOST_SYSTEM_NOEXCEPT = 0; virtual std::string message( int ev ) const = 0; - inline virtual error_condition default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT; + inline virtual error_condition default_error_condition( int ev ) const + BOOST_SYSTEM_NOEXCEPT; inline virtual bool equivalent( int code, - const error_condition & condition ) const BOOST_SYSTEM_NOEXCEPT; + const error_condition & condition ) const + BOOST_SYSTEM_NOEXCEPT; inline virtual bool equivalent( const error_code & code, int condition ) const BOOST_SYSTEM_NOEXCEPT; - bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this == &rhs; } - bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT { return this != &rhs; } + bool operator==(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT + { return this == &rhs; } + bool operator!=(const error_category & rhs) const BOOST_SYSTEM_NOEXCEPT + { return this != &rhs; } bool operator<( const error_category & rhs ) const BOOST_SYSTEM_NOEXCEPT - { - return std::less()( this, &rhs ); - } + { return std::less()( this, &rhs ); } }; - // class error_condition -----------------------------------------------// + // class error_condition ---------------------------------------------------------// // error_conditions are portable, error_codes are system or library specific @@ -287,11 +295,13 @@ namespace boost // constructors: error_condition() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&generic_category()) {} - error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} + error_condition( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + : m_val(val), m_cat(&cat) {} template error_condition(ErrorConditionEnum e, - typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT + typename boost::enable_if >::type* + = 0) BOOST_SYSTEM_NOEXCEPT { *this = make_error_condition(e); } @@ -305,7 +315,8 @@ namespace boost } template - typename boost::enable_if, error_condition>::type & + typename boost::enable_if, + error_condition>::type & operator=( ErrorConditionEnum val ) BOOST_SYSTEM_NOEXCEPT { *this = make_error_condition(val); @@ -376,7 +387,7 @@ namespace boost }; - // class error_code ----------------------------------------------------// + // class error_code --------------------------------------------------------------// // We want error_code to be a value type that can be copied without slicing // and without requiring heap allocation, but we also want it to have @@ -390,11 +401,13 @@ namespace boost // constructors: error_code() BOOST_SYSTEM_NOEXCEPT : m_val(0), m_cat(&system_category()) {} - error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT : m_val(val), m_cat(&cat) {} + error_code( int val, const error_category & cat ) BOOST_SYSTEM_NOEXCEPT + : m_val(val), m_cat(&cat) {} template error_code(ErrorCodeEnum e, - typename boost::enable_if >::type* = 0) BOOST_SYSTEM_NOEXCEPT + typename boost::enable_if >::type* = 0) + BOOST_SYSTEM_NOEXCEPT { *this = make_error_code(e); } @@ -423,7 +436,8 @@ namespace boost // observers: int value() const BOOST_SYSTEM_NOEXCEPT { return m_val; } const error_category & category() const BOOST_SYSTEM_NOEXCEPT { return *m_cat; } - error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT { return m_cat->default_error_condition(value()); } + error_condition default_error_condition() const BOOST_SYSTEM_NOEXCEPT + { return m_cat->default_error_condition(value()); } std::string message() const { return m_cat->message(value()); } # ifndef BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS @@ -560,7 +574,7 @@ namespace boost + reinterpret_cast(&ec.category()); } - // make_* functions for errc::errc_t -----------------------------// + // make_* functions for errc::errc_t ---------------------------------------------// namespace errc { @@ -573,9 +587,10 @@ namespace boost { return error_condition( e, generic_category() ); } } - // error_category default implementation -------------------------------// + // error_category default implementation -----------------------------------------// - error_condition error_category::default_error_condition( int ev ) const BOOST_SYSTEM_NOEXCEPT + error_condition error_category::default_error_condition( int ev ) const + BOOST_SYSTEM_NOEXCEPT { return error_condition( ev, *this ); } @@ -594,26 +609,31 @@ namespace boost #ifndef BOOST_NO_CXX11_HDR_SYSTEM_ERROR - inline std::error_condition error_category::std_category::default_error_condition( int ev ) const BOOST_NOEXCEPT + inline std::error_condition error_category::std_category::default_error_condition( + int ev ) const BOOST_NOEXCEPT { return pc_->default_error_condition( ev ); } - inline bool error_category::std_category::equivalent( int code, const std::error_condition & condition ) const BOOST_NOEXCEPT + inline bool error_category::std_category::equivalent( int code, + const std::error_condition & condition ) const BOOST_NOEXCEPT { if( default_error_condition( code ) == condition ) { return true; } - else if( condition.category() == std::generic_category() || condition.category() == boost::system::generic_category() ) + else if( condition.category() == std::generic_category() + || condition.category() == boost::system::generic_category() ) { boost::system::error_code bc( code, *pc_ ); - boost::system::error_condition bn( condition.value(), boost::system::generic_category() ); + boost::system::error_condition bn( condition.value(), + boost::system::generic_category() ); return bc == bn; } #ifndef BOOST_NO_RTTI - else if( std_category const* pc2 = dynamic_cast< std_category const* >( &condition.category() ) ) + else if( std_category const* pc2 = dynamic_cast< std_category const* >( + &condition.category() ) ) { boost::system::error_code bc( code, *pc_ ); boost::system::error_condition bn( condition.value(), *pc2->pc_ ); @@ -627,7 +647,8 @@ namespace boost } } - inline bool error_category::std_category::equivalent( const std::error_code & code, int condition ) const BOOST_NOEXCEPT + inline bool error_category::std_category::equivalent( const std::error_code & code, + int condition ) const BOOST_NOEXCEPT { if( *this == code.category() && code.value() == condition ) {