12 #ifndef ASIO_IP_NETWORK_V4_HPP 13 #define ASIO_IP_NETWORK_V4_HPP 15 #if defined(_MSC_VER) && (_MSC_VER >= 1200) 17 #endif // defined(_MSC_VER) && (_MSC_VER >= 1200) 19 #include "asio/detail/config.hpp" 21 #include "asio/detail/string_view.hpp" 22 #include "asio/error_code.hpp" 23 #include "asio/ip/address_v4_range.hpp" 25 #include "asio/detail/push_options.hpp" 51 unsigned short prefix_len);
59 : address_(other.address_),
60 prefix_length_(other.prefix_length_)
64 #if defined(ASIO_HAS_MOVE) 67 : address_(ASIO_MOVE_CAST(
address_v4)(other.address_)),
68 prefix_length_(other.prefix_length_)
71 #endif // defined(ASIO_HAS_MOVE) 74 network_v4&
operator=(
const network_v4& other) ASIO_NOEXCEPT
76 address_ = other.address_;
77 prefix_length_ = other.prefix_length_;
81 #if defined(ASIO_HAS_MOVE) 82 network_v4&
operator=(network_v4&& other) ASIO_NOEXCEPT
85 address_ = ASIO_MOVE_CAST(
address_v4)(other.address_);
86 prefix_length_ = other.prefix_length_;
89 #endif // defined(ASIO_HAS_MOVE) 101 return prefix_length_;
131 return prefix_length_ == 32;
135 ASIO_DECL
bool is_subnet_of(
const network_v4& other)
const;
144 friend bool operator==(
const network_v4& a,
const network_v4& b)
146 return a.address_ == b.address_ && a.prefix_length_ == b.prefix_length_;
150 friend bool operator!=(
const network_v4& a,
const network_v4& b)
157 unsigned short prefix_length_;
165 const address_v4& addr,
unsigned short prefix_len)
210 #if defined(ASIO_HAS_STRING_VIEW) \ 211 || defined(GENERATING_DOCUMENTATION) 228 #endif // defined(ASIO_HAS_STRING_VIEW) 231 #if !defined(ASIO_NO_IOSTREAM) 245 template <
typename Elem,
typename Traits>
246 std::basic_ostream<Elem, Traits>& operator<<(
247 std::basic_ostream<Elem, Traits>& os,
const network_v4& net);
249 #endif // !defined(ASIO_NO_IOSTREAM) 254 #include "asio/detail/pop_options.hpp" 256 #include "asio/ip/impl/network_v4.hpp" 257 #if defined(ASIO_HEADER_ONLY) 258 # include "asio/ip/impl/network_v4.ipp" 259 #endif // defined(ASIO_HEADER_ONLY) 261 #endif // ASIO_IP_NETWORK_V4_HPP ASIO_DECL network_v4 make_network_v4(const char *str)
Create an IPv4 network from a string containing IP address and prefix length.
Definition: network_v4.ipp:140
friend bool operator!=(const network_v4 &a, const network_v4 &b)
Compare two networks for inequality.
Definition: network_v4.hpp:150
unsigned short prefix_length() const ASIO_NOEXCEPT
Obtain the prefix length that was specified when the network object was created.
Definition: network_v4.hpp:99
Implements IP version 4 style addresses.
Definition: address_v4.hpp:45
Represents a range of IPv4 addresses.
Definition: address_v4_range.hpp:34
network_v4 make_network_v4(const address_v4 &addr, unsigned short prefix_len)
Create an IPv4 network from an address and prefix length.
Definition: network_v4.hpp:164
network_v4 & operator=(const network_v4 &other) ASIO_NOEXCEPT
Assign from another network.
Definition: network_v4.hpp:74
address_v4 broadcast() const ASIO_NOEXCEPT
Obtain an address object that represents the network's broadcast address.
Definition: network_v4.hpp:114
ASIO_DECL uint_type to_uint() const ASIO_NOEXCEPT
Get the address as an unsigned integer in host byte order.
Definition: address_v4.ipp:72
Represents an IPv4 network.
Definition: network_v4.hpp:39
bool is_host() const ASIO_NOEXCEPT
Test if network is a valid host address.
Definition: network_v4.hpp:129
address_v4 address() const ASIO_NOEXCEPT
Obtain the address object specified when the network object was created.
Definition: network_v4.hpp:92
network_v4(const network_v4 &other) ASIO_NOEXCEPT
Copy constructor.
Definition: network_v4.hpp:58
ASIO_DECL std::string to_string() const
Get the network as an address in dotted decimal format.
Definition: network_v4.ipp:119
friend bool operator==(const network_v4 &a, const network_v4 &b)
Compare two networks for equality.
Definition: network_v4.hpp:144
network_v4 make_network_v4(const address_v4 &addr, const address_v4 &mask)
Create an IPv4 network from an address and netmask.
Definition: network_v4.hpp:174
Class to represent an error code value.
Definition: error_code.hpp:80
network_v4 canonical() const ASIO_NOEXCEPT
Obtain the true network address, omitting any host bits.
Definition: network_v4.hpp:123
ASIO_DECL bool is_subnet_of(const network_v4 &other) const
Test if a network is a real subnet of another network.
Definition: network_v4.ipp:111
ASIO_DECL address_v4_range hosts() const ASIO_NOEXCEPT
Obtain an address range corresponding to the hosts in the network.
Definition: network_v4.ipp:104
ASIO_DECL address_v4 netmask() const ASIO_NOEXCEPT
Obtain the netmask that was specified when the network object was created.
Definition: network_v4.ipp:94
Definition: any_io_executor.hpp:28
address_v4 network() const ASIO_NOEXCEPT
Obtain an address object that represents the network address.
Definition: network_v4.hpp:108
network_v4() ASIO_NOEXCEPT
Default constructor.
Definition: network_v4.hpp:43