Utility functions for UUID and unique identifier generation.
More...
|
| std::string | uniqid (bool moreEntropy=false) |
| | Generate a unique identifier based on the current time (microseconds).
|
| |
| std::string | v4 () |
| | Generate a random UUID (version 4).
|
| |
| std::string | v7 () |
| | Generate a time-ordered UUID (version 7).
|
| |
Utility functions for UUID and unique identifier generation.
Provides functions to generate unique identifiers in various formats:
- uniqid() : timestamp-based unique identifier (PHP-style).
- v4() : randomly generated UUID (RFC 4122 version 4).
- v7() : time-ordered UUID (RFC 4122 version 7).
◆ uniqid()
| std::string uniqid |
( |
bool |
moreEntropy = false | ) |
|
|
inline |
Generate a unique identifier based on the current time (microseconds).
Produces a string identifier derived from the current timestamp in microseconds. If moreEntropy is true, additional random bytes are appended to increase uniqueness (useful when multiple identifiers are generated in quick succession).
- Parameters
-
| moreEntropy | If true, append extra random entropy to the identifier. |
- Returns
- std::string Generated identifier (ASCII string, format not strictly defined).
Definition at line 70 of file uuid.h.
◆ v4()
Generate a random UUID (version 4).
Produces a RFC 4122 compliant UUID version 4 using random data. The returned string uses the canonical textual representation: "8-4-4-4-12" hexadecimal digits.
- Returns
- std::string UUID v4 as a text string.
Definition at line 101 of file uuid.h.
◆ v7()
Generate a time-ordered UUID (version 7).
Produces a UUID v7 combining a timestamp and random bits to allow roughly time-ordered identifiers while keeping sufficient entropy for uniqueness. The returned string uses the canonical textual representation: "8-4-4-4-12" hexadecimal digits.
- Note
- UUID v7 is a newer specification intended for sortable UUIDs.
- Returns
- std::string UUID v7 as a text string.
Definition at line 145 of file uuid.h.