From b951517625f416528b26348a462c9a05f05a22df Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Thu, 27 Aug 2020 16:25:34 +0300 Subject: [PATCH] Move system_category implementation to system_category_impl.hpp --- .../system/detail/system_category_impl.hpp | 64 ++++++++++++++++++ include/boost/system/error_code.hpp | 67 +------------------ 2 files changed, 65 insertions(+), 66 deletions(-) create mode 100644 include/boost/system/detail/system_category_impl.hpp diff --git a/include/boost/system/detail/system_category_impl.hpp b/include/boost/system/detail/system_category_impl.hpp new file mode 100644 index 0000000..d4a9ba8 --- /dev/null +++ b/include/boost/system/detail/system_category_impl.hpp @@ -0,0 +1,64 @@ +#ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED +#define BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED + +// Copyright Beman Dawes 2006, 2007 +// Copyright Christoper Kohlhoff 2007 +// Copyright Peter Dimov 2017, 2018 +// +// 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 + +#include +#include +#include + +#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) +# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined +#endif + +// system_error_category implementation + +#if defined(BOOST_WINDOWS_API) + +#include + +inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT +{ + return system_category_default_error_condition_win32( ev ); +} + +inline std::string boost::system::detail::system_error_category::message( int ev ) const +{ + return system_category_message_win32( ev ); +} + +inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT +{ + return system_category_message_win32( ev, buffer, len ); +} + +#else // #if defined(BOOST_WINDOWS_API) + +#include +#include + +inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT +{ + return system_category_default_error_condition_posix( ev ); +} + +inline std::string boost::system::detail::system_error_category::message( int ev ) const +{ + return generic_error_category_message( ev ); +} + +inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT +{ + return generic_error_category_message( ev, buffer, len ); +} + +#endif // #if defined(BOOST_WINDOWS_API) + +#endif // #ifndef BOOST_SYSTEM_DETAIL_SYSTEM_CATEGORY_IMPL_HPP_INCLUDED diff --git a/include/boost/system/error_code.hpp b/include/boost/system/error_code.hpp index 87f8b6a..6f02f1e 100644 --- a/include/boost/system/error_code.hpp +++ b/include/boost/system/error_code.hpp @@ -16,23 +16,9 @@ #include #include #include +#include #include -#include -#include -#include #include -#include -#include -#include -#include - -#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR) -# include -#endif - -#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API) -# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined -#endif namespace boost { @@ -40,17 +26,8 @@ namespace boost namespace system { -class error_code; // values defined by the operating system -class error_condition; // portable generic values defined below, but ultimately - // based on the POSIX standard - -} // namespace system - // non-member functions of error_code and error_condition -namespace system -{ - inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT { return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() ); @@ -75,46 +52,4 @@ inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BO } // namespace boost -// system_error_category implementation - -#if defined(BOOST_WINDOWS_API) - -#include - -inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT -{ - return system_category_default_error_condition_win32( ev ); -} - -inline std::string boost::system::detail::system_error_category::message( int ev ) const -{ - return system_category_message_win32( ev ); -} - -inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT -{ - return system_category_message_win32( ev, buffer, len ); -} - -#else // #if defined(BOOST_WINDOWS_API) - -#include - -inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT -{ - return system_category_default_error_condition_posix( ev ); -} - -inline std::string boost::system::detail::system_error_category::message( int ev ) const -{ - return generic_error_category_message( ev ); -} - -inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT -{ - return generic_error_category_message( ev, buffer, len ); -} - -#endif // #if defined(BOOST_WINDOWS_API) - #endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED