summaryrefslogtreecommitdiff
path: root/AK/LogStream.h
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-07-04 07:05:58 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-07-04 07:05:58 +0200
commit1b013ba6995df165636cb33effeb26acc01e06cf (patch)
tree4599b5c072ef6f6bfcd33bd8155b747e939df208 /AK/LogStream.h
parent07d11a9b6b18f28d0e343bd7f69a091ae4b550b8 (diff)
downloadserenity-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.h43
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;