C++ Essence Library 0.1.0
A Utility Library for Modern C++ Programming
Loading...
Searching...
No Matches
essence::net::ipv6_address Class Reference

Represents an IPv6 address. More...

#include <ipv6_address.hpp>

Public Types

using value_type = std::array<std::uint8_t, value_size>
 
using zone_id_type = std::array<char, max_zone_id_size>
 

Public Member Functions

constexpr ipv6_address () noexcept
 Creates an instance.
 
constexpr ipv6_address (std::initializer_list< std::uint8_t > address, std::string_view zone_id="") noexcept
 Creates an instance from an initializer list.
 
constexpr ipv6_address (std::span< const std::uint8_t, value_size > address, std::string_view zone_id="") noexcept
 Creates an instance from a 16-byte array.
 
constexpr auto operator<=> (const ipv6_address &) const noexcept=default
 
constexpr value_type & get () noexcept
 Gets the underlying array.
 
constexpr const value_type & get () const noexcept
 Gets the underlying array.
 
constexpr const char * zone_id () const noexcept
 Gets the zone ID.
 
constexpr void set_zone_id (std::string_view zone_id) noexcept
 Sets the zone ID.
 

Static Public Attributes

static constexpr std::size_t value_size = 16
 
static constexpr std::size_t value_group_count = value_size / 2
 
static constexpr std::size_t max_zone_id_size = 16
 On linux systems, the length of a stringified zone ID must be not longer than 16 bytes including the null-terminating character. On Windows, the zone ID must be a decimal natural number.
 

Detailed Description

Represents an IPv6 address.

Constructor & Destructor Documentation

◆ ipv6_address() [1/2]

essence::net::ipv6_address::ipv6_address ( std::initializer_list< std::uint8_t > address,
std::string_view zone_id = "" )
inlineconstexprnoexcept

Creates an instance from an initializer list.

Parameters
addressThe IPv6 address.
zone_idThe zone ID of the scoped address.

◆ ipv6_address() [2/2]

essence::net::ipv6_address::ipv6_address ( std::span< const std::uint8_t, value_size > address,
std::string_view zone_id = "" )
inlineexplicitconstexprnoexcept

Creates an instance from a 16-byte array.

Parameters
addressThe IPv6 address.
zone_idThe zone ID of the scoped address.

Member Function Documentation

◆ get() [1/2]

const value_type & essence::net::ipv6_address::get ( ) const
inlinenodiscardconstexprnoexcept

Gets the underlying array.

Returns
The underlying array.

◆ get() [2/2]

value_type & essence::net::ipv6_address::get ( )
inlinenodiscardconstexprnoexcept

Gets the underlying array.

Returns
The underlying array.

◆ set_zone_id()

void essence::net::ipv6_address::set_zone_id ( std::string_view zone_id)
inlineconstexprnoexcept

Sets the zone ID.

Parameters
zone_idThe zone ID.

◆ zone_id()

const char * essence::net::ipv6_address::zone_id ( ) const
inlinenodiscardconstexprnoexcept

Gets the zone ID.

Returns
The zone ID.

Member Data Documentation

◆ max_zone_id_size

std::size_t essence::net::ipv6_address::max_zone_id_size = 16
staticconstexpr

On linux systems, the length of a stringified zone ID must be not longer than 16 bytes including the null-terminating character. On Windows, the zone ID must be a decimal natural number.

See also
https://elixir.bootlin.com/linux/v5.6/source/include/uapi/linux/if.h#L33

The documentation for this class was generated from the following file: