Skip to content
Snippets Groups Projects
Commit e8c6b7d3 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Correct UUID to string

parent 77575990
No related branches found
No related tags found
No related merge requests found
Pipeline #11990 passed
...@@ -61,11 +61,37 @@ namespace ftl { ...@@ -61,11 +61,37 @@ namespace ftl {
*/ */
std::string to_string() const { std::string to_string() const {
static const char *digits = "0123456789abcdef"; static const char *digits = "0123456789abcdef";
std::string rc(sizeof(uuid_)*2,'0'); std::string rc(sizeof(uuid_)*2+4,'0');
for (size_t i=0 ; i<16; ++i) { size_t j=0;
rc[i*2] = digits[uuid_[i] & 0x0f]; for (size_t i=0 ; i<4; ++i) {
rc[i*2+1] = digits[(uuid_[i] >> 4) & 0x0f]; rc[j+1] = digits[uuid_[i] & 0x0f];
rc[j] = digits[(uuid_[i] >> 4) & 0x0f];
j+=2;
}
rc[j++] = '-';
for (size_t i=4 ; i<6; ++i) {
rc[j+1] = digits[uuid_[i] & 0x0f];
rc[j] = digits[(uuid_[i] >> 4) & 0x0f];
j+=2;
}
rc[j++] = '-';
for (size_t i=6 ; i<8; ++i) {
rc[j+1] = digits[uuid_[i] & 0x0f];
rc[j] = digits[(uuid_[i] >> 4) & 0x0f];
j+=2;
}
rc[j++] = '-';
for (size_t i=8 ; i<10; ++i) {
rc[j+1] = digits[uuid_[i] & 0x0f];
rc[j] = digits[(uuid_[i] >> 4) & 0x0f];
j+=2;
}
rc[j++] = '-';
for (size_t i=10 ; i<16; ++i) {
rc[j+1] = digits[uuid_[i] & 0x0f];
rc[j] = digits[(uuid_[i] >> 4) & 0x0f];
j+=2;
} }
return rc; return rc;
/* /*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment