| 181 | |
| 182 | #if defined _WIN32 && defined _DEBUG |
| 183 | class DebugOutput : public DebugOutputBase |
| 184 | { |
| 185 | public: |
| 186 | std::streamsize writeImpl(const char* str, std::streamsize size, Level debugLevel) |
| 187 | { |
| 188 | if (size > std::numeric_limits<int>::max()) |
| 189 | OutputDebugStringW(L"Next line truncated..."); |
| 190 | auto wideSize = MultiByteToWideChar(CP_UTF8, 0, str, |
| 191 | static_cast<int>(std::min<std::streamsize>(size, std::numeric_limits<int>::max())), nullptr, 0); |
| 192 | std::wstring wide(wideSize, L'\0'); |
| 193 | MultiByteToWideChar(CP_UTF8, 0, str, |
| 194 | static_cast<int>(std::min<std::streamsize>(size, std::numeric_limits<int>::max())), wide.data(), |
| 195 | wideSize); |
| 196 | // Write string to Visual Studio Debug output |
| 197 | OutputDebugStringW(wide.c_str()); |
| 198 | return size; |
| 199 | } |
| 200 | |
| 201 | virtual ~DebugOutput() = default; |
| 202 | }; |
| 203 | #else |
| 204 | |
| 205 | struct Record |