Universally Unique Identifier (UUID).
More...
#include <uuid.h>
Universally Unique Identifier (UUID).
Generates and manipulates RFC 4122 / RFC 9562 UUIDs.
- Example
bool valid =
id.isValid();
Dynamic array container wrapping std::vector.
Definition list.h:40
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
Universally Unique Identifier (UUID).
Definition uuid.h:34
static UUID fromString(const char *string, Error *err=nullptr)
Parses a UUID from a string representation.
static UUID generate(int version=4)
Convenience generator that dispatches to the appropriate generateVn() function.
Supports versions 1 (stub), 3, 4, 5, and 7.
◆ data()
Returns a const reference to the raw 16-byte data.
- Returns
- The underlying DataFormat array.
◆ fromString()
Parses a UUID from a string representation.
- Parameters
-
| string | The UUID string (e.g. "550e8400-e29b-41d4-a716-446655440000"). |
| err | Optional error output. |
- Returns
- The parsed UUID, or an invalid UUID on failure.
◆ generate()
Convenience generator that dispatches to the appropriate generateVn() function.
- Parameters
-
| version | UUID version to generate (default: 4). |
For versions 3 and 5, the namespace UUID and name are taken from the Application object (appUUID and appName).
- Returns
- A valid UUID, or an invalid UUID if the version is unsupported or if generation fails.
◆ generateV1()
Generates a version 1 (timestamp + MAC) UUID.
- Note
- Not implemented. Calling this will trigger an assertion failure.
◆ generateV3()
Generates a version 3 (MD5 namespace) UUID.
- Parameters
-
| ns | The namespace UUID. |
| name | The name to hash within the namespace. |
- Returns
- A deterministic version 3 UUID.
◆ generateV4()
Generates a random version 4 UUID.
- Returns
- A valid UUID, or an invalid (all-zero) UUID on failure.
◆ generateV5()
Generates a version 5 (SHA-1 namespace) UUID.
- Parameters
-
| ns | The namespace UUID. |
| name | The name to hash within the namespace. |
- Returns
- A deterministic version 5 UUID.
◆ generateV7()
Generates a version 7 (Unix timestamp + random) UUID.
- Parameters
-
| timestampMs | Unix timestamp in milliseconds. If negative, the current system time is used. |
- Returns
- A valid, time-sortable UUID.
◆ isValid()
| bool UUID::isValid |
( |
| ) |
const |
|
inline |
Returns true if this UUID is not all-zero.
- Returns
- true if the UUID contains at least one non-zero byte.
◆ raw()
Returns a pointer to the raw byte data.
- Returns
- A pointer to the first byte of the UUID.
◆ toString()
| String UUID::toString |
( |
| ) |
const |
Returns the standard string representation of the UUID.
- Returns
- A String in the format "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx".
◆ version()
| int UUID::version |
( |
| ) |
const |
|
inline |
Returns the UUID version number.
- Returns
- The version (1-8) encoded in the UUID, or 0 if invalid.
The documentation for this class was generated from the following file: