![]() |
FastEngine 0.9.3
A multiplayer oriented 2D engine made with Vulkan.
|
A class to represent an IP address. More...
#include <C_ipAddress.hpp>
Public Member Functions | |
IpAddress () noexcept | |
Build a default invalid IP address. | |
IpAddress (std::string const &address, CheckHostname check=CheckHostname::Yes) | |
Build an address from a string. | |
IpAddress (char const *address, CheckHostname check=CheckHostname::Yes) | |
IpAddress (uint8_t byte3, uint8_t byte2, uint8_t byte1, uint8_t byte0) noexcept | |
Build an ipv4 address from 4 bytes. | |
IpAddress (std::initializer_list< uint16_t > words) noexcept | |
Build an ipv4 address from 8 words in host byte order. | |
IpAddress (Ipv6Data const &data) noexcept | |
Build an ipv4 address from Ipv6Data in host byte order. | |
IpAddress (Ipv4Data address) noexcept | |
Build an ipv4 address from a host byte order integer. | |
bool | set (std::string const &address, CheckHostname check=CheckHostname::Yes) |
Build an address from a string. | |
bool | set (char const *address, CheckHostname check=CheckHostname::Yes) |
bool | set (uint8_t byte3, uint8_t byte2, uint8_t byte1, uint8_t byte0) |
Build an ipv4 address from 4 bytes. | |
bool | set (std::initializer_list< uint16_t > words) |
Build an ipv6 address from 8 words in host byte order. | |
bool | set (Ipv6Data const &data) |
Build an ipv6 address from Ipv6Data in host byte order. | |
bool | set (uint8_t const bytes[16]) |
Build an ipv6 address from a host byte order array of bytes. | |
bool | set (Ipv4Data address) |
Build an ipv4 address from a host byte order integer. | |
bool | setNetworkByteOrdered (Ipv4Data address) |
Build an ipv4 address from a network byte order integer. | |
bool | setNetworkByteOrdered (Ipv6Data const &data) |
Build an ipv6 address from a network byte order data. | |
bool | setNetworkByteOrdered (uint8_t const bytes[16]) |
Build an ipv6 address from a network byte order array of bytes. | |
bool | operator== (IpAddress const &r) const |
std::optional< std::string > | toString () const |
Get the ip address in a string format. | |
std::optional< Data > | getNetworkByteOrder () const |
Get the ip address in a network byte order. | |
std::optional< Data > | getHostByteOrder () const |
Get the ip address in host byte order. | |
Types | getType () const |
Static Public Member Functions | |
static std::optional< std::string > | getHostName () |
Get the standard hostname for the local computer. | |
static std::vector< IpAddress > | getLocalAddresses (Types type=Types::None) |
Get a list of local IpAddress of the local computer. | |
static IpAddress | Any (Types addressType) |
static IpAddress | Loopback (Types addressType) |
Static Public Attributes | |
static IpAddress const | None |
Represent an invalid address. | |
static IpAddress const | Ipv4Any |
Represent an unspecified ipv4 address "0.0.0.0". | |
static IpAddress const | Ipv6Any |
Represent an unspecified ipv6 address "::". | |
static IpAddress const | Ipv4Loopback |
Represent the local host ipv4 address "127.0.0.1". | |
static IpAddress const | Ipv6Loopback |
Represent the local host ipv6 address "::1". | |
static IpAddress const | Ipv4Broadcast |
Represent the broadcast ipv4 address "255.255.255.255". | |
Friends | |
struct | std::hash< IpAddress > |
A class to represent an IP address.
This class will automatically handle the byte order of the IP address.
|
noexcept |
Build a default invalid IP address.
fge::net::IpAddress::IpAddress | ( | std::string const & | address, |
CheckHostname | check = CheckHostname::Yes ) |
Build an address from a string.
The string can be in the ipv4 form XXX.XXX.XXX.XXX, ipv6, or a hostname.
address | A string representing the address |
check | Control if the method should check if the address is a hostname or not |
|
noexcept |
Build an ipv4 address from 4 bytes.
byte3 | The most significant byte |
byte2 | The second most significant byte |
byte1 | The second least significant byte |
byte0 | The least significant byte |
|
noexcept |
Build an ipv4 address from 8 words in host byte order.
words | The 8 words representing the ipv6 address in host byte order |
|
noexcept |
Build an ipv4 address from Ipv6Data in host byte order.
data | The Ipv6Data representing the address in host byte order |
|
noexcept |
Build an ipv4 address from a host byte order integer.
address | The host byte order integer |
|
nodiscard |
Get the ip address in host byte order.
|
staticnodiscard |
Get the standard hostname for the local computer.
|
staticnodiscard |
Get a list of local IpAddress of the local computer.
type | The type of address to get, if None, all addresses will be returned |
|
nodiscard |
Get the ip address in a network byte order.
bool fge::net::IpAddress::set | ( | Ipv4Data | address | ) |
Build an ipv4 address from a host byte order integer.
address | The host byte order integer |
bool fge::net::IpAddress::set | ( | Ipv6Data const & | data | ) |
Build an ipv6 address from Ipv6Data in host byte order.
data | The Ipv6Data representing the ipv6 address in host byte order |
bool fge::net::IpAddress::set | ( | std::initializer_list< uint16_t > | words | ) |
Build an ipv6 address from 8 words in host byte order.
Manualy build an ipv6 address with a initializer list.
words | The 8 words representing the ipv6 address in host byte order |
bool fge::net::IpAddress::set | ( | std::string const & | address, |
CheckHostname | check = CheckHostname::Yes ) |
Build an address from a string.
The string can be in the ipv4 form XXX.XXX.XXX.XXX, ipv6, or a hostname.
address | A string representing the address |
check | Control if the method should check if the address is a hostname or not |
bool fge::net::IpAddress::set | ( | uint8_t | byte3, |
uint8_t | byte2, | ||
uint8_t | byte1, | ||
uint8_t | byte0 ) |
Build an ipv4 address from 4 bytes.
byte3 | The most significant byte |
byte2 | The second most significant byte |
byte1 | The second least significant byte |
byte0 | The least significant byte |
bool fge::net::IpAddress::set | ( | uint8_t const | bytes[16] | ) |
Build an ipv6 address from a host byte order array of bytes.
bytes | The host byte order array |
bool fge::net::IpAddress::setNetworkByteOrdered | ( | Ipv4Data | address | ) |
Build an ipv4 address from a network byte order integer.
address | The network byte order integer |
bool fge::net::IpAddress::setNetworkByteOrdered | ( | Ipv6Data const & | data | ) |
Build an ipv6 address from a network byte order data.
data | The network byte order data |
bool fge::net::IpAddress::setNetworkByteOrdered | ( | uint8_t const | bytes[16] | ) |
Build an ipv6 address from a network byte order array of bytes.
bytes | The network byte order array |
|
nodiscard |
Get the ip address in a string format.
|
static |
Represent an unspecified ipv4 address "0.0.0.0".
|
static |
Represent the broadcast ipv4 address "255.255.255.255".
|
static |
Represent the local host ipv4 address "127.0.0.1".
|
static |
Represent an unspecified ipv6 address "::".
|
static |
Represent the local host ipv6 address "::1".
|
static |
Represent an invalid address.