Lightweight ulid
implementation in C++ suitable for embedded environments:
- No dynamic allocations
- No C++ Exceptions
- Thread-safe
-
Copy
ulid.cpp
andulid.h
files 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 build
No dynamic allocation:
char ulid_str[27]; // 26 characters + null terminator
ulid::generate(ulid_str);
printf("%s\n", ulid_str); // ulid_str is null-terminated
Simple 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);