Boost Asio总结class address
Posted thefist11
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Boost Asio总结class address相关的知识,希望对你有一定的参考价值。
class address
public:
/// Default constructor.
BOOST_ASIO_DECL address() BOOST_ASIO_NOEXCEPT;
/// Construct an address from an IPv4 address.
BOOST_ASIO_DECL address(
const boost::asio::ip::address_v4& ipv4_address) BOOST_ASIO_NOEXCEPT;
/// Construct an address from an IPv6 address.
BOOST_ASIO_DECL address(
const boost::asio::ip::address_v6& ipv6_address) BOOST_ASIO_NOEXCEPT;
/// Copy constructor.
BOOST_ASIO_DECL address(const address& other) BOOST_ASIO_NOEXCEPT;
#if defined(BOOST_ASIO_HAS_MOVE)
/// Move constructor.
BOOST_ASIO_DECL address(address&& other) BOOST_ASIO_NOEXCEPT;
#endif // defined(BOOST_ASIO_HAS_MOVE)
/// Assign from another address.
BOOST_ASIO_DECL address& operator=(const address& other) BOOST_ASIO_NOEXCEPT;
#if defined(BOOST_ASIO_HAS_MOVE)
/// Move-assign from another address.
BOOST_ASIO_DECL address& operator=(address&& other) BOOST_ASIO_NOEXCEPT;
#endif // defined(BOOST_ASIO_HAS_MOVE)
/// Assign from an IPv4 address.
BOOST_ASIO_DECL address& operator=(
const boost::asio::ip::address_v4& ipv4_address) BOOST_ASIO_NOEXCEPT;
/// Assign from an IPv6 address.
BOOST_ASIO_DECL address& operator=(
const boost::asio::ip::address_v6& ipv6_address) BOOST_ASIO_NOEXCEPT;
/// Get whether the address is an IP version 4 address.
bool is_v4() const BOOST_ASIO_NOEXCEPT
return type_ == ipv4;
/// Get whether the address is an IP version 6 address.
bool is_v6() const BOOST_ASIO_NOEXCEPT
return type_ == ipv6;
/// Get the address as an IP version 4 address.
BOOST_ASIO_DECL boost::asio::ip::address_v4 to_v4() const;
/// Get the address as an IP version 6 address.
BOOST_ASIO_DECL boost::asio::ip::address_v6 to_v6() const;
/// Get the address as a string.
BOOST_ASIO_DECL std::string to_string() const;
#if !defined(BOOST_ASIO_NO_DEPRECATED)
/// (Deprecated: Use other overload.) Get the address as a string.
BOOST_ASIO_DECL std::string to_string(boost::system::error_code& ec) const;
/// (Deprecated: Use make_address().) Create an address from an IPv4 address
/// string in dotted decimal form, or from an IPv6 address in hexadecimal
/// notation.
static address from_string(const char* str);
/// (Deprecated: Use make_address().) Create an address from an IPv4 address
/// string in dotted decimal form, or from an IPv6 address in hexadecimal
/// notation.
static address from_string(const char* str, boost::system::error_code& ec);
/// (Deprecated: Use make_address().) Create an address from an IPv4 address
/// string in dotted decimal form, or from an IPv6 address in hexadecimal
/// notation.
static address from_string(const std::string& str);
/// (Deprecated: Use make_address().) Create an address from an IPv4 address
/// string in dotted decimal form, or from an IPv6 address in hexadecimal
/// notation.
static address from_string(
const std::string& str, boost::system::error_code& ec);
#endif // !defined(BOOST_ASIO_NO_DEPRECATED)
/// Determine whether the address is a loopback address.
BOOST_ASIO_DECL bool is_loopback() const BOOST_ASIO_NOEXCEPT;
/// Determine whether the address is unspecified.
BOOST_ASIO_DECL bool is_unspecified() const BOOST_ASIO_NOEXCEPT;
/// Determine whether the address is a multicast address.
BOOST_ASIO_DECL bool is_multicast() const BOOST_ASIO_NOEXCEPT;
/// Compare two addresses for equality.
BOOST_ASIO_DECL friend bool operator==(const address& a1,
const address& a2) BOOST_ASIO_NOEXCEPT;
/// Compare two addresses for inequality.
friend bool operator!=(const address& a1,
const address& a2) BOOST_ASIO_NOEXCEPT
return !(a1 == a2);
/// Compare addresses for ordering.
BOOST_ASIO_DECL friend bool operator<(const address& a1,
const address& a2) BOOST_ASIO_NOEXCEPT;
/// Compare addresses for ordering.
friend bool operator>(const address& a1,
const address& a2) BOOST_ASIO_NOEXCEPT
return a2 < a1;
/// Compare addresses for ordering.
friend bool operator<=(const address& a1,
const address& a2) BOOST_ASIO_NOEXCEPT
return !(a2 < a1);
/// Compare addresses for ordering.
friend bool operator>=(const address& a1,
const address& a2) BOOST_ASIO_NOEXCEPT
return !(a1 < a2);
private:
// The type of the address.
enum ipv4, ipv6 type_;
// The underlying IPv4 address.
boost::asio::ip::address_v4 ipv4_address_;
// The underlying IPv6 address.
boost::asio::ip::address_v6 ipv6_address_;
;
以上是关于Boost Asio总结class address的主要内容,如果未能解决你的问题,请参考以下文章