From 8cb8925921523e701c59f5b1ac1c37825528fec7 Mon Sep 17 00:00:00 2001 From: Jeff Sharkey Date: Thu, 30 May 2013 13:53:39 -0700 Subject: [PATCH] Bring back overloading to print String8/16. Change-Id: Iecab20db2b8574d5f1e6fdefdc2c8d4ce6c37121 --- include/binder/TextOutput.h | 5 +++++ libs/binder/TextOutput.cpp | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/binder/TextOutput.h b/include/binder/TextOutput.h index de2fbbee1..974a194d8 100644 --- a/include/binder/TextOutput.h +++ b/include/binder/TextOutput.h @@ -25,6 +25,9 @@ // --------------------------------------------------------------------------- namespace android { +class String8; +class String16; + class TextOutput { public: @@ -76,6 +79,8 @@ TextOutput& operator<<(TextOutput& to, float); TextOutput& operator<<(TextOutput& to, double); TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func); TextOutput& operator<<(TextOutput& to, const void*); +TextOutput& operator<<(TextOutput& to, const String8& val); +TextOutput& operator<<(TextOutput& to, const String16& val); class TypeCode { diff --git a/libs/binder/TextOutput.cpp b/libs/binder/TextOutput.cpp index 9637334be..db3e858a4 100644 --- a/libs/binder/TextOutput.cpp +++ b/libs/binder/TextOutput.cpp @@ -18,6 +18,9 @@ #include +#include +#include + #include #include #include @@ -119,6 +122,18 @@ TextOutput& operator<<(TextOutput& to, const void* val) return to; } +TextOutput& operator<<(TextOutput& to, const String8& val) +{ + to << val.string(); + return to; +} + +TextOutput& operator<<(TextOutput& to, const String16& val) +{ + to << String8(val).string(); + return to; +} + static void textOutputPrinter(void* cookie, const char* txt) { ((TextOutput*)cookie)->print(txt, strlen(txt));