| 106 | } |
| 107 | |
| 108 | std::string GlobalUID::ToString() const { |
| 109 | #ifdef GRS_WINDOWS |
| 110 | GUID guid; |
| 111 | std::memcpy(&guid, uuid, sizeof(guid)); |
| 112 | |
| 113 | // To string (wchar_t) |
| 114 | OLECHAR *guidString; |
| 115 | StringFromCLSID(guid, &guidString); |
| 116 | |
| 117 | // Get the converted length |
| 118 | int32_t wideLength = static_cast<int32_t>(std::wcslen(guidString)); |
| 119 | |
| 120 | // Get the UTF8 length |
| 121 | int32_t length = WideCharToMultiByte(CP_UTF8, 0, guidString, wideLength, nullptr, 0, nullptr, nullptr); |
| 122 | |
| 123 | // To UTF8 |
| 124 | std::string str(length, 0); |
| 125 | WideCharToMultiByte(CP_UTF8, 0, guidString, wideLength, &str[0], length, nullptr, nullptr); |
| 126 | |
| 127 | // OK |
| 128 | CoTaskMemFree(guidString); |
| 129 | return str; |
| 130 | #else |
| 131 | # error Not implemented |
| 132 | #endif |
| 133 | } |
| 134 | |
| 135 | GlobalUID GlobalUID::FromPlatformGUID(const GUID &value) { |
| 136 | GlobalUID uid; |
no outgoing calls
no test coverage detected