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:
parent
96ba6c4b5b
commit
62334dd32a
@ -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) << '"';
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user