VIPA 0.1.0
Header-only C++23 SIMD-assisted IPv4/IPv6 text parser.
Loading...
Searching...
No Matches
address.hxx
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cstdint>
5#include <span>
6#include <variant>
7
8namespace llmx::vipa {
9
11enum class AddressFamily : uint8_t { IPv4, IPv6 };
12
17 std::array<uint8_t, 4> bytes{};
18
20 constexpr auto octets() const noexcept -> std::span<const uint8_t, 4> {
21 return std::span<const uint8_t, 4>{bytes};
22 }
23};
24
29 std::array<uint8_t, 16> bytes{};
30
32 constexpr auto octets() const noexcept -> std::span<const uint8_t, 16> {
33 return std::span<const uint8_t, 16>{bytes};
34 }
35};
36
38using Address = std::variant<IPv4Address, IPv6Address>;
39
47
48} // namespace llmx::vipa
Definition address.hxx:8
std::variant< IPv4Address, IPv6Address > Address
Parsed IPv4 or IPv6 address value.
Definition address.hxx:38
AddressFamily
Parsed IP address family.
Definition address.hxx:11
@ IPv4
Definition address.hxx:11
@ IPv6
Definition address.hxx:11
Parsed IPv4 address in network byte order.
Definition address.hxx:14
std::array< uint8_t, 4 > bytes
Definition address.hxx:17
constexpr auto octets() const noexcept -> std::span< const uint8_t, 4 >
View the address as four read-only octets.
Definition address.hxx:20
Parsed IPv6 address in network byte order.
Definition address.hxx:26
std::array< uint8_t, 16 > bytes
Definition address.hxx:29
constexpr auto octets() const noexcept -> std::span< const uint8_t, 16 >
View the address as sixteen read-only octets.
Definition address.hxx:32
Address parser result with the concrete address family.
Definition address.hxx:41
Address address
Definition address.hxx:43
AddressFamily family
Definition address.hxx:45