Hide menu
Loading...
Searching...
No Matches

Defines a Universally Unique IDentifier (UUID), also known as GUIDs (Globally Unique IDentifier). More...

#include <cadex/Uuid.hxx>

Public Types

typedef uint8_t ValueType
 
typedef std::array< ValueType, 16 > DataType
 

Public Member Functions

 Uuid ()
 Creates the null UUID.
 
 Uuid (const ValueType *theData)
 Creates a UUID with the values specified by the parameter.
 
 Uuid (DataType theData)
 
const DataType & Data () const
 
bool IsNull () const
 Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false.
 
 operator bool () const
 
std::string ToString () const
 Returns the string representation of this UUID.
 

Static Public Member Functions

static Uuid FromString (const std::string &theStr)
 Creates a UUID object from a string.
 
static Uuid CreateRandom ()
 Creates new random uuid.
 

Detailed Description

Defines a Universally Unique IDentifier (UUID), also known as GUIDs (Globally Unique IDentifier).

A UUID is a 16-byte (128-bit) number, that is unique in the computer system (guaranteed by generated algorithm ).

Constructor & Destructor Documentation

◆ Uuid() [1/2]

cadex::Uuid::Uuid ( )

Creates the null UUID.

◆ Uuid() [2/2]

cadex::Uuid::Uuid ( const ValueType * theData)
explicit

Creates a UUID with the values specified by the parameter.

The function assumes theData contains 16 bytes and initializes the object with the values of these 16 bytes.

Member Function Documentation

◆ CreateRandom()

Uuid cadex::Uuid::CreateRandom ( )
static

Creates new random uuid.

This method is thread-safe and uses mutex to syncrhonize access to random number generator.

◆ FromString()

Uuid cadex::Uuid::FromString ( const std::string & theStr)
static

Creates a UUID object from a string.

String must be formatted as five hex fields separated by '-', e.g., "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" where each 'x' is a hexidecimal digit. The curly braces shown here are optional. If the conversion fails, a null UUID is returned.

◆ IsNull()

bool cadex::Uuid::IsNull ( ) const

Returns true if this is the null UUID {00000000-0000-0000-0000-000000000000}; otherwise returns false.

◆ ToString()

std::string cadex::Uuid::ToString ( ) const

Returns the string representation of this UUID.

The string representation of a uuid is "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" where 'x' is a hexidecimal digit.