Spicy
Public Member Functions | List of all members
hilti::rt::Network Class Reference

#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
 
Networkoperator= (const Network &)=default
 
Networkoperator= (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
 
 operator std::string () const
 

Detailed Description

Represents HILTI's network type.

Constructor & Destructor Documentation

◆ Network() [1/2]

hilti::rt::Network::Network ( const Address prefix,
int  length 
)
inline

Constructs a network from prefix address and length.

Parameters
prefixprefix address, which's length lower bits will be masked out.
lengthprefix length, which must be in the range from 0-32 for IPv4 addresses; and 0-128 for IPv6 addresses.
Exceptions
InvalidArgumentfor invalid length values.

◆ Network() [2/2]

hilti::rt::Network::Network ( const std::string &  prefix,
int  length 
)
inline

Constructs a network from prefix address and length.

Parameters
prefixprefix address, which's length lower bits will be masked out.
lengthprefix length, which must be in the range from 0-32 for IPv4 addresses; and 0-128 for IPv6 addresses.
Exceptions
RuntimeErrorif it cannot parse the prefix into a valid IPv4 or IPv6 address.
InvalidArgumentfor invalid length values.

Member Function Documentation

◆ contains()

bool hilti::rt::Network::contains ( const Address x) const
inline

Returns true if the network includes a given address.

◆ family()

auto hilti::rt::Network::family ( ) const
inline

Returns the protocol family of the network, which can be IPv4 or IPv6.

◆ length()

auto hilti::rt::Network::length ( ) const
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.

◆ operator std::string()

hilti::rt::Network::operator std::string ( ) const
inline

Returns a human-readable representation of the network, using the same format that the corresponding constructor parses.

◆ prefix()

const auto& hilti::rt::Network::prefix ( ) const
inline

Returns the network prefix, with the lower bits masked out.


The documentation for this class was generated from the following file: