![]() |
Spicy
|
#include <network.h>
Public Member Functions | |
Network (const Address &prefix, int length) | |
Network (const std::string &prefix, int length) | |
Network (const Network &)=default | |
Network (Network &&) noexcept=default | |
Network & | operator= (const Network &)=default |
Network & | operator= (Network &&) noexcept=default |
const auto & | prefix () const |
auto | family () const |
auto | length () const |
bool | contains (const Address &x) const |
bool | operator== (const Network &other) const |
bool | operator!= (const Network &other) const |
bool | operator< (const Network &other) const |
operator std::string () const | |
Represents HILTI's network type.
|
inline |
Constructs a network from prefix address and length.
prefix | prefix address, which's length lower bits will be masked out. |
length | prefix length, which must be in the range from 0-32 for IPv4 addresses; and 0-128 for IPv6 addresses. |
InvalidArgument | for invalid length values. |
|
inline |
Constructs a network from prefix address and length.
prefix | prefix address, which's length lower bits will be masked out. |
length | prefix length, which must be in the range from 0-32 for IPv4 addresses; and 0-128 for IPv6 addresses. |
RuntimeError | if it cannot parse the prefix into a valid IPv4 or IPv6 address. |
InvalidArgument | for invalid length values. |
|
inline |
Returns true if the network includes a given address.
|
inline |
Returns the protocol family of the network, which can be IPv4 or IPv6.
|
inline |
Returns the length of the prefix. If the prefix' protocol family is IPv4, this will be between 0 and 32; if IPv6, between 0 and 128.
|
inline |
Returns a human-readable representation of the network, using the same format that the corresponding constructor parses.
|
inline |
Returns the network prefix, with the lower bits masked out.