An IPv6 address used as a URL's host, e.g. "2001:db8::1". More...
#include <urlparser.h>
Collaboration diagram for urlparser::ipv6:Public Member Functions | |
| ipv6 () noexcept=default | |
| Default-constructs "::" (all zero). | |
| ipv6 (std::string_view text) | |
| Parse an IPv6 address from text. Accepts a bracketed literal ("[::1]", as it appears in a URL's host component) or a bare one ("::1"). | |
| std::array< uint8_t, 16 > | bytes () const noexcept |
| The address as 16 bytes, most significant first. | |
| uint64_t | high64 () const noexcept |
| The high 64 bits (first 8 bytes). | |
| uint64_t | low64 () const noexcept |
| The low 64 bits (last 8 bytes). | |
| ipv6 & | operator++ () noexcept |
| ipv6 | operator++ (int) noexcept |
| ipv6 & | operator+= (int64_t delta) noexcept |
Steps the address by delta, wrapping around mod 2^128. | |
| ipv6 & | operator-- () noexcept |
| ipv6 | operator-- (int) noexcept |
| ipv6 & | operator-= (int64_t delta) noexcept |
| std::string | str () const |
| Canonical (RFC 5952) text form, no brackets: "2001:db8::1", not "[2001:db8::1]". | |
Static Public Member Functions | |
| static ipv6 | from_uint64_pair (uint64_t high, uint64_t low) noexcept |
| Constructs from the two 64-bit halves (high64, then low64), in host byte order. | |
| static ipv6 | from_url (std::string_view url) |
| Extract the host from a URL and parse it as an IPv6 address. | |
| static bool | is_valid (std::string_view text) noexcept |
| Checks validity (bracketed or bare) without throwing or constructing. | |
Friends | |
| bool | operator!= (const ipv6 &a, const ipv6 &b) noexcept |
| ipv6 | operator+ (ipv6 lhs, int64_t delta) noexcept |
| ipv6 | operator- (ipv6 lhs, int64_t delta) noexcept |
| bool | operator< (const ipv6 &a, const ipv6 &b) noexcept |
| bool | operator<= (const ipv6 &a, const ipv6 &b) noexcept |
| bool | operator== (const ipv6 &a, const ipv6 &b) noexcept |
| bool | operator> (const ipv6 &a, const ipv6 &b) noexcept |
| bool | operator>= (const ipv6 &a, const ipv6 &b) noexcept |
An IPv6 address used as a URL's host, e.g. "2001:db8::1".
A plain 128-bit value type, stored as two 64-bit halves (high64()/ low64()) since C++ has no portable 128-bit integer - arithmetic is two native 64-bit add-with-carry operations, not a byte-array loop.
Parsing/formatting use the platform's own inet_pton/inet_ntop (POSIX) or InetPtonA/InetNtopA (Windows): IPv6's text format (:: compression, embedded IPv4 tails, zone IDs on some platforms) has enough edge cases that a hand-written parser is far more likely to introduce bugs than to avoid them.
|
defaultnoexcept |
Default-constructs "::" (all zero).
| urlparser::ipv6::ipv6 | ( | std::string_view | text | ) |
Parse an IPv6 address from text. Accepts a bracketed literal ("[::1]", as it appears in a URL's host component) or a bare one ("::1").
| std::invalid_argument | if text isn't a valid IPv6 address. |
|
noexcept |
The address as 16 bytes, most significant first.
|
staticnoexcept |
Constructs from the two 64-bit halves (high64, then low64), in host byte order.
|
static |
Extract the host from a URL and parse it as an IPv6 address.
| std::invalid_argument | if the URL's host isn't a valid IPv6 address. |
|
inlinenoexcept |
The high 64 bits (first 8 bytes).
|
staticnoexcept |
Checks validity (bracketed or bare) without throwing or constructing.
|
inlinenoexcept |
The low 64 bits (last 8 bytes).
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
Steps the address by delta, wrapping around mod 2^128.
|
inlinenoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
| std::string urlparser::ipv6::str | ( | ) | const |
Canonical (RFC 5952) text form, no brackets: "2001:db8::1", not "[2001:db8::1]".