1
0
mirror of https://github.com/narzoul/DDrawCompat synced 2024-12-30 08:55:36 +01:00

Handle null pointers when logging strings

This commit is contained in:
narzoul 2016-03-24 22:57:45 +01:00
parent 96ba6c4b5b
commit 62334dd32a
2 changed files with 22 additions and 0 deletions

View File

@ -16,8 +16,28 @@ namespace
}
}
std::ostream& operator<<(std::ostream& os, const char* str)
{
if (!str)
{
return os << "null";
}
return os.write(str, strlen(str));
}
std::ostream& operator<<(std::ostream& os, const unsigned char* data)
{
return os << static_cast<const void*>(data);
}
std::ostream& operator<<(std::ostream& os, const WCHAR* wstr)
{
if (!wstr)
{
return os << "null";
}
CStringA str(wstr);
return os << '"' << static_cast<const char*>(str) << '"';
}

View File

@ -14,6 +14,8 @@
isAlreadyLogged##__LINE__ = true; \
}
std::ostream& operator<<(std::ostream& os, const char* str);
std::ostream& operator<<(std::ostream& os, const unsigned char* data);
std::ostream& operator<<(std::ostream& os, const WCHAR* wstr);
std::ostream& operator<<(std::ostream& os, const RECT& rect);
std::ostream& operator<<(std::ostream& os, HDC__& dc);