Permanent identifier for entities, assets and any object that must keep the same identity across sessions.
More...
#include <quasar/core/UUID.h>
|
|
constexpr | UUID ()=default |
| | Creates an invalid UUID, with the value 0.
|
| constexpr | UUID (std::uint64_t value) |
| | Creates a UUID from a saved value, for example when a scene is loaded.
|
| constexpr std::uint64_t | GetValue () const |
| | Returns the raw value, to save the UUID in a file.
|
| constexpr bool | IsValid () const |
| | Returns true if the UUID is not the reserved value 0.
|
| std::string | ToString () const |
| | Returns the UUID as text, to save it in a file: 16 lowercase hexadecimal digits.
|
|
constexpr auto | operator<=> (const UUID &) const =default |
| | Compares two UUIDs by their value, so they can be sorted and used as map keys.
|
Permanent identifier for entities, assets and any object that must keep the same identity across sessions.
The value is saved as is in scene and asset files. The value 0 is reserved: a default-constructed UUID is invalid. Use Generate() to create a new identifier. A UUID can be used as a key in std::map and std::unordered_map.
◆ UUID()
| Quasar::UUID::UUID |
( |
std::uint64_t | value | ) |
|
|
inlineexplicitconstexpr |
Creates a UUID from a saved value, for example when a scene is loaded.
- Parameters
-
◆ Generate()
| UUID Quasar::UUID::Generate |
( |
| ) |
|
|
static |
Creates a new random UUID.
Safe to call from any thread.
- Returns
- A valid UUID, never equal to 0.
◆ GetValue()
| std::uint64_t Quasar::UUID::GetValue |
( |
| ) |
const |
|
inlineconstexpr |
Returns the raw value, to save the UUID in a file.
- Returns
- The 64-bit value of the UUID.
◆ IsValid()
| bool Quasar::UUID::IsValid |
( |
| ) |
const |
|
inlineconstexpr |
Returns true if the UUID is not the reserved value 0.
- Returns
- False for a default-constructed UUID, true for a generated one.
◆ ToString()
| std::string Quasar::UUID::ToString |
( |
| ) |
const |
Returns the UUID as text, to save it in a file: 16 lowercase hexadecimal digits.
- Returns
- For example "00ab3f9c12e45d07". An invalid UUID gives "0000000000000000".
◆ FromString()
| std::optional< UUID > Quasar::UUID::FromString |
( |
std::string_view | text | ) |
|
|
static |
Reads a UUID from the text written by ToString().
Nothing is logged when the text is invalid: the caller knows which file or field it came from, so it can report a clearer error.
- Parameters
-
| text | Exactly 16 hexadecimal digits, in lowercase or uppercase, with nothing before or after. |
- Returns
- The UUID, or no value if the text has another form.
The documentation for this class was generated from the following file: