mirror of
https://github.com/SerenityOS/serenity
synced 2024-11-05 17:46:52 +00:00
0e75aba7c3
This should make you think twice before trying to use the const char* from a StringView as if it's a null-terminated string.
34 lines
788 B
C++
34 lines
788 B
C++
#include <AK/AKString.h>
|
|
#include <AK/LogStream.h>
|
|
#include <AK/StringView.h>
|
|
|
|
namespace AK {
|
|
|
|
const LogStream& operator<<(const LogStream& stream, const String& value)
|
|
{
|
|
stream.write(value.characters(), value.length());
|
|
return stream;
|
|
}
|
|
|
|
const LogStream& operator<<(const LogStream& stream, const StringView& value)
|
|
{
|
|
stream.write(value.characters_without_null_termination(), value.length());
|
|
return stream;
|
|
}
|
|
|
|
const LogStream& operator<<(const LogStream& stream, int value)
|
|
{
|
|
return stream << String::number(value);
|
|
}
|
|
|
|
const LogStream& operator<<(const LogStream& stream, unsigned value)
|
|
{
|
|
return stream << String::number(value);
|
|
}
|
|
|
|
const LogStream& operator<<(const LogStream& stream, const void* value)
|
|
{
|
|
return stream << String::format("%p", value);
|
|
}
|
|
|
|
}
|