psl::UID struct final

is an object holding a Unique IDentifier (UID)

UID generates a unique ID, either through a random number generator, or by using OS provided methods. It is immutable once created.

static variables

invalid_uid
a global instance that signifies the invalid_uid used by the current runtime.
constconstpublicpublicstaticstatic

static member functions

from_string
tries to convert from the given string based representation to a valid UID.
public static
valid
checks the given string if it's in a valid UID format.
public static noexcept
generate
generates a UID.
public static

constructors, destructors, conversion operators

UID
constructor that creates an invalid UID.
public defaulted
UID
public constexpr
operator bool
checks if the held UID is valid.
const public

member-functions

to_string
creates a string based representation of the owned UID.
const public
invalidate
invalidates the current UID.
public

Function documentation

static UID psl::UID::from_string(const psl::string8_t& key)

Brief

tries to convert from the given string based representation to a valid UID.

Details

when sending a string of the form "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" or "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}" to this method, it will parse it and will return a valid UID instance. Otherwise it will return UID::invalid_uid.

Parameters
key in a string in the valid format to convert to UID.
Returns either a valid UID based on the key, or UID::invalid_uid if something went wrong.

static bool psl::UID::valid(const psl::string8_t& key) noexcept

Brief

checks the given string if it's in a valid UID format.

Parameters
key in the string to be checked.
Returns true if the given key is convertible to a UID instance.

static UID psl::UID::generate()

Brief

generates a UID.

Returns a valid UID.

psl::UID::UID(const PUID& id) constexpr

Details

a constructor that created a UID from the internal representation (PUID).

Parameters
id in the internal representation of a UID.

psl::UID::operator bool() const

Brief

checks if the held UID is valid.

Returns true in case the held UID is valid.

const psl::string8_t psl::UID::to_string() const

Brief

creates a string based representation of the owned UID.

Details

creates a string based representation of the owned UID of the form "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".

Returns a UTF-8 string based representation of the owned UID.

void psl::UID::invalidate()

Brief

invalidates the current UID.

Details

If for some reason you want to invalidate this object as being a valid UID, then calling this method will set the internal UID to be equivalent to UID::invalid_uid. This operation is permanent.

Variable documentation

static UID psl::UID::invalid_uid

a global instance that signifies the invalid_uid used by the current runtime.