42 memset(
this, 0,
sizeof(*
this));
64 for(
int i=0; i<38; ++i)
70 const char* hex=
"0123456789abcdef";
86 for(
int i=0; i<8; ++i)
87 guid_str[i+1] = hex[ (
mTimeLow >> (28-4*i)) & 0xF];
90 for(
int i=0; i<4; ++i)
91 guid_str[i+10] = hex[ (
mTimeMid >> (12-4*i)) & 0xF];
94 for(
int i=0; i<4; ++i)
106 guid_str[25] = hex[ (
mNode[0] >> (4-4*0)) & 0xF];
107 guid_str[26] = hex[ (mNode[0] >> (4-4*1)) & 0xF];
108 guid_str[27] = hex[ (mNode[1] >> (4-4*0)) & 0xF];
109 guid_str[28] = hex[ (mNode[1] >> (4-4*1)) & 0xF];
110 guid_str[29] = hex[ (mNode[2] >> (4-4*0)) & 0xF];
111 guid_str[30] = hex[ (mNode[2] >> (4-4*1)) & 0xF];
112 guid_str[31] = hex[ (mNode[3] >> (4-4*0)) & 0xF];
113 guid_str[32] = hex[ (mNode[3] >> (4-4*1)) & 0xF];
114 guid_str[33] = hex[ (mNode[4] >> (4-4*0)) & 0xF];
115 guid_str[34] = hex[ (mNode[4] >> (4-4*1)) & 0xF];
116 guid_str[35] = hex[ (mNode[5] >> (4-4*0)) & 0xF];
117 guid_str[36] = hex[ (mNode[5] >> (4-4*1)) & 0xF];
122 sprintf(guid_cstr,
"{%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x}",
125 mNode[0], mNode[1], mNode[2], mNode[3], mNode[4], mNode[5]);
126 VL_CHECK( memcmp(guid_str, guid_cstr, 38) == 0 )
132 std::string guid_str;
140 memcpy(xxx, guid_str, 38);
142 if (guid_str[0] !=
'{')
145 if (guid_str[37] !=
'}')
148 if (guid_str[9] !=
'-')
151 if (guid_str[14] !=
'-')
154 if (guid_str[19] !=
'-')
157 if (guid_str[24] !=
'-')
161 unsigned int nibble[38];
162 for(
int i=0; i<38; ++i)
164 if (i==0 || i==37 || i==9 || i==14 || i==19 || i==24 )
167 if ( guid_str[i]>=
'0' && guid_str[i]<=
'9' )
168 nibble[i] = guid_str[i] -
'0';
170 if ( guid_str[i]>=
'a' && guid_str[i]<=
'f' )
171 nibble[i] = guid_str[i] -
'a' + 10;
173 if ( guid_str[i]>=
'A' && guid_str[i]<=
'F' )
174 nibble[i] = guid_str[i] -
'A' + 10;
182 memset(
this, 0,
sizeof(*
this));
184 mTimeLow = (nibble[1] << 28) | (nibble[2] << 24) | (nibble[3] << 20) | (nibble[4] << 16) |
185 (nibble[5] << 12) | (nibble[6] << 8) | (nibble[7] << 4) | nibble[8];
187 mTimeMid = (
unsigned short)((nibble[10] << 12) | (nibble[11] << 8) | (nibble[12] << 4) | nibble[13]);
189 mTimeHiAndVersion = (
unsigned short)((nibble[15] << 12) | (nibble[16] << 8) | (nibble[17] << 4) | nibble[18]);
193 mClockSeqLow = (
unsigned char)((nibble[22] << 4) | (nibble[23] << 0));
195 mNode[0] = (
unsigned char)((nibble[25] << 4) | nibble[26]);
196 mNode[1] = (
unsigned char)((nibble[27] << 4) | nibble[28]);
197 mNode[2] = (
unsigned char)((nibble[29] << 4) | nibble[30]);
198 mNode[3] = (
unsigned char)((nibble[31] << 4) | nibble[32]);
199 mNode[4] = (
unsigned char)((nibble[33] << 4) | nibble[34]);
200 mNode[5] = (
unsigned char)((nibble[35] << 4) | nibble[36]);
unsigned short mTimeHiAndVersion
unsigned char mClockSeqLow
bool fromString(const char *guid_str)
Init the UUID from the specified string which must be at least 38 characters long and must be of the ...
void generateVersion4(const Random &random)
Generates a Version 4 UUID as defined by RFC4122 using the specified random number generator...
VLCORE_EXPORT real random(real min, real max)
Returns a random number N between 'min' and 'max' (included) with 53 bits of randomness generated usi...
Visualization Library main namespace.
unsigned char mClockSeqHiAndReserved
void fillString(char *guid_str, bool zero_terminate=true) const
Fills a buffer with an ascii representation of the UUID of type {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx...
UUID()
Constructor, by default it is set to all zeros.
virtual bool fillRandom(void *ptr, size_t bytes) const
Fills the specified buffer with random data generated using the best quality random number generation...
std::string toStdString() const
Returns an std::string jwith an ASCII representation of the UUID of type {xxxxxxxx-xxxx-xxxx-xxxx-xxx...
Cryptographic random number generator.