forked from boostorg/system
Make errc::errc_t a scoped enum
This commit is contained in:
@@ -12,101 +12,122 @@
|
|||||||
|
|
||||||
#include <boost/system/is_error_condition_enum.hpp>
|
#include <boost/system/is_error_condition_enum.hpp>
|
||||||
#include <boost/system/detail/cerrno.hpp>
|
#include <boost/system/detail/cerrno.hpp>
|
||||||
|
#include <boost/config.hpp>
|
||||||
|
|
||||||
namespace boost
|
namespace boost
|
||||||
{
|
{
|
||||||
|
|
||||||
namespace system
|
namespace system
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#define BOOST_SYSTEM_ENUMERATE_ERRC(F) \
|
||||||
|
F(success, 0) \
|
||||||
|
F(address_family_not_supported, EAFNOSUPPORT) \
|
||||||
|
F(address_in_use, EADDRINUSE) \
|
||||||
|
F(address_not_available, EADDRNOTAVAIL) \
|
||||||
|
F(already_connected, EISCONN) \
|
||||||
|
F(argument_list_too_long, E2BIG) \
|
||||||
|
F(argument_out_of_domain, EDOM) \
|
||||||
|
F(bad_address, EFAULT) \
|
||||||
|
F(bad_file_descriptor, EBADF) \
|
||||||
|
F(bad_message, EBADMSG) \
|
||||||
|
F(broken_pipe, EPIPE) \
|
||||||
|
F(connection_aborted, ECONNABORTED) \
|
||||||
|
F(connection_already_in_progress, EALREADY) \
|
||||||
|
F(connection_refused, ECONNREFUSED) \
|
||||||
|
F(connection_reset, ECONNRESET) \
|
||||||
|
F(cross_device_link, EXDEV) \
|
||||||
|
F(destination_address_required, EDESTADDRREQ) \
|
||||||
|
F(device_or_resource_busy, EBUSY) \
|
||||||
|
F(directory_not_empty, ENOTEMPTY) \
|
||||||
|
F(executable_format_error, ENOEXEC) \
|
||||||
|
F(file_exists, EEXIST) \
|
||||||
|
F(file_too_large, EFBIG) \
|
||||||
|
F(filename_too_long, ENAMETOOLONG) \
|
||||||
|
F(function_not_supported, ENOSYS) \
|
||||||
|
F(host_unreachable, EHOSTUNREACH) \
|
||||||
|
F(identifier_removed, EIDRM) \
|
||||||
|
F(illegal_byte_sequence, EILSEQ) \
|
||||||
|
F(inappropriate_io_control_operation, ENOTTY) \
|
||||||
|
F(interrupted, EINTR) \
|
||||||
|
F(invalid_argument, EINVAL) \
|
||||||
|
F(invalid_seek, ESPIPE) \
|
||||||
|
F(io_error, EIO) \
|
||||||
|
F(is_a_directory, EISDIR) \
|
||||||
|
F(message_size, EMSGSIZE) \
|
||||||
|
F(network_down, ENETDOWN) \
|
||||||
|
F(network_reset, ENETRESET) \
|
||||||
|
F(network_unreachable, ENETUNREACH) \
|
||||||
|
F(no_buffer_space, ENOBUFS) \
|
||||||
|
F(no_child_process, ECHILD) \
|
||||||
|
F(no_link, ENOLINK) \
|
||||||
|
F(no_lock_available, ENOLCK) \
|
||||||
|
F(no_message_available, ENODATA) \
|
||||||
|
F(no_message, ENOMSG) \
|
||||||
|
F(no_protocol_option, ENOPROTOOPT) \
|
||||||
|
F(no_space_on_device, ENOSPC) \
|
||||||
|
F(no_stream_resources, ENOSR) \
|
||||||
|
F(no_such_device_or_address, ENXIO) \
|
||||||
|
F(no_such_device, ENODEV) \
|
||||||
|
F(no_such_file_or_directory, ENOENT) \
|
||||||
|
F(no_such_process, ESRCH) \
|
||||||
|
F(not_a_directory, ENOTDIR) \
|
||||||
|
F(not_a_socket, ENOTSOCK) \
|
||||||
|
F(not_a_stream, ENOSTR) \
|
||||||
|
F(not_connected, ENOTCONN) \
|
||||||
|
F(not_enough_memory, ENOMEM) \
|
||||||
|
F(not_supported, ENOTSUP) \
|
||||||
|
F(operation_canceled, ECANCELED) \
|
||||||
|
F(operation_in_progress, EINPROGRESS) \
|
||||||
|
F(operation_not_permitted, EPERM) \
|
||||||
|
F(operation_not_supported, EOPNOTSUPP) \
|
||||||
|
F(operation_would_block, EWOULDBLOCK) \
|
||||||
|
F(owner_dead, EOWNERDEAD) \
|
||||||
|
F(permission_denied, EACCES) \
|
||||||
|
F(protocol_error, EPROTO) \
|
||||||
|
F(protocol_not_supported, EPROTONOSUPPORT) \
|
||||||
|
F(read_only_file_system, EROFS) \
|
||||||
|
F(resource_deadlock_would_occur, EDEADLK) \
|
||||||
|
F(resource_unavailable_try_again, EAGAIN) \
|
||||||
|
F(result_out_of_range, ERANGE) \
|
||||||
|
F(state_not_recoverable, ENOTRECOVERABLE) \
|
||||||
|
F(stream_timeout, ETIME) \
|
||||||
|
F(text_file_busy, ETXTBSY) \
|
||||||
|
F(timed_out, ETIMEDOUT) \
|
||||||
|
F(too_many_files_open_in_system, ENFILE) \
|
||||||
|
F(too_many_files_open, EMFILE) \
|
||||||
|
F(too_many_links, EMLINK) \
|
||||||
|
F(too_many_symbolic_link_levels, ELOOP) \
|
||||||
|
F(value_too_large, EOVERFLOW) \
|
||||||
|
F(wrong_protocol_type, EPROTOTYPE)
|
||||||
|
|
||||||
namespace errc
|
namespace errc
|
||||||
{
|
{
|
||||||
|
|
||||||
|
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && !defined(BOOST_SYSTEM_ENABLE_DEPRECATED)
|
||||||
|
enum class errc_t
|
||||||
|
#else
|
||||||
enum errc_t
|
enum errc_t
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
success = 0,
|
|
||||||
address_family_not_supported = EAFNOSUPPORT,
|
#define BOOST_SYSTEM_DEFINE_ERRC(x, y) x = y,
|
||||||
address_in_use = EADDRINUSE,
|
BOOST_SYSTEM_ENUMERATE_ERRC(BOOST_SYSTEM_DEFINE_ERRC)
|
||||||
address_not_available = EADDRNOTAVAIL,
|
#undef BOOST_SYSTEM_DEFINE_ERRC
|
||||||
already_connected = EISCONN,
|
|
||||||
argument_list_too_long = E2BIG,
|
}; // enum errc_t
|
||||||
argument_out_of_domain = EDOM,
|
|
||||||
bad_address = EFAULT,
|
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS) && !defined(BOOST_SYSTEM_ENABLE_DEPRECATED)
|
||||||
bad_file_descriptor = EBADF,
|
|
||||||
bad_message = EBADMSG,
|
#define BOOST_SYSTEM_SURFACE_ERRC(x, y) BOOST_CONSTEXPR_OR_CONST errc_t x = errc_t::x;
|
||||||
broken_pipe = EPIPE,
|
BOOST_SYSTEM_ENUMERATE_ERRC(BOOST_SYSTEM_SURFACE_ERRC)
|
||||||
connection_aborted = ECONNABORTED,
|
#undef BOOST_SYSTEM_SURFACE_ERRC
|
||||||
connection_already_in_progress = EALREADY,
|
|
||||||
connection_refused = ECONNREFUSED,
|
#endif
|
||||||
connection_reset = ECONNRESET,
|
|
||||||
cross_device_link = EXDEV,
|
|
||||||
destination_address_required = EDESTADDRREQ,
|
|
||||||
device_or_resource_busy = EBUSY,
|
|
||||||
directory_not_empty = ENOTEMPTY,
|
|
||||||
executable_format_error = ENOEXEC,
|
|
||||||
file_exists = EEXIST,
|
|
||||||
file_too_large = EFBIG,
|
|
||||||
filename_too_long = ENAMETOOLONG,
|
|
||||||
function_not_supported = ENOSYS,
|
|
||||||
host_unreachable = EHOSTUNREACH,
|
|
||||||
identifier_removed = EIDRM,
|
|
||||||
illegal_byte_sequence = EILSEQ,
|
|
||||||
inappropriate_io_control_operation = ENOTTY,
|
|
||||||
interrupted = EINTR,
|
|
||||||
invalid_argument = EINVAL,
|
|
||||||
invalid_seek = ESPIPE,
|
|
||||||
io_error = EIO,
|
|
||||||
is_a_directory = EISDIR,
|
|
||||||
message_size = EMSGSIZE,
|
|
||||||
network_down = ENETDOWN,
|
|
||||||
network_reset = ENETRESET,
|
|
||||||
network_unreachable = ENETUNREACH,
|
|
||||||
no_buffer_space = ENOBUFS,
|
|
||||||
no_child_process = ECHILD,
|
|
||||||
no_link = ENOLINK,
|
|
||||||
no_lock_available = ENOLCK,
|
|
||||||
no_message_available = ENODATA,
|
|
||||||
no_message = ENOMSG,
|
|
||||||
no_protocol_option = ENOPROTOOPT,
|
|
||||||
no_space_on_device = ENOSPC,
|
|
||||||
no_stream_resources = ENOSR,
|
|
||||||
no_such_device_or_address = ENXIO,
|
|
||||||
no_such_device = ENODEV,
|
|
||||||
no_such_file_or_directory = ENOENT,
|
|
||||||
no_such_process = ESRCH,
|
|
||||||
not_a_directory = ENOTDIR,
|
|
||||||
not_a_socket = ENOTSOCK,
|
|
||||||
not_a_stream = ENOSTR,
|
|
||||||
not_connected = ENOTCONN,
|
|
||||||
not_enough_memory = ENOMEM,
|
|
||||||
not_supported = ENOTSUP,
|
|
||||||
operation_canceled = ECANCELED,
|
|
||||||
operation_in_progress = EINPROGRESS,
|
|
||||||
operation_not_permitted = EPERM,
|
|
||||||
operation_not_supported = EOPNOTSUPP,
|
|
||||||
operation_would_block = EWOULDBLOCK,
|
|
||||||
owner_dead = EOWNERDEAD,
|
|
||||||
permission_denied = EACCES,
|
|
||||||
protocol_error = EPROTO,
|
|
||||||
protocol_not_supported = EPROTONOSUPPORT,
|
|
||||||
read_only_file_system = EROFS,
|
|
||||||
resource_deadlock_would_occur = EDEADLK,
|
|
||||||
resource_unavailable_try_again = EAGAIN,
|
|
||||||
result_out_of_range = ERANGE,
|
|
||||||
state_not_recoverable = ENOTRECOVERABLE,
|
|
||||||
stream_timeout = ETIME,
|
|
||||||
text_file_busy = ETXTBSY,
|
|
||||||
timed_out = ETIMEDOUT,
|
|
||||||
too_many_files_open_in_system = ENFILE,
|
|
||||||
too_many_files_open = EMFILE,
|
|
||||||
too_many_links = EMLINK,
|
|
||||||
too_many_symbolic_link_levels = ELOOP,
|
|
||||||
value_too_large = EOVERFLOW,
|
|
||||||
wrong_protocol_type = EPROTOTYPE
|
|
||||||
};
|
|
||||||
|
|
||||||
} // namespace errc
|
} // namespace errc
|
||||||
|
|
||||||
|
#undef BOOST_SYSTEM_ENUMERATE_ERRC
|
||||||
|
|
||||||
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
#ifdef BOOST_SYSTEM_ENABLE_DEPRECATED
|
||||||
|
|
||||||
namespace posix = errc;
|
namespace posix = errc;
|
||||||
@@ -120,7 +141,6 @@ template<> struct is_error_condition_enum<errc::errc_t>
|
|||||||
};
|
};
|
||||||
|
|
||||||
} // namespace system
|
} // namespace system
|
||||||
|
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
|
#endif // #ifndef BOOST_SYSTEM_DETAIL_ERRC_HPP_INCLUDED
|
||||||
|
@@ -25,7 +25,7 @@ namespace system
|
|||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
|
||||||
inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
inline errc::errc_t system_category_condition_win32_( int ev ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
// When using the Windows Runtime, most system errors are reported as HRESULTs.
|
// When using the Windows Runtime, most system errors are reported as HRESULTs.
|
||||||
// We want to map the common Win32 errors to their equivalent error condition,
|
// We want to map the common Win32 errors to their equivalent error condition,
|
||||||
@@ -138,10 +138,15 @@ inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
|||||||
case WSAETIMEDOUT_: return timed_out;
|
case WSAETIMEDOUT_: return timed_out;
|
||||||
case WSAEWOULDBLOCK_: return operation_would_block;
|
case WSAEWOULDBLOCK_: return operation_would_block;
|
||||||
|
|
||||||
default: return -1;
|
default: return static_cast<errc::errc_t>( -1 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline int system_category_condition_win32( int ev ) BOOST_NOEXCEPT
|
||||||
|
{
|
||||||
|
return static_cast<int>( system_category_condition_win32_( ev ) );
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
|
|
||||||
} // namespace system
|
} // namespace system
|
||||||
|
@@ -32,13 +32,13 @@ namespace errc
|
|||||||
// explicit conversion:
|
// explicit conversion:
|
||||||
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return error_code( e, generic_category() );
|
return error_code( static_cast<int>( e ), generic_category() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// implicit conversion:
|
// implicit conversion:
|
||||||
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return error_condition( e, generic_category() );
|
return error_condition( static_cast<int>( e ), generic_category() );
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace errc
|
} // namespace errc
|
||||||
|
Reference in New Issue
Block a user