CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
CeresEngine::UUID Struct Reference

Represents a universally unique identifier (UUID). More...

#include <CeresEngine/Foundation/UUID.hpp>

Inheritance diagram for CeresEngine::UUID:
CeresEngine::PackageID CeresEngine::ResourceID CeresEngine::ResourceStreamID

Public Member Functions

constexpr UUID ()=default
 Initializes an empty UUID.
 
constexpr UUID (const UInt32 data1, const UInt32 data2, const UInt32 data3, const UInt32 data4)
 Initializes an UUID using framework's UUID representation.
 
 UUID (StringView uuid)
 Initializes an UUID using its string representation.
 
 UUID (const char *uuid)
 Initializes an UUID using its string representation.
 
constexpr bool empty () const
 Checks has the UUID been initialized to a valid value.
 
String toString () const
 Converts the UUID into its string representation.
 
void toString (String &str) const
 Converts the UUID into its string representation.
 
void copyTo (Byte *buffer) const
 Copies the UUID into a buffer.
 
void copyFrom (const Byte *buffer)
 Copies the UUID from a buffer.
 

Static Public Member Functions

static UUID random ()
 Generate a new random universally unique identifier.
 
static UUID withNamespace (const UUID &ns, StringView name)
 Generate a new random universally unique identifier.
 
static UUID fromName (StringView name)
 Generate a new UUID based on a name.
 
template<typename Generator >
static UUID random (Generator generator)
 Generate a new random universally unique identifier.
 

Public Attributes

UInt32 raw [4] = {0, 0, 0, 0}
 The UUID raw representation.
 

Friends

constexpr bool operator== (const UUID &lhs, const UUID &rhs) noexcept
 Compares two UUID objects for equality.
 
constexpr bool operator!= (const UUID &lhs, const UUID &rhs) noexcept
 Compares two UUID objects for inequality.
 
constexpr bool operator< (const UUID &lhs, const UUID &rhs) noexcept
 Compares two UUID objects for ordering.
 
constexpr bool operator> (const UUID &lhs, const UUID &rhs) noexcept
 Compares two UUID objects for ordering.
 
constexpr bool operator<= (const UUID &lhs, const UUID &rhs) noexcept
 Compares two UUID objects for ordering.
 
constexpr bool operator>= (const UUID &lhs, const UUID &rhs) noexcept
 Compares two UUID objects for ordering.
 
String toString (const UUID &uuid)
 Converts the UUID into its string representation.
 
std::ostream & operator<< (std::ostream &os, const UUID &uuid)
 Prints a string representation of a UUID into a standard output stream.
 

Detailed Description

Represents a universally unique identifier (UUID).

A UUID is a 128-bit value that is unique across all devices and time.

Constructor & Destructor Documentation

◆ UUID() [1/4]

constexpr CeresEngine::UUID::UUID ( )
constexprdefault

Initializes an empty UUID.

◆ UUID() [2/4]

constexpr CeresEngine::UUID::UUID ( const UInt32  data1,
const UInt32  data2,
const UInt32  data3,
const UInt32  data4 
)
inlineconstexpr

Initializes an UUID using framework's UUID representation.

◆ UUID() [3/4]

CeresEngine::UUID::UUID ( StringView  uuid)
explicit

Initializes an UUID using its string representation.

◆ UUID() [4/4]

CeresEngine::UUID::UUID ( const char uuid)
inlineexplicit

Initializes an UUID using its string representation.

Member Function Documentation

◆ copyFrom()

void CeresEngine::UUID::copyFrom ( const Byte buffer)
inline

Copies the UUID from a buffer.

Parameters
bufferThe buffer to copy from

◆ copyTo()

void CeresEngine::UUID::copyTo ( Byte buffer) const
inline

Copies the UUID into a buffer.

Parameters
bufferThe buffer to copy to

◆ empty()

constexpr bool CeresEngine::UUID::empty ( ) const
inlineconstexpr

Checks has the UUID been initialized to a valid value.

Returns
true if the UUID is empty (not initialized)

◆ fromName()

static UUID CeresEngine::UUID::fromName ( StringView  name)
static

Generate a new UUID based on a name.

Given the same name, the same UUID will always be generated.

Returns
The generated UUID.

◆ random() [1/2]

static UUID CeresEngine::UUID::random ( )
static

Generate a new random universally unique identifier.

Returns
A randomly generated UUID.

◆ random() [2/2]

template<typename Generator >
static UUID CeresEngine::UUID::random ( Generator  generator)
inlinestatic

Generate a new random universally unique identifier.

Template Parameters
Generatorthe generator type
Parameters
generatorThe random number generator
Returns
A randomly generated UUID.

◆ toString() [1/2]

String CeresEngine::UUID::toString ( ) const

Converts the UUID into its string representation.

Returns
a string representation the UUID

◆ toString() [2/2]

void CeresEngine::UUID::toString ( String str) const

Converts the UUID into its string representation.

Parameters
strThe string to output the representation to

◆ withNamespace()

static UUID CeresEngine::UUID::withNamespace ( const UUID ns,
StringView  name 
)
static

Generate a new random universally unique identifier.

Returns
A randomly generated UUID.

Friends And Related Symbol Documentation

◆ operator!=

constexpr bool operator!= ( const UUID lhs,
const UUID rhs 
)
friend

Compares two UUID objects for inequality.

Parameters
lhsThe left hand-side argument
rhsThe right hand-side argument
Returns
true if both UUIDs are not equal

◆ operator<

constexpr bool operator< ( const UUID lhs,
const UUID rhs 
)
friend

Compares two UUID objects for ordering.

Parameters
lhsThe left hand-side argument
rhsThe right hand-side argument
Returns
true if a is considered to come before b.

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const UUID uuid 
)
friend

Prints a string representation of a UUID into a standard output stream.

Parameters
osThe output stream
uuidThe uuid
Returns
The given os

◆ operator<=

constexpr bool operator<= ( const UUID lhs,
const UUID rhs 
)
friend

Compares two UUID objects for ordering.

Parameters
lhsThe left hand-side argument
rhsThe right hand-side argument
Returns
true if a is considered to come before or is equal to b.

◆ operator==

constexpr bool operator== ( const UUID lhs,
const UUID rhs 
)
friend

Compares two UUID objects for equality.

Parameters
lhsThe left hand-side argument
rhsThe right hand-side argument
Returns
true if both UUIDs are equal

◆ operator>

constexpr bool operator> ( const UUID lhs,
const UUID rhs 
)
friend

Compares two UUID objects for ordering.

Parameters
lhsThe left hand-side argument
rhsThe right hand-side argument
Returns
true if a is considered to come after b.

◆ operator>=

constexpr bool operator>= ( const UUID lhs,
const UUID rhs 
)
friend

Compares two UUID objects for ordering.

Parameters
lhsThe left hand-side argument
rhsThe right hand-side argument
Returns
true if a is considered to come after or is equal to b.

◆ toString

String toString ( const UUID uuid)
friend

Converts the UUID into its string representation.

Returns
a string representation the UUID

Member Data Documentation

◆ raw

UInt32 CeresEngine::UUID::raw[4] = {0, 0, 0, 0}

The UUID raw representation.


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