mirror of
https://github.com/boostorg/system.git
synced 2025-07-30 04:27:14 +02:00
Add system_category_posix.hpp; remove BOOST_SYSTEM_WIN32
This commit is contained in:
@ -65,10 +65,4 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// BOOST_SYSTEM_WIN32
|
|
||||||
|
|
||||||
#if defined( _WIN32 ) || defined( __CYGWIN__ )
|
|
||||||
# define BOOST_SYSTEM_WIN32
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED
|
#endif // BOOST_SYSTEM_DETAIL_CONFIG_HPP_INCLUDED
|
||||||
|
132
include/boost/system/detail/system_category_posix.hpp
Normal file
132
include/boost/system/detail/system_category_posix.hpp
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
// POSIX-specific implementation details of system_error_category
|
||||||
|
//
|
||||||
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
|
||||||
|
namespace boost
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace system
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace detail
|
||||||
|
{
|
||||||
|
|
||||||
|
inline bool is_generic_value( int ev ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
using namespace errc;
|
||||||
|
|
||||||
|
static int const gen[] =
|
||||||
|
{
|
||||||
|
success,
|
||||||
|
address_family_not_supported,
|
||||||
|
address_in_use,
|
||||||
|
address_not_available,
|
||||||
|
already_connected,
|
||||||
|
argument_list_too_long,
|
||||||
|
argument_out_of_domain,
|
||||||
|
bad_address,
|
||||||
|
bad_file_descriptor,
|
||||||
|
bad_message,
|
||||||
|
broken_pipe,
|
||||||
|
connection_aborted,
|
||||||
|
connection_already_in_progress,
|
||||||
|
connection_refused,
|
||||||
|
connection_reset,
|
||||||
|
cross_device_link,
|
||||||
|
destination_address_required,
|
||||||
|
device_or_resource_busy,
|
||||||
|
directory_not_empty,
|
||||||
|
executable_format_error,
|
||||||
|
file_exists,
|
||||||
|
file_too_large,
|
||||||
|
filename_too_long,
|
||||||
|
function_not_supported,
|
||||||
|
host_unreachable,
|
||||||
|
identifier_removed,
|
||||||
|
illegal_byte_sequence,
|
||||||
|
inappropriate_io_control_operation,
|
||||||
|
interrupted,
|
||||||
|
invalid_argument,
|
||||||
|
invalid_seek,
|
||||||
|
io_error,
|
||||||
|
is_a_directory,
|
||||||
|
message_size,
|
||||||
|
network_down,
|
||||||
|
network_reset,
|
||||||
|
network_unreachable,
|
||||||
|
no_buffer_space,
|
||||||
|
no_child_process,
|
||||||
|
no_link,
|
||||||
|
no_lock_available,
|
||||||
|
no_message_available,
|
||||||
|
no_message,
|
||||||
|
no_protocol_option,
|
||||||
|
no_space_on_device,
|
||||||
|
no_stream_resources,
|
||||||
|
no_such_device_or_address,
|
||||||
|
no_such_device,
|
||||||
|
no_such_file_or_directory,
|
||||||
|
no_such_process,
|
||||||
|
not_a_directory,
|
||||||
|
not_a_socket,
|
||||||
|
not_a_stream,
|
||||||
|
not_connected,
|
||||||
|
not_enough_memory,
|
||||||
|
not_supported,
|
||||||
|
operation_canceled,
|
||||||
|
operation_in_progress,
|
||||||
|
operation_not_permitted,
|
||||||
|
operation_not_supported,
|
||||||
|
operation_would_block,
|
||||||
|
owner_dead,
|
||||||
|
permission_denied,
|
||||||
|
protocol_error,
|
||||||
|
protocol_not_supported,
|
||||||
|
read_only_file_system,
|
||||||
|
resource_deadlock_would_occur,
|
||||||
|
resource_unavailable_try_again,
|
||||||
|
result_out_of_range,
|
||||||
|
state_not_recoverable,
|
||||||
|
stream_timeout,
|
||||||
|
text_file_busy,
|
||||||
|
timed_out,
|
||||||
|
too_many_files_open_in_system,
|
||||||
|
too_many_files_open,
|
||||||
|
too_many_links,
|
||||||
|
too_many_symbolic_link_levels,
|
||||||
|
value_too_large,
|
||||||
|
wrong_protocol_type
|
||||||
|
};
|
||||||
|
|
||||||
|
int const n = sizeof( gen ) / sizeof( gen[0] );
|
||||||
|
|
||||||
|
for( int i = 0; i < n; ++i )
|
||||||
|
{
|
||||||
|
if( ev == gen[ i ] ) return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline error_condition system_category_default_error_condition_posix( int ev ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
if( is_generic_value( ev ) )
|
||||||
|
{
|
||||||
|
return error_condition( ev, generic_category() );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return error_condition( ev, system_category() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace detail
|
||||||
|
|
||||||
|
} // namespace system
|
||||||
|
|
||||||
|
} // namespace boost
|
@ -1,18 +1,17 @@
|
|||||||
// Windows implementation of system_error_category
|
// Windows implementation of system_error_category
|
||||||
|
//
|
||||||
// Copyright Beman Dawes 2002, 2006
|
// Copyright Beman Dawes 2002, 2006
|
||||||
// Copyright (c) Microsoft Corporation 2014
|
// Copyright (c) Microsoft Corporation 2014
|
||||||
// Copyright 2018 Peter Dimov
|
// Copyright 2018 Peter Dimov
|
||||||
|
//
|
||||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
// 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)
|
// 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
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
#include <boost/winapi/error_codes.hpp>
|
#include <boost/winapi/error_codes.hpp>
|
||||||
#include <boost/winapi/error_handling.hpp>
|
#include <boost/winapi/error_handling.hpp>
|
||||||
#include <boost/winapi/character_code_conversion.hpp>
|
#include <boost/winapi/character_code_conversion.hpp>
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
//
|
//
|
||||||
// See library home page at http://www.boost.org/libs/system
|
// See library home page at http://www.boost.org/libs/system
|
||||||
|
|
||||||
|
#include <boost/system/api_config.hpp>
|
||||||
#include <boost/system/detail/config.hpp>
|
#include <boost/system/detail/config.hpp>
|
||||||
#include <boost/type_traits/enable_if.hpp>
|
#include <boost/type_traits/enable_if.hpp>
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
@ -748,7 +749,7 @@ inline std::string generic_error_category::message( int ev ) const
|
|||||||
|
|
||||||
// system_error_category implementation
|
// system_error_category implementation
|
||||||
|
|
||||||
#if defined(BOOST_SYSTEM_WIN32)
|
#if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
#include <boost/system/detail/system_category_win32.hpp>
|
#include <boost/system/detail/system_category_win32.hpp>
|
||||||
|
|
||||||
@ -762,7 +763,9 @@ inline boost::system::error_condition boost::system::detail::system_error_catego
|
|||||||
return system_category_default_error_condition_win32( ev );
|
return system_category_default_error_condition_win32( ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
#else // #if defined(BOOST_SYSTEM_WIN32)
|
#else // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
|
#include <boost/system/detail/system_category_posix.hpp>
|
||||||
|
|
||||||
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
||||||
{
|
{
|
||||||
@ -771,10 +774,10 @@ inline std::string boost::system::detail::system_error_category::message( int ev
|
|||||||
|
|
||||||
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
inline boost::system::error_condition boost::system::detail::system_error_category::default_error_condition( int ev ) const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return boost::system::error_condition( ev, generic_category() );
|
return system_category_default_error_condition_posix( ev );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif // #if defined(BOOST_SYSTEM_WIN32)
|
#endif // #if defined(BOOST_WINDOWS_API)
|
||||||
|
|
||||||
// interoperability with std::error_code, std::error_condition
|
// interoperability with std::error_code, std::error_condition
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user