ipaddress 1.1.0
|
Namespace dedicated to IP addresses and networks operations. More...
Classes | |
class | base_v4 |
A template class providing the base functionality for IPv4 addresses. More... | |
class | base_v6 |
A template class providing the base functionality for IPv6 addresses. More... | |
struct | byte_array |
A template class for creating and managing a fixed-size array of bytes. More... | |
class | error |
The primary exception class used by the IP address library. More... | |
class | exclude_network_sequence |
A sequence container for networks excluding specified subnets. More... | |
struct | fixed_string |
Fixed size string class. More... | |
class | hosts_any_sequence |
A sequence of host IP addresses. More... | |
class | hosts_sequence< ip_address_base< Base > > |
A sequence of host IP addresses. More... | |
class | ip_address |
A class that represents an IP address, supporting both IPv4 and IPv6 formats. More... | |
class | ip_address_base |
A template base class for IP address representations. More... | |
class | ip_address_iterator< ip_address_base< Base > > |
An iterator for traversing IP addresses. More... | |
class | ip_any_iterator |
An iterator for unified traversal over IPv4 and IPv6 address spaces. More... | |
class | ip_exclude_network_iterator |
An iterator to traverse IP addresses within a network, excluding specified subnets. More... | |
class | ip_network |
A class that encapsulates both IPv4 and IPv6 network functionalities. More... | |
class | ip_network_base |
Template base class for representing a network of IP addresses. More... | |
class | ip_network_iterator |
An iterator for traversing IP addresses within a network range. More... | |
class | ip_reverse_iterator |
A reverse iterator template class for IP addresses. More... | |
class | ipv4_address_base |
Represents the base class for IPv4 address manipulation. More... | |
class | ipv4_network_base |
Base class for IPv4 network address manipulation. More... | |
class | ipv6_address_base |
Represents the base class for IPv6 address manipulation. More... | |
class | ipv6_network_base |
Base class for IPv6 network address manipulation. More... | |
class | logic_error |
Exception for logical errors in IP address operations. More... | |
class | optional |
A template class to manage an optional contained value. More... | |
class | parse_error |
Exception for errors encountered during IP address parsing. More... | |
class | scope |
Represents the scope identifier for an IPv6 address. More... | |
class | subnets_any_sequence |
A sequence container for subnet ranges within a network. More... | |
class | subnets_sequence |
A sequence container for subnet ranges within a network. More... | |
class | uint128_t |
Class for representing a 128-bit unsigned integer. More... | |
Typedefs | |
using | ipv4_address = ip_address_base<ipv4_address_base> |
Alias for the base class specialized for IPv4 address manipulation. | |
using | ipv4_network = ip_network_base<ipv4_network_base> |
Alias for the specialized ip_network_base class for IPv4. | |
using | ipv6_address = ip_address_base<ipv6_address_base> |
Alias for the base class specialized for IPv6 address manipulation. | |
using | ipv6_network = ip_network_base<ipv6_network_base> |
Alias for the specialized ip_network_base class for IPv6. | |
Functions | |
template<size_t N> | |
constexpr inline bool | operator== (const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept |
Checks if two byte_array objects are equal. | |
template<size_t N> | |
constexpr inline bool | operator!= (const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept |
Checks if two byte_array objects are not equal. | |
template<size_t N> | |
constexpr inline bool | operator< (const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept |
Determines if one byte_array is less than another. | |
template<size_t N> | |
constexpr inline bool | operator> (const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept |
Determines if one byte_array is greater than another. | |
template<size_t N> | |
constexpr inline bool | operator<= (const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept |
Determines if one byte_array is less than or equal to another. | |
template<size_t N> | |
constexpr inline bool | operator>= (const byte_array< N > &lhs, const byte_array< N > &rhs) noexcept |
Determines if one byte_array is greater than or equal to another. | |
constexpr inline bool | is_little_endian () noexcept |
Checks if the system is little-endian. | |
constexpr inline uint32_t | swap_bytes (uint32_t value) noexcept |
Swaps the bytes of a 32-bit unsigned integer. | |
template<typename T > | |
constexpr inline void | raise_error (error_code code, uint32_t value, const T *address, size_t length) |
Raises an error with a specific error code and additional context. | |
template<size_t N1, size_t N2> | |
constexpr inline bool | operator== (const fixed_string< N1 > &lhs, const fixed_string< N2 > &rhs) noexcept |
Compares the contents of two fixed strings for equality. | |
template<size_t N1, size_t N2> | |
constexpr inline bool | operator!= (const fixed_string< N1 > &lhs, const fixed_string< N2 > &rhs) noexcept |
Compares the contents of two fixed strings for inequality. | |
template<size_t N1, size_t N2> | |
constexpr inline bool | operator< (const fixed_string< N1 > &lhs, const fixed_string< N2 > &rhs) noexcept |
Compares the contents of two fixed strings lexicographically. | |
template<size_t N1, size_t N2> | |
constexpr inline bool | operator> (const fixed_string< N1 > &lhs, const fixed_string< N2 > &rhs) noexcept |
Compares the contents of two fixed strings for greater than relation. | |
template<size_t N1, size_t N2> | |
constexpr inline bool | operator<= (const fixed_string< N1 > &lhs, const fixed_string< N2 > &rhs) noexcept |
Compares the contents of two fixed strings for less than or equal relation. | |
template<size_t N1, size_t N2> | |
constexpr inline bool | operator>= (const fixed_string< N1 > &lhs, const fixed_string< N2 > &rhs) noexcept |
Compares the contents of two fixed strings for greater than or equal relation. | |
template<typename T , size_t N> | |
constexpr inline fixed_string< N - 1 > | make_fixed_string (const T(&data)[N]) noexcept(noexcept(fixed_string< N - 1 >(data))) |
Creates a fixed-length string from a character array. | |
template<typename T , size_t N> | |
constexpr inline fixed_string< N - 1 > | make_fixed_string (const T(&data)[N], error_code &code) noexcept |
Creates a fixed-length string from a character array. | |
template<fixed_string FixedString> | |
consteval inline ip_address | operator""_ip () noexcept |
User-defined literal for creating an ip_address from a fixed string at compile time. | |
template<fixed_string FixedString> | |
consteval inline ip_network | operator""_net () noexcept |
User-defined literal operator for creating an ip_network object from a string literal. | |
template<fixed_string FixedString> | |
consteval inline ipv4_address | operator""_ipv4 () noexcept |
User-defined literal for creating an ipv4_address from a fixed string at compile time. | |
consteval inline ipv4_address | operator""_ipv4 (unsigned long long value) noexcept |
User-defined literal for creating an ipv4_address from an unsigned long long integer at compile time. | |
template<fixed_string FixedString> | |
consteval inline ipv4_network | operator""_ipv4_net () noexcept |
User-defined literal operator for creating an ipv4_network object from a string literal. | |
template<fixed_string FixedString> | |
consteval inline ipv6_address | operator""_ipv6 () noexcept |
User-defined literal for creating an ipv6_address from a fixed string at compile time. | |
template<fixed_string FixedString> | |
consteval inline ipv6_network | operator""_ipv6_net () noexcept |
User-defined literal operator for creating an ipv6_network object from a string literal. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator+ (T lower, const uint128_t &value) noexcept |
Performs addition between an integer and a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator- (T lower, const uint128_t &value) noexcept |
Performs subtraction of a uint128_t value from an integer. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator* (T lower, const uint128_t &value) noexcept |
Performs multiplication between an integer and a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator/ (T lower, const uint128_t &value) noexcept |
Performs division of an integer by a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator% (T lower, const uint128_t &value) noexcept |
Calculates the remainder of division of an integer by a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator& (T lower, const uint128_t &value) noexcept |
Performs bitwise AND operation between an integer and a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator| (T lower, const uint128_t &value) noexcept |
Performs bitwise OR operation between an integer and a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_arithmetic<T>::value, T>::type> | |
constexpr inline uint128_t | operator^ (T lower, const uint128_t &value) noexcept |
Performs bitwise XOR operation between an integer and a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type> | |
constexpr inline bool | operator== (T lower, const uint128_t &other) noexcept |
Checks if an integer value is equal to a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type> | |
constexpr inline bool | operator!= (T lower, const uint128_t &other) noexcept |
Checks if an integer value is not equal to a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type> | |
constexpr inline bool | operator< (T lower, const uint128_t &other) noexcept |
Compares if an integer value is less than a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type> | |
constexpr inline bool | operator> (T lower, const uint128_t &other) noexcept |
Compares if an integer value is greater than a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type> | |
constexpr inline bool | operator<= (T lower, const uint128_t &other) noexcept |
Compares if an integer value is less than or equal to a uint128_t value. | |
template<typename T , typename = typename std::enable_if<std::is_integral<T>::value, T>::type> | |
constexpr inline bool | operator>= (T lower, const uint128_t &other) noexcept |
Compares if an integer value is greater than or equal to a uint128_t value. | |
Namespace dedicated to IP addresses and networks operations.
This namespace contains all the classes, functions, and utilities necessary for handling both IPv4 and IPv6 addresses and networks. It provides a comprehensive suite of tools for various operations such as parsing, constructing, and manipulating IP addresses and networks.
using ipv4_address = ip_address_base<ipv4_address_base> |
Alias for the base class specialized for IPv4 address manipulation.
This alias provides a convenient shorthand for the specialized ip_address_base
class tailored for IPv4 address handling. It inherits all functionalities from the ipv4_address_base
class, allowing for operations such as conversion, comparison, and property querying specific to IPv4 addresses.
using ipv4_network = ip_network_base<ipv4_network_base> |
Alias for the specialized ip_network_base class for IPv4.
The ipv4_network is a convenient alias for the ip_network_base class specialized with ipv4_network_base. It allows users to work with IPv4 network addresses using a type that is specifically designed for IPv4, simplifying the interface and usage in code that deals with IPv4 networks.
using ipv6_address = ip_address_base<ipv6_address_base> |
Alias for the base class specialized for IPv6 address manipulation.
This alias provides a convenient shorthand for the specialized ip_address_base
class tailored for IPv6 address handling. It inherits all functionalities from the ipv6_address_base
class, allowing for operations such as conversion, comparison, and property querying specific to IPv6 addresses.
using ipv6_network = ip_network_base<ipv6_network_base> |
Alias for the specialized ip_network_base class for IPv6.
The ipv6_network is a convenient alias for the ip_network_base class specialized with ipv6_network_base. It allows users to work with IPv6 network addresses using a type that is specifically designed for IPv6, simplifying the interface and usage in code that deals with IPv6 networks.
|
strong |
Enumeration of error codes for IP address parsing and validation.
This enumeration defines a set of error codes used to represent various error conditions that can occur during the parsing and validation of IP addresses. These error codes are used to provide detailed feedback about the nature of the error encountered, allowing for more precise error handling and troubleshooting.
The error codes are divided into several categories:
Each error code is accompanied by a brief comment explaining the specific error condition it represents.
|
strong |
|
strong |
Enumerates the formatting options for IP address strings.
Defines the formatting styles that can be applied when converting IP addresses to strings, such as full, compact, or compressed representations.
Enumerator | |
---|---|
full | Full format with no compression or omission. |
compact | Compact format with possible omission of leading zeros. |
compressed | Compressed format with maximal omission of segments or octets. |
|
noexcept |
Checks if two byte_array objects are equal.
Compares two byte_array objects of the same size element-wise to determine if they are equal.
N | The size of the byte array. |
[in] | lhs | A reference to the left-hand side byte_array object. |
[in] | rhs | A reference to the right-hand side byte_array object. |
true | the two byte_array objects are equal |
false | the two byte_array objects are not equal |
|
noexcept |
Checks if two byte_array objects are not equal.
Compares two byte_array objects of the same size element-wise to determine if they are not equal.
N | The size of the byte array. |
[in] | lhs | A reference to the left-hand side byte_array object. |
[in] | rhs | A reference to the right-hand side byte_array object. |
true | the two byte_array objects are not equal |
false | the two byte_array objects are equal |
|
noexcept |
Determines if one byte_array is less than another.
Performs a lexicographical comparison of two byte_array objects. The comparison is done element-wise and stops at the first unequal pair where the left-hand side is less than the right-hand side.
N | The size of the byte arrays. |
[in] | lhs | A reference to the left-hand side byte_array object. |
[in] | rhs | A reference to the right-hand side byte_array object. |
true
if lhs is lexicographically less than rhs, false
otherwise.
|
noexcept |
Determines if one byte_array is greater than another.
N | The size of the byte arrays. |
[in] | lhs | A reference to the left-hand side byte_array object. |
[in] | rhs | A reference to the right-hand side byte_array object. |
true
if lhs is lexicographically greater than rhs, false
otherwise.
|
noexcept |
Determines if one byte_array is less than or equal to another.
N | The size of the byte arrays. |
[in] | lhs | A reference to the left-hand side byte_array object. |
[in] | rhs | A reference to the right-hand side byte_array object. |
true
if lhs is lexicographically less than or equal to rhs, false
otherwise.
|
noexcept |
Determines if one byte_array is greater than or equal to another.
N | The size of the byte arrays. |
[in] | lhs | A reference to the left-hand side byte_array object. |
[in] | rhs | A reference to the right-hand side byte_array object. |
true
if lhs is lexicographically greater than or equal to rhs, false
otherwise.
|
noexcept |
Checks if the system is little-endian.
true
if the system is little-endian, false
otherwise.
|
noexcept |
Swaps the bytes of a 32-bit unsigned integer.
[in] | value | The integer value to swap bytes of. |
constexpr inline void raise_error | ( | error_code | code, |
uint32_t | value, | ||
const T * | address, | ||
size_t | length ) |
Raises an error with a specific error code and additional context.
This function constructs an error message based on the provided error code, value, and address, then throws a parse_error or a logic_error exception with the constructed message.
T | The character type of the address string. |
[in] | code | The error code indicating the type of error encountered. |
[in] | value | The value at which the error occurred, if applicable. |
[in] | address | A pointer to the beginning of the address string. |
[in] | length | The length of the address string. |
parse_error | Thrown with a message corresponding to the error code. |
logic_error | Thrown with a message corresponding to the error code. |
|
noexcept |
Compares the contents of two fixed strings for equality.
Checks if the contents of lhs and rhs are equal, meaning they have the same number of elements and each element in lhs compares equal with the element in rhs at the same position.
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
[in] | lhs | The fixed string whose contents to compare. |
[in] | rhs | The fixed string whose contents to compare. |
true
if the contents of the strings are equal, false
otherwise.
|
noexcept |
Compares the contents of two fixed strings for inequality.
Checks if the contents of lhs and rhs are not equal, meaning they do not have the same number of elements or there is at least one position at which the elements in lhs and rhs differ.
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
[in] | lhs | The fixed string whose contents to compare. |
[in] | rhs | The fixed string whose contents to compare. |
true
if the contents of the strings are not equal, false
otherwise.
|
noexcept |
Compares the contents of two fixed strings lexicographically.
Checks if the contents of lhs are lexicographically less than the contents of rhs.
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
[in] | lhs | The fixed string whose contents to compare. |
[in] | rhs | The fixed string whose contents to compare. |
true
if the contents of lhs are lexicographically less than the contents of rhs, false
otherwise.
|
noexcept |
Compares the contents of two fixed strings for greater than relation.
Determines if the contents of lhs are lexicographically greater than the contents of rhs.
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
[in] | lhs | The fixed string whose contents to compare. |
[in] | rhs | The fixed string whose contents to compare. |
true
if lhs is lexicographically greater than rhs, false
otherwise.
|
noexcept |
Compares the contents of two fixed strings for less than or equal relation.
Determines if the contents of lhs are lexicographically less than or equal to the contents of rhs.
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
[in] | lhs | The fixed string whose contents to compare. |
[in] | rhs | The fixed string whose contents to compare. |
true
if lhs is lexicographically less than or equal to rhs, false
otherwise.
|
noexcept |
Compares the contents of two fixed strings for greater than or equal relation.
Determines if the contents of lhs are lexicographically greater than or equal to the contents of rhs.
N1 | The maximum number of characters of lhs. |
N2 | The maximum number of characters of rhs. |
[in] | lhs | The fixed string whose contents to compare. |
[in] | rhs | The fixed string whose contents to compare. |
true
if lhs is lexicographically greater than or equal to rhs, false
otherwise.
|
noexcept |
Creates a fixed-length string from a character array.
Constructs a fixed_string object from a character array, deducing the size automatically.
T | The character type of the input array. |
N | The size of the character array plus one for the null terminator. |
[in] | data | The character array to initialize the fixed_string with. |
|
noexcept |
Creates a fixed-length string from a character array.
Constructs a fixed_string object from a character array, deducing the size automatically.
T | The character type of the input array. |
N | The size of the character array plus one for the null terminator. |
[in] | data | The character array to initialize the fixed_string with. |
[out] | code | A reference to an error_code object that will be set if an error occurs during parsing. |
|
noexcept |
User-defined literal for creating an ip_address from a fixed string at compile time.
FixedString | A compile-time fixed string representing the IPv6 address. |
|
noexcept |
User-defined literal operator for creating an ip_network object from a string literal.
This operator allows the creation of ip_network objects using a string literal with the _net
suffix.
FixedString | A string literal representing the IP network. |
|
noexcept |
User-defined literal for creating an ipv4_address from a fixed string at compile time.
FixedString | A compile-time fixed string representing the IPv4 address. |
|
noexcept |
User-defined literal for creating an ipv4_address from an unsigned long long integer at compile time.
[in] | value | An unsigned long long integer representing the IPv4 address in host byte order. |
|
noexcept |
User-defined literal operator for creating an ipv4_network object from a string literal.
This operator allows the creation of ipv4_network objects using a string literal with the _ipv4_net
suffix.
FixedString | A string literal representing the IPv4 network. |
|
noexcept |
User-defined literal for creating an ipv6_address from a fixed string at compile time.
FixedString | A compile-time fixed string representing the IPv6 address. |
|
noexcept |
User-defined literal operator for creating an ipv6_network object from a string literal.
This operator allows the creation of ipv6_network objects using a string literal with the _ipv6_net
suffix.
FixedString | A string literal representing the IPv6 network. |
|
noexcept |
|
noexcept |
|
noexcept |
Compares if an integer value is less than a uint128_t value.
This function template overloads the less than operator (<) to compare an integer of type T with a uint128_t value. It checks if the integer value is lexicographically less than the uint128_t value.
T | An integral type parameter that is checked at compile-time to ensure it is an integer type. |
[in] | lower | The integer value of type T to be compared. |
[in] | other | The uint128_t value to compare against. |
true
if lower is less than other, false
otherwise.
|
noexcept |
Compares if an integer value is greater than a uint128_t value.
This function template overloads the greater than operator (>) to compare an integer of type T with a uint128_t value. It checks if the integer value is lexicographically greater than the uint128_t value.
T | An integral type parameter that is checked at compile-time to ensure it is an integer type. |
[in] | lower | The integer value of type T to be compared. |
[in] | other | The uint128_t value to compare against. |
true
if lower is greater than other, false
otherwise.
|
noexcept |
Compares if an integer value is less than or equal to a uint128_t value.
This function template overloads the less than or equal to operator (<=) to compare an integer of type T with a uint128_t value. It checks if the integer value is lexicographically less than or equal to the uint128_t value.
T | An integral type parameter that is checked at compile-time to ensure it is an integer type. |
[in] | lower | The integer value of type T to be compared. |
[in] | other | The uint128_t value to compare against. |
true
if lower is less than or equal to other, false
otherwise.
|
noexcept |
Compares if an integer value is greater than or equal to a uint128_t value.
This function template overloads the greater than or equal to operator (>=) to compare an integer of type T with a uint128_t value. It checks if the integer value is lexicographically greater than or equal to the uint128_t value.
T | An integral type parameter that is checked at compile-time to ensure it is an integer type. |
[in] | lower | The integer value of type T to be compared. |
[in] | other | The uint128_t value to compare against. |
true
if lower is greater than or equal to other, false
otherwise.