Lightweight ulid implementation in C++ suitable for embedded environments:
- No dynamic allocations
- No C++ Exceptions
- Thread-safe
-
Copy
ulid.cppandulid.hfiles to your project. That's it. -
You can also build it from source and install it via CMake.
$ cmake -B build -DCMAKE_BUILD_TYPE=Release
$ cmake --build build
$ cmake --install buildNo dynamic allocation:
char ulid_str[27]; // 26 characters + null terminator
ulid::generate(ulid_str);
printf("%s\n", ulid_str); // ulid_str is null-terminatedSimple API:
std::string unique = ulid::generate().str();Decode a ULID string back to bytes:
const char some_ulid[] = "01GF428XRREWQWJHXRRGNN99NV";
ulid::ulid_t bits = ulid::from_str(some_ulid);