A UUID.
More...
#include <xentara/utils/core/Uuid.hpp>
|
template<tools::StringViewable String> |
static auto | fromString (const String &string) -> eh::expected< Uuid, std::error_code > |
| Creates a new UUID from a string.
|
|
static constexpr auto | fromRawData (const std::span< const std::byte, kRawDataSize > &data) -> Uuid |
| Creates a new UUID from raw data.
|
|
static auto | create () -> Uuid |
| Creates a new UUID.
|
|
static auto | createVersion4 () -> Uuid |
| Creates a version 4 UUID.
|
|
static auto | createVersion5 (const Uuid &namespaceUuid, const void *data, std::size_t size) -> Uuid |
| Creates a version 5 UUID from a block of memory.
|
|
template<tools::StringViewable String> |
static auto | createVersion5 (const Uuid &namespaceUuid, const String &string) -> Uuid |
| Creates a version 5 UUID from a Unicode string.
|
|
template<memory::MemoryRegion Region>
requires (!tools::StringViewable<Region>) |
static auto | createVersion5 (const Uuid &namespaceUuid, const Region ®ion) -> Uuid |
| Creates a version 5 UUID from a memory region.
|
|
template<memory::MemoryIterator Iterator> |
static auto | createVersion5 (const Uuid &namespaceUuid, Iterator begin, Iterator end) -> Uuid |
| Creates a version 5 UUID from a memory region defined by a pair of iterators.
|
|
template<memory::MemoryIterator Iterator>
requires (!std::convertible_to<Iterator, const void *>) |
static auto | createVersion5 (const Uuid &namespaceUuid, Iterator begin, std::iter_difference_t< Iterator > size) -> Uuid |
| Creates a version 5 UUID from a memory region defined by an iterator and a size.
|
|
◆ Uuid()
constexpr xentara::utils::core::Uuid::Uuid |
( |
| ) |
|
|
constexprdefault |
Default constructor.
Generates a null UUID
◆ create()
static auto xentara::utils::core::Uuid::create |
( |
| ) |
-> Uuid |
|
static |
Creates a new UUID.
Creates a new general purpose UUID, using a suitable version.
◆ createVersion4()
static auto xentara::utils::core::Uuid::createVersion4 |
( |
| ) |
-> Uuid |
|
static |
Creates a version 4 UUID.
◆ createVersion5() [1/5]
template<memory::MemoryRegion Region>
requires (!tools::StringViewable<Region>)
static auto xentara::utils::core::Uuid::createVersion5 |
( |
const Uuid & |
namespaceUuid, |
|
|
const Region & |
region |
|
) |
| -> Uuid
|
|
static |
Creates a version 5 UUID from a memory region.
- Parameters
-
namespaceUuid | The namespace UUID |
region | The memory region |
◆ createVersion5() [2/5]
template<tools::StringViewable String>
static auto xentara::utils::core::Uuid::createVersion5 |
( |
const Uuid & |
namespaceUuid, |
|
|
const String & |
string |
|
) |
| -> Uuid
|
|
static |
Creates a version 5 UUID from a Unicode string.
- Parameters
-
namespaceUuid | The namespace UUID |
string | The string. Must be encoded as UTF-8, UTF-16, or UTF-32. |
◆ createVersion5() [3/5]
static auto xentara::utils::core::Uuid::createVersion5 |
( |
const Uuid & |
namespaceUuid, |
|
|
const void * |
data, |
|
|
std::size_t |
size |
|
) |
| -> Uuid |
|
static |
Creates a version 5 UUID from a block of memory.
- Parameters
-
namespaceUuid | The namespace UUID |
data | A pointer to the memory block |
size | The size of the memory block |
◆ createVersion5() [4/5]
template<memory::MemoryIterator Iterator>
static auto xentara::utils::core::Uuid::createVersion5 |
( |
const Uuid & |
namespaceUuid, |
|
|
Iterator |
begin, |
|
|
Iterator |
end |
|
) |
| -> Uuid
|
|
static |
Creates a version 5 UUID from a memory region defined by a pair of iterators.
- Parameters
-
namespaceUuid | The namespace UUID |
begin | An iterator that points at the beginning of the memory region |
end | An iterator that points at the end of the memory region |
◆ createVersion5() [5/5]
Creates a version 5 UUID from a memory region defined by an iterator and a size.
- Parameters
-
namespaceUuid | The namespace UUID |
begin | An iterator that points at the beginning of the memory region |
size | The size of the memory region |
◆ fromRawData()
Creates a new UUID from raw data.
- Parameters
-
data | The raw bytes that should make up the UUID, in big endian byte order. The UUID 00112233-4455-6677-8899-aabbccddeeff must be represented as { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }. |
- Returns
- The UUID. No validity checking is done on the data.
◆ fromString()
template<tools::StringViewable String>
Creates a new UUID from a string.
- Parameters
-
string | The string. The encoding of the string can be ASCII, or any encoding compatible with ASCII. This includes, but is not limited to, UTF-8, Latin-1, Windows Code Page 1252, and Windows Code Page 850 (OEM). |
- Returns
- The UUID, or an error, if the string does not contain a valid UUID
◆ hash()
auto xentara::utils::core::Uuid::hash |
( |
| ) |
const -> std::size_t |
|
noexcept |
Calculates a hash value for the UUID.
◆ isNull()
constexpr auto xentara::utils::core::Uuid::isNull |
( |
| ) |
const -> bool
|
|
constexprnoexcept |
Determines if the UUID is 00000000-0000-0000-0000-000000000000
◆ operator<=>()
Three-Way-Comparison operator.
◆ operator==()
constexpr auto xentara::utils::core::Uuid::operator== |
( |
const Uuid & |
rhs | ) |
const -> bool
|
|
constexpr |
◆ rawData()
Gets the raw data of the UUID.
- Returns
- The raw bytes that make up the UUID, in big endian byte order. The UUID 00112233-4455-6677-8899-aabbccddeeff will be returned as { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0x00, 0xaa, 0xbb, 0xcc, 0xdd, 0xee, 0xff }.
The returned span will become invalid when this Uuid object is destroyed.
◆ toBasicString()
template<tools::CharType Char, typename CharTraits >
Converts the UUID to a string.
◆ toString()
Converts the UUID to a string of type char.
◆ toU16String()
Converts the UUID to a string of type char16_t.
◆ toU32String()
Converts the UUID to a string of type char32_t.
◆ toU8String()
Converts the UUID to a string of type char8_t.
◆ toWString()
Converts the UUID to a string of type wchar_t.
◆ operator""_uuid()
Literal operator for creating literal UUIDs.
◆ kRawDataSize
constexpr std::size_t xentara::utils::core::Uuid::kRawDataSize |
|
staticconstexpr |
The size of the raw data.
◆ kStringSize
constexpr std::size_t xentara::utils::core::Uuid::kStringSize |
|
staticconstexpr |
The size of the string representation.