Ada 3.4.0
Fast spec-compliant URL parser
Loading...
Searching...
No Matches
ada::serializers Namespace Reference

IP address serialization functions. More...

Functions

void find_longest_sequence_of_ipv6_pieces (const std::array< uint16_t, 8 > &address, size_t &compress, size_t &compress_length) noexcept
 
std::string ipv6 (const std::array< uint16_t, 8 > &address) noexcept
 
std::string ipv4 (uint64_t address) noexcept
 

Detailed Description

IP address serialization functions.

Contains utilities for serializing IPv4 and IPv6 addresses to strings.

Function Documentation

◆ find_longest_sequence_of_ipv6_pieces()

void ada::serializers::find_longest_sequence_of_ipv6_pieces ( const std::array< uint16_t, 8 > & address,
size_t & compress,
size_t & compress_length )
noexcept

Finds the longest consecutive sequence of zero pieces in an IPv6 address. Used for :: compression in IPv6 serialization.

Parameters
addressThe 8 16-bit pieces of the IPv6 address.
[out]compressIndex of the start of the longest zero sequence.
[out]compress_lengthLength of the longest zero sequence.

Definition at line 7 of file serializers.cpp.

Referenced by ipv6().

◆ ipv4()

std::string ada::serializers::ipv4 ( uint64_t address)
noexcept

Serializes an IPv4 address to its dotted-decimal string representation.

Parameters
addressThe 32-bit IPv4 address as an integer.
Returns
The serialized IPv4 string (e.g., "192.168.1.1").
See also
https://url.spec.whatwg.org/#concept-ipv4-serializer

Definition at line 66 of file serializers.cpp.

◆ ipv6()

std::string ada::serializers::ipv6 ( const std::array< uint16_t, 8 > & address)
noexcept

Serializes an IPv6 address to its string representation.

Parameters
addressThe 8 16-bit pieces of the IPv6 address.
Returns
The serialized IPv6 string (e.g., "2001:db8::1").
See also
https://url.spec.whatwg.org/#concept-ipv6-serializer

Definition at line 25 of file serializers.cpp.

References find_longest_sequence_of_ipv6_pieces().