SPARK  0.1.0
A general purpose game engine written in C++.
Loading...
Searching...
No Matches
spark::lib::Uuid Class Referencefinal

A 128-bit universally unique identifier (UUID). More...

#include <Uuid.h>

Public Member Functions

 Uuid ()
 Instantiates a new random uuid.
 
 Uuid (__m128i uuid)
 Instantiates a new uuid from a 128-bit number.
 
 Uuid (const uint8_t *bytes)
 Instantiates a new uuid from a byte string.
 
 Uuid (const std::string &bytes)
 Instantiates a new uuid from a byte string.
 
 Uuid (const Uuid &other)
 
 Uuid (Uuid &&other) noexcept
 
Uuidoperator= (const Uuid &other)
 
Uuidoperator= (Uuid &&other) noexcept
 
bool operator== (const Uuid &other) const
 
bool operator!= (const Uuid &other) const
 
std::string bytes () const
 Serializes the uuid to a byte std::string (16 bytes).
 
std::string str () const
 Converts the uuid to its string representation.
 
void str (char *res) const
 Converts the uuid to its string representation.
 

Friends

std::ostream & operator<< (std::ostream &os, const Uuid &uuid)
 
std::size_t hash_value (const Uuid &obj)
 Hashes the uuid.
 

Detailed Description

A 128-bit universally unique identifier (UUID).

Uses Uses SIMD (Single Instruction Multiple Data) with Intel's AVX2 instruction set to generate UUIDs. UUIDs are stored as a 16-byte array, representing a 128-bit number in memory.

See: https://www.rfc-editor.org/rfc/rfc4122

Constructor & Destructor Documentation

◆ Uuid() [1/3]

spark::lib::Uuid::Uuid ( __m128i uuid)
explicit

Instantiates a new uuid from a 128-bit number.

Parameters
uuidThe 128-bit number to use as uuid.

◆ Uuid() [2/3]

spark::lib::Uuid::Uuid ( const uint8_t * bytes)
explicit

Instantiates a new uuid from a byte string.

Parameters
bytesA raw array of bytes (size 16) containing the uuid.

◆ Uuid() [3/3]

spark::lib::Uuid::Uuid ( const std::string & bytes)
explicit

Instantiates a new uuid from a byte string.

Parameters
bytesA std::string containing the uuid.

Member Function Documentation

◆ bytes()

std::string spark::lib::Uuid::bytes ( ) const
nodiscard

Serializes the uuid to a byte std::string (16 bytes).

Returns
The std::string containing the 16 bytes of the uuid.

◆ str() [1/2]

std::string spark::lib::Uuid::str ( ) const
nodiscard

Converts the uuid to its string representation.

Returns
The std::string representation of the uuid.

◆ str() [2/2]

void spark::lib::Uuid::str ( char * res) const

Converts the uuid to its string representation.

Parameters
resA char array of size 36 to store the result in.

Friends And Related Symbol Documentation

◆ hash_value

std::size_t hash_value ( const Uuid & obj)
friend

Hashes the uuid.

Parameters
objThe uuid to hash.
Returns
The hashed representation of the uuid.