Sole is a lightweight, header-only C++11 library used to generate and manipulate Universally Unique Identifiers (UUIDs). It supports UUID versions 0, 1, and 4, and allows rebuilding UUIDs from hexadecimal or base62 strings.
Supported UUID Versions
- Version 0 (Custom): Combines a 16-bit PID, 48-bit MAC address, and a 60-bit clock (100ns resolution since Unix epoch). Format:
EPOCH_LOW-EPOCH_MID-VERSION(0)|EPOCH_HI-PID-MAC. - Version 1: Uses a 48-bit MAC address and a 60-bit clock. Best used when you want to avoid collisions based on probability.
- Version 4: Uses 122 bits of randomness. Best used when security and non-determinism are priorities.
Integration
Since it is a header-only library, you can include sole.hpp in your project. When compiling with clang or g++, you may need to specify -std=c++11 and link the real-time library using -lrt.
g++ sample.cc -std=c++11 -lrt && ./a.out