smgl 0.11.0
Structured Metadata Engine and Graph Objects Library
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
smgl::Uuid Class Reference

Universally unique identifier class. More...

#include <smgl/Uuid.hpp>

Collaboration diagram for smgl::Uuid:
[legend]

Public Types

using Byte = std::uint8_t
 

Public Member Functions

 Uuid ()=default
 
 operator bool () const
 
auto operator== (const Uuid &rhs) const -> bool
 
auto operator!= (const Uuid &rhs) const -> bool
 
void reset ()
 Reset the UUID to a nil value.
 
auto is_nil () const -> bool
 Returns true is all bytes are zero.
 
auto string () const -> std::string
 Get a string representation of the UUID.
 
auto short_string () const -> std::string
 Get a string representation of the short UUID.
 

Static Public Member Functions

static auto FromString (const std::string &str) -> Uuid
 Construct a UUID from a string.
 
static auto Uuid4 () -> Uuid
 Generate a UUIDv4 using pseudo-random numbers.
 

Private Attributes

std::array< Byte, 16 > buffer_ {}
 

Detailed Description

Universally unique identifier class.

Attempts to implement the UUID defined by RFC 4122.

Definition at line 17 of file Uuid.hpp.

Member Typedef Documentation

◆ Byte

Byte type

Definition at line 21 of file Uuid.hpp.

Constructor & Destructor Documentation

◆ Uuid()

smgl::Uuid::Uuid ( )
default

Default constructor. Constructed UUID is nil valued.

Member Function Documentation

◆ FromString()

static auto smgl::Uuid::FromString ( const std::string str) -> Uuid
static

Construct a UUID from a string.

Exceptions
std::invalid_argumentif str is not of the form: aabbccdd-eeff-0011-2233-445566778899

◆ operator bool()

smgl::Uuid::operator bool ( ) const
explicit

Functor: Returns true if not nil

◆ operator!=()

auto smgl::Uuid::operator!= ( const Uuid rhs) const -> bool

Inequality: Returns true if UUID bytes are not the same

◆ operator==()

auto smgl::Uuid::operator== ( const Uuid rhs) const -> bool

Equality: Returns true if UUID bytes are the same

◆ short_string()

auto smgl::Uuid::short_string ( ) const -> std::string

Get a string representation of the short UUID.

Gets a string representation of the short UUID, the first 4 hexadecimal digits: aabbccdd

◆ string()

auto smgl::Uuid::string ( ) const -> std::string

Get a string representation of the UUID.

Gets a string representation of the UUID as 16 hexadecimal digits: aabbccdd-eeff-0011-2233-445566778899

◆ Uuid4()

static auto smgl::Uuid::Uuid4 ( ) -> Uuid
static

Generate a UUIDv4 using pseudo-random numbers.

See RFC 4122 section 4.4 for more details.

Member Data Documentation

◆ buffer_

std::array<Byte, 16> smgl::Uuid::buffer_ {}
private

Byte storage

Definition at line 72 of file Uuid.hpp.


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