Hi,
I’m looking to create some UUIDs that are reproducible
To do this, I propose adding a constructor to Uuid that takes an int64 which is passed into the Random object instead of letting the Random object seed itself
I don’t know what your preferred method would be, but something like this would be great:
void initialiseUuid (Random& r, uint8* uuid)
{
for (size_t i = 0; i < sizeof (uuid); ++i)
uuid[i] = (uint8) (r.nextInt (256));
// To make it RFC 4122 compliant, need to force a few bits...
uuid[6] = (uuid[6] & 0x0f) | 0x40;
uuid[8] = (uuid[8] & 0x3f) | 0x80;
}
Uuid::Uuid()
{
Random r;
initialiseUuid (r, uuid);
}
Uuid::Uuid (int64 seed)
{
Random r (seed);
initialiseUuid (r, uuid);
}