diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-07-04 07:05:58 +0200 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-07-04 07:05:58 +0200 |
commit | 1b013ba6995df165636cb33effeb26acc01e06cf (patch) | |
tree | 4599b5c072ef6f6bfcd33bd8155b747e939df208 /AK/LogStream.h | |
parent | 07d11a9b6b18f28d0e343bd7f69a091ae4b550b8 (diff) | |
download | serenity-1b013ba6995df165636cb33effeb26acc01e06cf.zip |
AK: Move some of LogStream out of line & add overloads for smart pointers.
Diffstat (limited to 'AK/LogStream.h')
-rw-r--r-- | AK/LogStream.h | 43 |
1 files changed, 17 insertions, 26 deletions
diff --git a/AK/LogStream.h b/AK/LogStream.h index 315d133b79..44ee51df09 100644 --- a/AK/LogStream.h +++ b/AK/LogStream.h @@ -1,9 +1,12 @@ #pragma once -#include <AK/AKString.h> -#include <AK/StringView.h> #include <AK/kstdio.h> +namespace AK { + +class String; +class StringView; + class LogStream { public: LogStream() {} @@ -35,21 +38,19 @@ inline DebugLogStream dbg() inline const LogStream& operator<<(const LogStream& stream, const char* value) { - stream.write(value, strlen(value)); + int length = 0; + const char* p = value; + while (*(p++)) + ++length; + stream.write(value, length); return stream; } -inline const LogStream& operator<<(const LogStream& stream, const String& value) -{ - stream.write(value.characters(), value.length()); - return stream; -} - -inline const LogStream& operator<<(const LogStream& stream, const StringView& value) -{ - stream.write(value.characters(), value.length()); - return stream; -} +const LogStream& operator<<(const LogStream&, const String&); +const LogStream& operator<<(const LogStream&, const StringView&); +const LogStream& operator<<(const LogStream&, int); +const LogStream& operator<<(const LogStream&, unsigned); +const LogStream& operator<<(const LogStream&, const void*); inline const LogStream& operator<<(const LogStream& stream, char value) { @@ -62,17 +63,7 @@ inline const LogStream& operator<<(const LogStream& stream, bool value) return stream << (value ? "true" : "false"); } -inline const LogStream& operator<<(const LogStream& stream, int value) -{ - return stream << String::number(value); } -inline const LogStream& operator<<(const LogStream& stream, unsigned value) -{ - return stream << String::number(value); -} - -inline const LogStream& operator<<(const LogStream& stream, const void* value) -{ - return stream << String::format("%p", value); -} +using AK::LogStream; +using AK::dbg; |