| 34 | namespace |
| 35 | { |
| 36 | std::array<char, 16> CreateRandomUUID() |
| 37 | { |
| 38 | std::random_device rd; |
| 39 | std::mt19937 gen(rd()); |
| 40 | std::uniform_int_distribution<uint32_t> dist; |
| 41 | std::array<char, 16> out{}; |
| 42 | char* bytes = out.data(); |
| 43 | for(int i = 0; i < 16; i += 4) |
| 44 | { |
| 45 | // NOLINTNEXTLINE(cppcoreguidelines-pro-type-reinterpret-cast) |
| 46 | *reinterpret_cast<uint32_t*>(bytes + i) = dist(gen); |
| 47 | } |
| 48 | // variant must be 10xxxxxx |
| 49 | bytes[8] &= static_cast<char>(0xBF); |
| 50 | bytes[8] |= static_cast<char>(0x80); |
| 51 | |
| 52 | // version must be 0100xxxx |
| 53 | bytes[6] &= 0x4F; |
| 54 | bytes[6] |= 0x40; |
| 55 | |
| 56 | return out; |
| 57 | } |
| 58 | } // namespace |
| 59 | |
| 60 | struct Groot2Publisher::PImpl |