class
#include <rll/uuid.h>
uuid 128-bit globally unique identifier (GUID).
Based on std::
Public static variables
- static auto long_guid_string_length constexpr
- Length of the guid string representation in the form of
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
. - static auto short_guid_string_length constexpr
- Length of the guid string representation in the form of
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
.
Public static functions
Constructors, destructors, conversion operators
- operator bool() const noexcept
- Checks whether the guid is valid or not.
- uuid() constexpr
- Creates an empty guid.
-
uuid(std::
array<u8, 16> const& bytes) explicit constexpr - Creates a guid from an array of bytes.
-
uuid(std::
array<std:: byte, 16> const& bytes) explicit - Creates a
guid
from an array ofstd::
.byte -
uuid(std::
string_view const str) explicit constexpr - Creates a guid from a string.
- uuid(uuid const&) defaulted
- uuid(uuid&&) defaulted
- ~uuid() defaulted
Public functions
-
auto bytes() const → std::
array<u8, 16> const& constexpr noexcept - Gets the bytes of the guid.
-
auto bytes_mut() → std::
array<u8, 16>& constexpr noexcept - Gets the mutable bytes of the guid.
- auto operator!=(uuid const& other) const → bool noexcept
- Checks whether two guids are not equal.
- auto operator=(uuid const&) → uuid& defaulted
- auto operator=(uuid&&) → uuid& defaulted
- auto operator==(uuid const& other) const → bool noexcept
- Checks whether two guids are equal or not.
-
auto to_string() const → std::
string - Converts the guid to a string.
- auto to_u64() const → u64 noexcept
- Hashes the guid to an unsigned 64-bit integer.
- auto valid() const → bool noexcept
- Checks whether the guid is valid or not.
Friends
- auto operator<(uuid const& lhs, uuid const& rhs) → bool noexcept
- Array-like less comparator for guid.
-
auto operator<<(std::
ostream& os, uuid const& guid) → std:: ostream& - Prints the guid to an output stream.
Function documentation
static result<uuid> rll:: uuid:: try_parse(std:: string_view str) noexcept
Tries to parse a guid from a string representation.
Parameters | |
---|---|
str | String representation of the guid. |
Returns | Parsed guid if successful, error otherwise. |
rll:: uuid:: operator bool() const noexcept
Checks whether the guid is valid or not.
Returns | true if the guid is valid, false otherwise. |
---|
rll:: uuid:: uuid() constexpr
Creates an empty guid.
rll:: uuid:: uuid(std:: array<u8, 16> const& bytes) explicit constexpr
Creates a guid from an array of bytes.
Parameters | |
---|---|
bytes | Array of bytes. |
rll:: uuid:: uuid(std:: array<std:: byte, 16> const& bytes) explicit
Creates a guid
from an array of std::
.
Parameters | |
---|---|
bytes | Array of std:: . |
rll:: uuid:: uuid(std:: string_view const str) explicit constexpr
Creates a guid from a string.
Parameters | |
---|---|
str | String representation of the guid. |
String must satisfy the following requirements:
- Length of string must be exactly 36 or 38 characters (see short_
guid_ string_ length and long_ guid_ string_ length). - String must be in the form of
{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}
orxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
(with or without braces). - Bytes must be separated by hyphens.
std:: array<u8, 16> const& rll:: uuid:: bytes() const constexpr noexcept
Gets the bytes of the guid.
Returns | Constant reference to the array of bytes. |
---|
std:: array<u8, 16>& rll:: uuid:: bytes_mut() constexpr noexcept
Gets the mutable bytes of the guid.
Returns | Mutable reference to the array of bytes. |
---|
bool rll:: uuid:: operator!=(uuid const& other) const noexcept
Checks whether two guids are not equal.
Parameters | |
---|---|
other | Other guid. |
Returns | true if the guids are not equal, false otherwise. |
bool rll:: uuid:: operator==(uuid const& other) const noexcept
Checks whether two guids are equal or not.
Parameters | |
---|---|
other | Other guid. |
Returns | true if the guids are equal, false otherwise. |
std:: string rll:: uuid:: to_string() const
Converts the guid to a string.
Returns | String representation of the guid . |
---|
String representation is in the form of xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
. All hex digits are lowercase. Bytes are separated by hyphens.
bool rll:: uuid:: valid() const noexcept
Checks whether the guid is valid or not.
Returns | true if the guid is valid, false otherwise. |
---|
std:: ostream& operator<<(std:: ostream& os,
uuid const& guid)
Prints the guid to an output stream.
Parameters | |
---|---|
os | Output stream |
guid | GUID |
Returns | Output stream |