ipaddress 1.1.0
|
A class that represents an IP address, supporting both IPv4 and IPv6 formats. More...
#include <ip-any-address.hpp>
Public Types | |
using | base_type_ipv4 = typename ipv4_address::base_type |
Base type for IPv4 address storage. | |
using | base_type_ipv6 = typename ipv6_address::base_type |
Base type for IPv6 address storage. | |
using | uint_type_ipv4 = typename ipv4_address::uint_type |
Unsigned integer type for IPv4 address representation. | |
using | uint_type_ipv6 = typename ipv6_address::uint_type |
Unsigned integer type for IPv6 address representation. | |
Public Member Functions | |
constexpr inline ip_version | version () const noexcept |
Retrieves the version of the IP address. | |
constexpr inline bool | is_multicast () const noexcept |
Checks if the IP address is a multicast address. | |
constexpr inline bool | is_private () const noexcept |
Checks if the IP address is a private address. | |
constexpr inline bool | is_global () const noexcept |
Checks if the IP address is a global address. | |
constexpr inline bool | is_reserved () const noexcept |
Checks if the IP address is a reserved address. | |
constexpr inline bool | is_loopback () const noexcept |
Checks if the IP address is a loopback address. | |
constexpr inline bool | is_link_local () const noexcept |
Checks if the IP address is link-local. | |
constexpr inline bool | is_unspecified () const noexcept |
Checks if the IP address is unspecified. | |
constexpr inline bool | is_site_local () const noexcept |
Checks if the IPv6 address is a site-local address. | |
constexpr inline bool | is_v4 () const noexcept |
Checks if the IP address is an IPv4 address. | |
constexpr inline bool | is_v6 () const noexcept |
Checks if the IP address is an IPv6 address. | |
constexpr inline size_t | size () const noexcept |
Retrieves the size of the IP address. | |
constexpr inline size_t | hash () const noexcept |
Computes a hash value for the IP address. | |
constexpr inline optional< ipv4_address > | ipv4_mapped () const noexcept |
Determines if the IPv6 address is an IPv4-mapped address. | |
constexpr inline optional< ipv4_address > | sixtofour () const noexcept |
Determines if the IPv6 address is a 6to4 address. | |
constexpr inline optional< std::pair< ipv4_address, ipv4_address > > | teredo () const noexcept |
Determines if the IPv6 address is a Teredo address. | |
constexpr inline optional< ipv4_address > | v4 () const noexcept |
Retrieves the IPv4 address. | |
constexpr inline optional< ipv6_address > | v6 () const noexcept |
Retrieves the IPv6 address. | |
constexpr inline const uint8_t * | data () const noexcept |
Retrieves the raw data of the IP address in network byte order (big-endian). | |
constexpr inline | ip_address () noexcept |
Default constructor. | |
constexpr inline | ip_address (const ipv4_address &ipv4) noexcept |
Constructor from an ipv4_address. | |
constexpr inline | ip_address (const ipv6_address &ipv6) noexcept |
Constructor from an ipv6_address. | |
constexpr inline | ip_address (const base_type_ipv4 &bytes) noexcept |
Constructor from byte array for IPv4. | |
constexpr inline | ip_address (const base_type_ipv6 &bytes) noexcept |
Constructor from byte array for IPv6. | |
constexpr inline uint32_t | to_uint32 () const noexcept |
Converts the IP address to a uint32_t. | |
constexpr inline uint128_t | to_uint128 () const noexcept |
Converts the IP address to a uint128_t. | |
inline std::string | to_string (format fmt=format::compressed) const |
Converts the IP address to a string. | |
inline std::wstring | to_wstring (format fmt=format::compressed) const |
Converts the IP address to a string. | |
inline std::u16string | to_u16string (format fmt=format::compressed) const |
Converts the IP address to a string. | |
inline std::u32string | to_u32string (format fmt=format::compressed) const |
Converts the IP address to a string. | |
inline std::u8string | to_u8string (format fmt=format::compressed) const |
Converts the IP address to a string. | |
inline std::string | reverse_pointer () const |
Generates a reverse DNS lookup pointer for the IP address. | |
constexpr inline void | swap (ip_address &ip) noexcept |
Swaps the contents of this ip_address with another ip_address. | |
constexpr inline void | set_scope_id (std::string_view scope_id) |
Sets the scope identifier of the IPv6 address using a string view. | |
constexpr inline void | set_scope_id (std::wstring_view scope_id) |
Sets the scope identifier of the IPv6 address using a wide string view. | |
constexpr inline void | set_scope_id (std::u8string_view scope_id) |
Sets the scope identifier of the IPv6 address using UTF-8 string view. | |
constexpr inline void | set_scope_id (std::u16string_view scope_id) |
Sets the scope identifier of the IPv6 address using UTF-16 string view. | |
constexpr inline void | set_scope_id (std::u32string_view scope_id) |
Sets the scope identifier of the IPv6 address using UTF-32 string view. | |
constexpr inline void | set_scope_id (std::string_view scope_id, error_code &code) noexcept |
Sets the scope identifier of the IPv6 address using a string view and reports any errors encountered. | |
constexpr inline void | set_scope_id (std::wstring_view scope_id, error_code &code) noexcept |
Sets the scope identifier of the IPv6 address using a wide string view and reports any errors encountered. | |
constexpr inline void | set_scope_id (std::u8string_view scope_id, error_code &code) noexcept |
Sets the scope identifier of the IPv6 address using a UTF-8 string view and reports any errors encountered. | |
constexpr inline void | set_scope_id (std::u16string_view scope_id, error_code &code) noexcept |
Sets the scope identifier of the IPv6 address using a UTF-16 string view and reports any errors encountered. | |
constexpr inline void | set_scope_id (std::u32string_view scope_id, error_code &code) noexcept |
Sets the scope identifier of the IPv6 address using a UTF-32 string view and reports any errors encountered. | |
template<typename T , size_t N> | |
constexpr inline void | set_scope_id (const T(&scope_id)[N]) noexcept(noexcept(ipv6_address().set_scope_id(scope_id))) |
Sets the scope identifier of the IPv6 address. | |
constexpr inline scope | get_scope_id () const noexcept |
Retrieves the scope identifier of the IPv6 address. | |
constexpr inline | operator uint32_t () const noexcept |
Converts the IP address to a uint32_t. | |
constexpr inline | operator uint128_t () const noexcept |
Converts the IP address to a uint128_t. | |
template<typename T > | |
inline | operator std::basic_string< T, std::char_traits< T >, std::allocator< T > > () const |
Converts the IP address to a string. | |
constexpr inline bool | operator== (const ip_address &rhs) const noexcept |
Equality comparison operator. | |
constexpr inline bool | operator!= (const ip_address &rhs) const noexcept |
Inequality comparison operator. | |
constexpr inline bool | operator< (const ip_address &rhs) const noexcept |
Less than comparison operator. | |
constexpr inline bool | operator> (const ip_address &rhs) const noexcept |
Greater than comparison operator. | |
constexpr inline bool | operator<= (const ip_address &rhs) const noexcept |
Less than or equal to comparison operator. | |
constexpr inline bool | operator>= (const ip_address &rhs) const noexcept |
Greater than or equal to comparison operator. | |
Static Public Member Functions | |
static constexpr inline ip_address | from_bytes (const base_type_ipv4 &bytes) noexcept |
Static factory method to create an ip_address from byte array for IPv4. | |
static constexpr inline ip_address | from_bytes (const base_type_ipv6 &bytes) noexcept |
Static factory method to create an ip_address from byte array for IPv6. | |
static constexpr inline ip_address | from_bytes (const uint8_t *bytes, size_t byte_count, ip_version version) noexcept |
Static factory method to create an ip_address from raw bytes. | |
static constexpr inline ip_address | from_uint (uint_type_ipv4 ip) noexcept |
Static factory method to create an ip_address from a uint_type_ipv4. | |
static constexpr inline ip_address | from_uint (const uint_type_ipv6 &ip) noexcept |
Static factory method to create an ip_address from a uint_type_ipv6. | |
template<fixed_string FixedString> | |
static consteval inline ip_address | parse () noexcept |
Static method template to parse an IP address from a fixed string at compile time. | |
static constexpr inline ip_address | parse (std::string_view address) |
Parses an IP address from a string view. | |
static constexpr inline ip_address | parse (std::wstring_view address) |
Parses an IP address from a wide string view. | |
static constexpr inline ip_address | parse (std::u8string_view address) |
Parses an IP address from a UTF-8 string view. | |
static constexpr inline ip_address | parse (std::u16string_view address) |
Parses an IP address from a UTF-16 string view. | |
static constexpr inline ip_address | parse (std::u32string_view address) |
Parses an IP address from a UTF-32 string view. | |
static constexpr inline ip_address | parse (std::string_view address, error_code &code) noexcept |
Parses an IP address from a string view and reports errors through an error code. | |
static constexpr inline ip_address | parse (std::wstring_view address, error_code &code) noexcept |
Parses an IP address from a wide string view and reports errors through an error code. | |
static constexpr inline ip_address | parse (std::u8string_view address, error_code &code) noexcept |
Parses an IP address from a UTF-8 string view and reports errors through an error code. | |
static constexpr inline ip_address | parse (std::u16string_view address, error_code &code) noexcept |
Parses an IP address from a UTF-16 string view and reports errors through an error code. | |
static constexpr inline ip_address | parse (std::u32string_view address, error_code &code) noexcept |
Parses an IP address from a UTF-32 string view and reports errors through an error code. | |
template<typename T , size_t N> | |
static constexpr inline ip_address | parse (const T(&address)[N]) |
Parses an IP address from a character array. | |
template<typename T , size_t N> | |
static constexpr inline ip_address | parse (const T(&address)[N], error_code &code) noexcept |
Parses an IP address from a character array and reports errors through an error code. | |
A class that represents an IP address, supporting both IPv4 and IPv6 formats.
The ip_address class is a union-type structure that encapsulates both ipv4_address and ipv6_address, allowing for the representation and manipulation of both IPv4 and IPv6 addresses. It provides a set of functions and type aliases that facilitate the handling of IP addresses in a network context, making it a versatile tool for developers working with IP-based communications.
The class ensures that the size of its instances will always be large enough to store an IPv6 address, which is the larger of the two address types. This design guarantees that an ip_address object can store any valid IP address, regardless of its version, without the need for separate storage mechanisms.
|
inlinenoexcept |
Default constructor.
Constructs an ip_address object with an unspecified ip address with version IPv4.
|
inlinenoexcept |
Constructor from an ipv4_address.
Constructs an ip_address object with the specified IPv4 address.
[in] | ipv4 | An ipv4_address object to initialize the ip_address. |
|
inlinenoexcept |
Constructor from an ipv6_address.
Constructs an ip_address object with the specified IPv6 address.
[in] | ipv6 | An ipv6_address object to initialize the ip_address. |
|
inlineexplicitnoexcept |
Constructor from byte array for IPv4.
Constructs an ip_address object with the specified byte array for an IPv4 address.
[in] | bytes | A base_type_ipv4 object representing the byte array of the IPv4 address. |
|
inlineexplicitnoexcept |
Constructor from byte array for IPv6.
Constructs an ip_address object with the specified byte array for an IPv6 address.
[in] | bytes | A base_type_ipv6 object representing the byte array of the IPv6 address. |
|
inlinenoexcept |
Retrieves the version of the IP address.
|
inlinenoexcept |
|
inlinenoexcept |
Checks if the IP address is a private address.
true
if the IP address is allocated for private networks, false
otherwise.
|
inlinenoexcept |
Checks if the IP address is a global address.
true
if the IP address is allocated for public networks, false
otherwise.
|
inlinenoexcept |
Checks if the IP address is a reserved address.
true
if the IP address is otherwise IETF reserved, false
otherwise.
|
inlinenoexcept |
|
inlinenoexcept |
Checks if the IP address is link-local.
|
inlinenoexcept |
Checks if the IP address is unspecified.
An unspecified IP address is an address with all bits set to zero. In IPv4, this is represented as 0.0.0.0, and in IPv6, as ::. This type of address is used to indicate the absence of an address.
true
if the IP address is unspecified (all bits are zero), false
otherwise.
|
inlinenoexcept |
Checks if the IPv6 address is a site-local address.
true
if the address is site-local, false
otherwise.
|
inlinenoexcept |
Checks if the IP address is an IPv4 address.
true
if the IP address is an IPv4 address, false
otherwise.
|
inlinenoexcept |
Checks if the IP address is an IPv6 address.
true
if the IP address is an IPv6 address, false
otherwise.
|
inlinenoexcept |
Retrieves the size of the IP address.
Depending on the IP version, this function returns the size of the IPv4 or IPv6 address.
|
inlinenoexcept |
Computes a hash value for the IP address.
This function generates a hash value that can be used to uniquely identify the IP address. It can be useful when IP addresses are used as keys in hash tables.
size_t
hash value of the IP address.
|
inlinenoexcept |
Determines if the IPv6 address is an IPv4-mapped address.
If the IP address is an IPv6 address, this function returns the IPv4-mapped IPv6 address if available.
optional
containing the mapped IPv4 address if the IPv6 address is IPv4-mapped, or an empty optional
otherwise. ::FFFF/96
).
|
inlinenoexcept |
Determines if the IPv6 address is a 6to4 address.
If the IP address is an IPv6 address, this function returns the 6to4 address if available.
2002::/16
prefix and embeds an IPv4 address in the next 32 bits.
|
inlinenoexcept |
Determines if the IPv6 address is a Teredo address.
If the IP address is an IPv6 address, this function returns the Teredo address, which includes both the Teredo server and client IPv4 addresses.
std::pair::first | The Teredo server IPv4 address |
std::pair::second | The Teredo client IPv4 address |
2001::/32
prefix and is used for NAT traversal for IPv6.
|
inlinenoexcept |
Retrieves the IPv4 address.
If the IP address is an IPv4 address, this function returns the IPv4 address.
|
inlinenoexcept |
Retrieves the IPv6 address.
If the IP address is an IPv6 address, this function returns the IPv6 address.
|
inlinenoexcept |
Retrieves the raw data of the IP address in network byte order (big-endian).
This function returns a pointer to the raw data representing the IP address. The format of the data depends on whether the address is IPv4 or IPv6.
|
inlinestaticnoexcept |
Static factory method to create an ip_address from byte array for IPv4.
[in] | bytes | A base_type_ipv4 object representing the byte array of the IPv4 address. |
|
inlinestaticnoexcept |
Static factory method to create an ip_address from byte array for IPv6.
[in] | bytes | A base_type_ipv6 object representing the byte array of the IPv6 address. |
|
inlinestaticnoexcept |
Static factory method to create an ip_address from raw bytes.
This method creates an ip_address object from raw bytes, with the specified IP version.
[in] | bytes | A pointer to the raw bytes representing the IP address. |
[in] | byte_count | The number of bytes to use from the pointer. |
[in] | version | The version of the IP address to create (IPv4 or IPv6). |
|
inlinestaticnoexcept |
Static factory method to create an ip_address from a uint_type_ipv4.
[in] | ip | A uint_type_ipv4 (uint32_t) representing the IPv4 address. |
|
inlinestaticnoexcept |
Static factory method to create an ip_address from a uint_type_ipv6.
[in] | ip | A uint_type_ipv6 (uint128_t) representing the IPv6 address. |
|
inlinenoexcept |
Converts the IP address to a uint32_t.
This function returns the numeric representation of the IP address as a uint32_t. For IPv6 addresses, it returns the least significant 32 bits of the address.
|
inlinenoexcept |
Converts the IP address to a uint128_t.
This function returns the numeric representation of the IP address as a uint128_t. For IPv4 addresses, the function converts the address to a uint128_t format.
|
inline |
Converts the IP address to a string.
This function returns a string representation of the IP address. The format can be specified by the fmt parameter.
[in] | fmt | The format to use for the string representation, defaults to compressed format. |
std::string
representing the IP address in the specified format.
|
inline |
Converts the IP address to a string.
This function returns a string representation of the IP address. The format can be specified by the fmt parameter.
[in] | fmt | The format to use for the string representation, defaults to compressed format. |
std::wstring
representing the IP address in the specified format.
|
inline |
Converts the IP address to a string.
This function returns a string representation of the IP address. The format can be specified by the fmt parameter.
[in] | fmt | The format to use for the string representation, defaults to compressed format. |
std::u16string
representing the IP address in the specified format.
|
inline |
Converts the IP address to a string.
This function returns a string representation of the IP address. The format can be specified by the fmt parameter.
[in] | fmt | The format to use for the string representation, defaults to compressed format. |
std::u32string
representing the IP address in the specified format.
|
inline |
Converts the IP address to a string.
This function returns a string representation of the IP address. The format can be specified by the fmt parameter.
[in] | fmt | The format to use for the string representation, defaults to compressed format. |
std::u8string
representing the IP address in the specified format.
|
inline |
Generates a reverse DNS lookup pointer for the IP address.
This function creates a string that is the reverse DNS lookup pointer of the IP address. It is commonly used in reverse DNS lookups, where the IP address is reversed and appended with .in-addr.arpa
for IPv4, or .ip6.arpa
for IPv6, to form a domain name that can be looked up in the DNS system.
The name of the reverse DNS PTR record for the IP address, e.g.:
std::string
that is the reverse DNS lookup pointer of the IP address.
|
inlinenoexcept |
Swaps the contents of this ip_address with another ip_address.
This function exchanges the contents of the ip_address with those of the ip parameter.
[in] | ip | The other ip_address object to swap with. |
|
inlinestaticnoexcept |
Static method template to parse an IP address from a fixed string at compile time.
FixedString | A non-type template parameter that holds the string representation of the IP address. |
|
inlinestatic |
Parses an IP address from a string view.
This method provides a way to parse an IP address from a string view, which is a non-owning reference to a sequence of characters.
[in] | address | The string view containing the IP address to parse. |
parse_error | Exception caused by invalid input string. |
std::string
and C-strings will be used instead.
|
inlinestatic |
Parses an IP address from a wide string view.
This method allows for parsing an IP address from a wide string view, which is typically used for wide character strings.
[in] | address | The wide string view containing the IP address to parse. |
parse_error | Exception caused by invalid input string. |
std::wstring
and C-strings will be used instead.
|
inlinestatic |
Parses an IP address from a UTF-8 string view.
This method parses an IP address from a given UTF-8 string view. It leverages the char8_t
type introduced in C++20 to handle UTF-8 strings natively.
[in] | address | A UTF-8 string view containing the IP address to parse. |
parse_error | Exception caused by invalid input string. |
char8_t
is supported.
|
inlinestatic |
Parses an IP address from a UTF-16 string view.
This method is designed to parse an IP address from a UTF-16 string view, which is a sequence of 16-bit characters.
[in] | address | The UTF-16 string view containing the IP address to parse. |
parse_error | Exception caused by invalid input string. |
std::u16string
and C-strings will be used instead.
|
inlinestatic |
Parses an IP address from a UTF-32 string view.
This method allows for parsing an IP address from a UTF-32 string view, which is a sequence of 32-bit characters.
[in] | address | The UTF-32 string view containing the IP address to parse. |
parse_error | Exception caused by invalid input string. |
std::u32string
and C-strings will be used instead.
|
inlinestaticnoexcept |
Parses an IP address from a string view and reports errors through an error code.
This method parses an IP address from a string view and provides an error code if the parsing fails.
[in] | address | The string view containing the IP address to parse. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
std::string
and C-strings will be used instead.
|
inlinestaticnoexcept |
Parses an IP address from a wide string view and reports errors through an error code.
This method parses an IP address from a wide string view and provides an error code if the parsing fails.
[in] | address | The wide string view containing the IP address to parse. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
std::wstring
and C-strings will be used instead.
|
inlinestaticnoexcept |
Parses an IP address from a UTF-8 string view and reports errors through an error code.
This method parses an IP address from a UTF-8 string view and provides an error code if the parsing fails.
[in] | address | The UTF-8 string view containing the IP address to parse. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
char8_t
is supported.
|
inlinestaticnoexcept |
Parses an IP address from a UTF-16 string view and reports errors through an error code.
This method parses an IP address from a UTF-16 string view and provides an error code if the parsing fails.
[in] | address | The UTF-16 string view containing the IP address to parse. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
std::u16string
and C-strings will be used instead.
|
inlinestaticnoexcept |
Parses an IP address from a UTF-32 string view and reports errors through an error code.
This method parses an IP address from a UTF-32 string view and provides an error code if the parsing fails.
[in] | address | The UTF-32 string view containing the IP address to parse. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
std::u32string
and C-strings will be used instead.
|
inline |
Sets the scope identifier of the IPv6 address using a string view.
This function sets the scope identifier using a string view, which allows for a more efficient way to handle strings without copying them.
[in] | scope_id | The string view representing the scope identifier. |
parse_error | Exception caused by invalid input string. |
std::string
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inline |
Sets the scope identifier of the IPv6 address using a wide string view.
This function sets the scope identifier using a wide string view, which allows for a more efficient way to handle strings without copying them.
[in] | scope_id | The wide string view representing the scope identifier. |
parse_error | Exception caused by invalid input string. |
std::wstring
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inline |
Sets the scope identifier of the IPv6 address using UTF-8 string view.
This function sets the scope identifier using UTF-8 string view, which allows for a more efficient way to handle strings without copying them.
[in] | scope_id | The UTF-8 string view representing the scope identifier. |
parse_error | Exception caused by invalid input string. |
char8_t
is supported. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inline |
Sets the scope identifier of the IPv6 address using UTF-16 string view.
This function sets the scope identifier using UTF-16 string view, which allows for a more efficient way to handle strings without copying them.
[in] | scope_id | The UTF-16 string view representing the scope identifier. |
parse_error | Exception caused by invalid input string. |
std::u16string
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inline |
Sets the scope identifier of the IPv6 address using UTF-32 string view.
This function sets the scope identifier using UTF-32 string view, which allows for a more efficient way to handle strings without copying them.
[in] | scope_id | The UTF-32 string view representing the scope identifier. |
parse_error | Exception caused by invalid input string. |
std::u32string
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inlinenoexcept |
Sets the scope identifier of the IPv6 address using a string view and reports any errors encountered.
This function sets the scope identifier using a string view and provides an error code parameter to report any issues that occur during the operation.
[in] | scope_id | The string view representing the scope identifier. |
[out] | code | An error_code object that will be set to the error that occurred, if any. |
std::string
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inlinenoexcept |
Sets the scope identifier of the IPv6 address using a wide string view and reports any errors encountered.
This function sets the scope identifier using a wide string view and provides an error code parameter to report any issues that occur during the operation.
[in] | scope_id | The wide string view representing the scope identifier. |
[out] | code | An error_code object that will be set to the error that occurred, if any. |
std::wstring
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inlinenoexcept |
Sets the scope identifier of the IPv6 address using a UTF-8 string view and reports any errors encountered.
This function sets the scope identifier using a UTF-8 string view and provides an error code parameter to report any issues that occur during the operation.
[in] | scope_id | The UTF-8 string view representing the scope identifier. |
[out] | code | An error_code object that will be set to the error that occurred, if any. |
IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inlinenoexcept |
Sets the scope identifier of the IPv6 address using a UTF-16 string view and reports any errors encountered.
This function sets the scope identifier using a UTF-16 string view and provides an error code parameter to report any issues that occur during the operation.
[in] | scope_id | The UTF-16 string view representing the scope identifier. |
[out] | code | An error_code object that will be set to the error that occurred, if any. |
std::u16string
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inlinenoexcept |
Sets the scope identifier of the IPv6 address using a UTF-32 string view and reports any errors encountered.
This function sets the scope identifier using a UTF-32 string view and provides an error code parameter to report any issues that occur during the operation.
[in] | scope_id | The UTF-32 string view representing the scope identifier. |
[out] | code | An error_code object that will be set to the error that occurred, if any. |
std::u32string
and C-strings will be used instead. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inlinestatic |
Parses an IP address from a character array.
This method template parses an IP address from a character array of a specified size. Can check and get the result at compile time.
T | The character type of the array. |
N | The size of the character array. |
[in] | address | The character array containing the IP address to parse. |
|
inlinestaticnoexcept |
Parses an IP address from a character array and reports errors through an error code.
This method template parses an IP address from a character array of a specified size and provides an error code if the parsing fails.
T | The character type of the array. |
N | The size of the character array. |
[in] | address | The character array containing the IP address to parse. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
|
inlinenoexcept |
Sets the scope identifier of the IPv6 address.
This function sets the scope identifier using a character array. The length of the array should not exceed IPADDRESS_IPV6_SCOPE_MAX_LENGTH + 1
.
T | The character type of the scope identifier. |
N | The size of the scope identifier array. |
[in] | scope_id | The character array representing the scope identifier. |
IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
) then this call will have no effect.
|
inlinenoexcept |
Retrieves the scope identifier of the IPv6 address.
The scope identifier is used to determine the context in which the address is valid. It is particularly relevant for link-local and site-local addresses.
scope
object representing the scope identifier of the IPv6 address. IPADDRESS_IPV6_SCOPE_MAX_LENGTH == 0
), then an empty scope will be returned.
|
inlineexplicitnoexcept |
Converts the IP address to a uint32_t.
This function casts the IP address to a uint32_t. For IPv4 addresses, it returns the direct numeric representation. For IPv6 addresses, it returns the least significant 32 bits of the address.
|
inlineexplicitnoexcept |
Converts the IP address to a uint128_t.
This function casts the IP address to a uint128_t. It is used to obtain the full numeric representation of the IP address, especially for IPv6 addresses.
|
inlineexplicit |
Converts the IP address to a string.
This operator allows the IP address to be converted to a string.
T | The character type of the string. |
std::string
representation of the IP address.
|
inlinenoexcept |
Equality comparison operator.
Compares this IP address with another IP address for equality.
[in] | rhs | The right-hand side ip_address object for comparison. |
|
inlinenoexcept |
Inequality comparison operator.
Compares this IP address with another IP address for inequality.
[in] | rhs | The right-hand side ip_address object for comparison. |
|
inlinenoexcept |
Less than comparison operator.
Compares this IP address with another IP address to determine if it is less than the other.
[in] | rhs | The right-hand side ip_address object for comparison. |
|
inlinenoexcept |
Greater than comparison operator.
Compares this IP address with another IP address to determine if it is greater than the other.
[in] | rhs | The right-hand side ip_address object for comparison. |
|
inlinenoexcept |
Less than or equal to comparison operator.
Compares this IP address with another IP address to determine if it is less than or equal to the other.
[in] | rhs | The right-hand side ip_address object for comparison. |
|
inlinenoexcept |
Greater than or equal to comparison operator.
Compares this IP address with another IP address to determine if it is greater than or equal to the other.
[in] | rhs | The right-hand side ip_address object for comparison. |