Helios Engine
A modular ECS based data-oriented C++23 game engine framework
Loading...
Searching...
No Matches

A class representing a universally unique identifier (UUID). More...

#include <uuid.hpp>

Public Member Functions

constexpr Uuid () noexcept=default
 Default constructor creates an invalid UUID (all zeros).
constexpr Uuid (std::span< uint8_t, 16 > bytes)
 Construct a UUID from a span of bytes.
constexpr Uuid (std::span< const std::byte, 16 > bytes)
 Construct a UUID from a span of bytes.
constexpr Uuid (std::string_view str)
 Construct a UUID from a string representation.
constexpr Uuid (const Uuid &other) noexcept=default
constexpr Uuid (Uuid &&other) noexcept=default
constexpr ~Uuid () noexcept=default
constexpr Uuidoperator= (const Uuid &other) noexcept=default
constexpr Uuidoperator= (Uuid &&other) noexcept=default
std::string ToString () const
 Convert the UUID to its string representation.
auto AsBytes () const noexcept -> std::span< const std::byte, 16 >
 Get the UUID as a span of bytes.
constexpr bool operator== (const Uuid &other) const noexcept=default
constexpr bool operator!= (const Uuid &other) const noexcept=default
constexpr bool operator< (const Uuid &other) const noexcept
constexpr bool Valid () const noexcept
 Check if the UUID is valid (not all zeros).
constexpr size_t Hash () const noexcept
 Compute a hash value for the UUID.

Static Public Member Functions

static constexpr Uuid Generate ()
 Generate a new random UUID.

Friends

class UuidGenerator
constexpr void swap (Uuid &lhs, Uuid &rhs)
 Swap two UUIDs.

Detailed Description

A class representing a universally unique identifier (UUID).

Definition at line 16 of file uuid.hpp.

Constructor & Destructor Documentation

◆ Uuid() [1/6]

helios::Uuid::Uuid ( )
constexprdefaultnoexcept

Default constructor creates an invalid UUID (all zeros).

◆ Uuid() [2/6]

helios::Uuid::Uuid ( std::span< uint8_t, 16 > bytes)
inlineexplicitconstexpr

Construct a UUID from a span of bytes.

The span must be exactly 16 bytes long; otherwise, the resulting UUID will be invalid.

Parameters
bytesA span of bytes representing the UUID

Definition at line 27 of file uuid.hpp.

◆ Uuid() [3/6]

helios::Uuid::Uuid ( std::span< const std::byte, 16 > bytes)
explicitconstexpr

Construct a UUID from a span of bytes.

The span must be exactly 16 bytes long; otherwise, the resulting UUID will be invalid.

Parameters
bytesA span of bytes representing the UUID

Definition at line 112 of file uuid.hpp.

◆ Uuid() [4/6]

helios::Uuid::Uuid ( std::string_view str)
explicitconstexpr

Construct a UUID from a string representation.

If the string is not a valid UUID, the resulting UUID will be invalid.

Parameters
strThe string representation of the UUID

Definition at line 120 of file uuid.hpp.

◆ Uuid() [5/6]

helios::Uuid::Uuid ( const Uuid & other)
constexprdefaultnoexcept

◆ Uuid() [6/6]

helios::Uuid::Uuid ( Uuid && other)
constexprdefaultnoexcept

◆ ~Uuid()

helios::Uuid::~Uuid ( )
constexprdefaultnoexcept

Member Function Documentation

◆ AsBytes()

auto helios::Uuid::AsBytes ( ) const -> std::span< const std::byte, 16 >
inlinenodiscardnoexcept

Get the UUID as a span of bytes.

Returns
A span of bytes representing the UUID, or an empty span if the UUID is invalid

Definition at line 159 of file uuid.hpp.

◆ Generate()

Uuid helios::Uuid::Generate ( )
staticnodiscardconstexpr

Generate a new random UUID.

Uses a thread_local generator for thread-safety without locks. Each thread maintains its own generator state for optimal performance.

Returns
A new random UUID

Definition at line 131 of file uuid.hpp.

◆ Hash()

size_t helios::Uuid::Hash ( ) const
inlinenodiscardconstexprnoexcept

Compute a hash value for the UUID.

Returns
A hash value for the UUID

Definition at line 95 of file uuid.hpp.

◆ operator!=()

bool helios::Uuid::operator!= ( const Uuid & other) const
nodiscardconstexprdefaultnoexcept

◆ operator<()

bool helios::Uuid::operator< ( const Uuid & other) const
inlinenodiscardconstexprnoexcept

Definition at line 79 of file uuid.hpp.

◆ operator=() [1/2]

Uuid & helios::Uuid::operator= ( const Uuid & other)
constexprdefaultnoexcept

◆ operator=() [2/2]

Uuid & helios::Uuid::operator= ( Uuid && other)
constexprdefaultnoexcept

◆ operator==()

bool helios::Uuid::operator== ( const Uuid & other) const
nodiscardconstexprdefaultnoexcept

◆ ToString()

std::string helios::Uuid::ToString ( ) const
inlinenodiscard

Convert the UUID to its string representation.

Returns
The string representation of the UUID, or an empty string if the UUID is invalid

Definition at line 152 of file uuid.hpp.

◆ Valid()

bool helios::Uuid::Valid ( ) const
inlinenodiscardconstexprnoexcept

Check if the UUID is valid (not all zeros).

Returns
True if the UUID is valid, false otherwise

Definition at line 87 of file uuid.hpp.

◆ swap

void swap ( Uuid & lhs,
Uuid & rhs )
friend

Swap two UUIDs.

Parameters
lhsThe first UUID
rhsThe second UUID

Definition at line 163 of file uuid.hpp.

◆ UuidGenerator

friend class UuidGenerator
friend

Definition at line 109 of file uuid.hpp.