2018-09-16 03:04:19 +03:00
|
|
|
#ifndef BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED
|
|
|
|
|
#define BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED
|
2006-11-03 16:57:30 +00:00
|
|
|
|
2007-09-09 14:59:10 +00:00
|
|
|
// Copyright Beman Dawes 2006, 2007
|
|
|
|
|
// Copyright Christoper Kohlhoff 2007
|
2018-01-22 21:13:02 +02:00
|
|
|
// Copyright Peter Dimov 2017, 2018
|
2018-09-16 03:04:19 +03:00
|
|
|
//
|
2006-11-03 16:57:30 +00:00
|
|
|
// 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)
|
2018-09-16 03:04:19 +03:00
|
|
|
//
|
2007-09-09 14:59:10 +00:00
|
|
|
// See library home page at http://www.boost.org/libs/system
|
2006-11-03 16:57:30 +00:00
|
|
|
|
2020-08-26 22:46:27 +03:00
|
|
|
#include <boost/system/is_error_code_enum.hpp>
|
|
|
|
|
#include <boost/system/is_error_condition_enum.hpp>
|
2020-08-27 00:31:45 +03:00
|
|
|
#include <boost/system/detail/errc.hpp>
|
2020-08-27 00:47:48 +03:00
|
|
|
#include <boost/system/detail/error_category.hpp>
|
2020-08-27 01:06:07 +03:00
|
|
|
#include <boost/system/detail/generic_category.hpp>
|
2020-08-27 01:15:28 +03:00
|
|
|
#include <boost/system/detail/system_category.hpp>
|
2020-08-27 01:21:56 +03:00
|
|
|
#include <boost/system/detail/enable_if.hpp>
|
2020-08-27 02:07:22 +03:00
|
|
|
#include <boost/system/detail/error_condition.hpp>
|
2020-08-27 02:23:50 +03:00
|
|
|
#include <boost/system/detail/error_code.hpp>
|
2020-08-27 03:06:14 +03:00
|
|
|
#include <boost/system/detail/throws.hpp>
|
2020-08-27 03:23:00 +03:00
|
|
|
#include <boost/system/detail/error_category_impl.hpp>
|
2018-09-16 05:44:58 +03:00
|
|
|
#include <boost/system/api_config.hpp>
|
2018-09-16 03:04:19 +03:00
|
|
|
#include <boost/system/detail/config.hpp>
|
|
|
|
|
#include <boost/cstdint.hpp>
|
|
|
|
|
#include <boost/config.hpp>
|
2007-09-09 14:59:10 +00:00
|
|
|
#include <ostream>
|
2006-11-03 16:57:30 +00:00
|
|
|
#include <string>
|
2007-09-09 14:59:10 +00:00
|
|
|
#include <functional>
|
2018-09-21 03:16:55 +03:00
|
|
|
#include <cstring>
|
2007-09-09 14:59:10 +00:00
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
#if defined(BOOST_SYSTEM_HAS_SYSTEM_ERROR)
|
|
|
|
|
# include <system_error>
|
2018-01-14 07:24:00 +02:00
|
|
|
#endif
|
|
|
|
|
|
2018-09-17 02:55:40 +03:00
|
|
|
#if !defined(BOOST_POSIX_API) && !defined(BOOST_WINDOWS_API)
|
|
|
|
|
# error BOOST_POSIX_API or BOOST_WINDOWS_API must be defined
|
|
|
|
|
#endif
|
|
|
|
|
|
2006-11-03 16:57:30 +00:00
|
|
|
namespace boost
|
|
|
|
|
{
|
|
|
|
|
|
2018-09-15 20:05:10 +03:00
|
|
|
namespace system
|
|
|
|
|
{
|
2006-11-03 16:57:30 +00:00
|
|
|
|
2018-09-15 20:05:10 +03:00
|
|
|
class error_code; // values defined by the operating system
|
|
|
|
|
class error_condition; // portable generic values defined below, but ultimately
|
|
|
|
|
// based on the POSIX standard
|
2006-11-03 16:57:30 +00:00
|
|
|
|
2018-09-15 20:05:10 +03:00
|
|
|
} // namespace system
|
2018-09-16 03:04:19 +03:00
|
|
|
|
|
|
|
|
// non-member functions of error_code and error_condition
|
|
|
|
|
|
2018-09-15 20:05:10 +03:00
|
|
|
namespace system
|
|
|
|
|
{
|
2013-03-24 20:20:29 +00:00
|
|
|
|
2018-09-15 20:06:14 +03:00
|
|
|
inline bool operator==( const error_code & code, const error_condition & condition ) BOOST_NOEXCEPT
|
2018-09-15 20:05:10 +03:00
|
|
|
{
|
|
|
|
|
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-15 20:06:14 +03:00
|
|
|
inline bool operator!=( const error_code & lhs, const error_condition & rhs ) BOOST_NOEXCEPT
|
2018-09-15 20:05:10 +03:00
|
|
|
{
|
|
|
|
|
return !( lhs == rhs );
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-15 20:06:14 +03:00
|
|
|
inline bool operator==( const error_condition & condition, const error_code & code ) BOOST_NOEXCEPT
|
2018-09-15 20:05:10 +03:00
|
|
|
{
|
2018-10-02 02:59:03 +03:00
|
|
|
return code.category().equivalent( code.value(), condition ) || condition.category().equivalent( code, condition.value() );
|
2018-09-15 20:05:10 +03:00
|
|
|
}
|
|
|
|
|
|
2018-09-15 20:06:14 +03:00
|
|
|
inline bool operator!=( const error_condition & lhs, const error_code & rhs ) BOOST_NOEXCEPT
|
2018-09-15 20:05:10 +03:00
|
|
|
{
|
|
|
|
|
return !( lhs == rhs );
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
// make_* functions for errc::errc_t
|
2007-09-09 14:59:10 +00:00
|
|
|
|
2018-09-15 20:05:10 +03:00
|
|
|
namespace errc
|
|
|
|
|
{
|
2007-09-09 14:59:10 +00:00
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
// explicit conversion:
|
|
|
|
|
BOOST_SYSTEM_CONSTEXPR inline error_code make_error_code( errc_t e ) BOOST_NOEXCEPT
|
2018-09-15 20:05:10 +03:00
|
|
|
{
|
|
|
|
|
return error_code( e, generic_category() );
|
|
|
|
|
}
|
2007-09-09 14:59:10 +00:00
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
// implicit conversion:
|
|
|
|
|
BOOST_SYSTEM_CONSTEXPR inline error_condition make_error_condition( errc_t e ) BOOST_NOEXCEPT
|
2018-09-15 20:05:10 +03:00
|
|
|
{
|
|
|
|
|
return error_condition( e, generic_category() );
|
|
|
|
|
}
|
2007-09-09 14:59:10 +00:00
|
|
|
|
2018-09-15 20:05:10 +03:00
|
|
|
} // namespace errc
|
2007-09-09 14:59:10 +00:00
|
|
|
|
2018-09-15 20:05:10 +03:00
|
|
|
} // namespace system
|
|
|
|
|
|
2006-11-03 16:57:30 +00:00
|
|
|
} // namespace boost
|
|
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
// system_error_category implementation
|
2006-11-03 16:57:30 +00:00
|
|
|
|
2018-09-16 05:44:58 +03:00
|
|
|
#if defined(BOOST_WINDOWS_API)
|
2007-09-09 14:59:10 +00:00
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
#include <boost/system/detail/system_category_win32.hpp>
|
|
|
|
|
|
2018-09-21 03:16:55 +03:00
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
|
|
|
|
{
|
|
|
|
|
return system_category_message_win32( ev );
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-21 03:16:55 +03:00
|
|
|
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
2018-09-16 03:04:19 +03:00
|
|
|
{
|
2018-09-21 03:16:55 +03:00
|
|
|
return system_category_message_win32( ev, buffer, len );
|
2018-09-16 03:04:19 +03:00
|
|
|
}
|
|
|
|
|
|
2018-09-16 05:44:58 +03:00
|
|
|
#else // #if defined(BOOST_WINDOWS_API)
|
|
|
|
|
|
|
|
|
|
#include <boost/system/detail/system_category_posix.hpp>
|
2018-09-16 03:04:19 +03:00
|
|
|
|
2018-09-21 03:16:55 +03:00
|
|
|
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 );
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-16 03:04:19 +03:00
|
|
|
inline std::string boost::system::detail::system_error_category::message( int ev ) const
|
|
|
|
|
{
|
|
|
|
|
return generic_error_category_message( ev );
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-21 03:16:55 +03:00
|
|
|
inline char const * boost::system::detail::system_error_category::message( int ev, char * buffer, std::size_t len ) const BOOST_NOEXCEPT
|
2018-09-16 03:04:19 +03:00
|
|
|
{
|
2018-09-21 03:16:55 +03:00
|
|
|
return generic_error_category_message( ev, buffer, len );
|
2018-09-16 03:04:19 +03:00
|
|
|
}
|
|
|
|
|
|
2018-09-16 05:44:58 +03:00
|
|
|
#endif // #if defined(BOOST_WINDOWS_API)
|
2018-09-16 03:04:19 +03:00
|
|
|
|
|
|
|
|
#endif // BOOST_SYSTEM_ERROR_CODE_HPP_INCLUDED
|