#include <ipv4_address.hpp>
|
using | address_type = std::array< std::uint8_t, 4 > |
|
using | int_type = std::uint32_t |
|
Class to store an IPv4 address in network order, and to provide convenient access to its data as required by various network APIs.
- Author
- Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
- Version
- February 13, 2021
◆ IPv4Address() [1/3]
fly::net::IPv4Address::IPv4Address |
( |
| ) |
|
|
default |
Default constructor. Initializes the IPv4 address to 0.0.0.0.
◆ IPv4Address() [2/3]
constexpr fly::net::IPv4Address::IPv4Address |
( |
const address_type & |
address | ) |
|
|
explicitconstexprnoexcept |
Constructor. Create an IPv4 address from a 4-part array of octets in decimal format. The array should be ordered such that index 0 is the first octet and index 3 is the fourth octet.
- Parameters
-
address | The 4-part array of octets to initialize the IPv4 address from. |
◆ IPv4Address() [3/3]
constexpr fly::net::IPv4Address::IPv4Address |
( |
int_type |
address | ) |
|
|
explicitconstexprnoexcept |
Constructor. Create an IPv4 address from a network-order 32-bit value.
- Parameters
-
address | The network-order address to initialize the IPv4 address from. |
◆ from_string()
constexpr std::optional< IPv4Address > fly::net::IPv4Address::from_string |
( |
std::string_view |
address | ) |
|
|
staticconstexpr |
Construct an IPv4 address from a string in dot-decimal notation.
The provided string must betwen one and four octets, inclusive. If the string contains less than four octets, the last octet is treated as an integer of as many bytes as are required to fill out the address to four octets. Thus, the string "127.65530" is converted to the IPv4 address 127.0.255.250.
- Parameters
-
address | The string in dot-decimal notation to initialize the IPv4 address from. |
- Returns
- If successful, the constructed IPv4 address. Otherwise, an uninitialized value.
◆ host_order()
constexpr auto fly::net::IPv4Address::host_order |
( |
| ) |
const |
|
constexpr |
- Returns
- The IPv4 address as an integer in host order.
◆ in_addr_any()
constexpr IPv4Address fly::net::IPv4Address::in_addr_any |
( |
| ) |
|
|
staticconstexpr |
- Returns
- An IPv4 address representing INADDR_ANY.
◆ in_addr_broadcast()
constexpr IPv4Address fly::net::IPv4Address::in_addr_broadcast |
( |
| ) |
|
|
staticconstexpr |
- Returns
- An IPv4 address representing INADDR_BROADCAST.
◆ in_addr_loopback()
constexpr IPv4Address fly::net::IPv4Address::in_addr_loopback |
( |
| ) |
|
|
staticconstexpr |
- Returns
- An IPv4 address representing INADDR_LOOPBACK.
◆ network_order()
constexpr auto fly::net::IPv4Address::network_order |
( |
| ) |
const |
|
constexpr |
- Returns
- The IPv4 address as an integer in network order.
◆ operator<=>()
auto fly::net::IPv4Address::operator<=> |
( |
const IPv4Address & |
| ) |
const |
|
default |
Three-way-comparison operator. Defaulted to perform the comparison on the network-order IPv4 address.
The documentation for this class was generated from the following file: