Bring back overloading to print String8/16.

Change-Id: Iecab20db2b8574d5f1e6fdefdc2c8d4ce6c37121
This commit is contained in:
Jeff Sharkey 2013-05-30 13:53:39 -07:00
parent c40f4e64f2
commit 8cb8925921
2 changed files with 20 additions and 0 deletions

View File

@ -25,6 +25,9 @@
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
namespace android { namespace android {
class String8;
class String16;
class TextOutput class TextOutput
{ {
public: public:
@ -76,6 +79,8 @@ TextOutput& operator<<(TextOutput& to, float);
TextOutput& operator<<(TextOutput& to, double); TextOutput& operator<<(TextOutput& to, double);
TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func); TextOutput& operator<<(TextOutput& to, TextOutputManipFunc func);
TextOutput& operator<<(TextOutput& to, const void*); TextOutput& operator<<(TextOutput& to, const void*);
TextOutput& operator<<(TextOutput& to, const String8& val);
TextOutput& operator<<(TextOutput& to, const String16& val);
class TypeCode class TypeCode
{ {

View File

@ -18,6 +18,9 @@
#include <binder/Debug.h> #include <binder/Debug.h>
#include <utils/String8.h>
#include <utils/String16.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
@ -119,6 +122,18 @@ TextOutput& operator<<(TextOutput& to, const void* val)
return to; 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) static void textOutputPrinter(void* cookie, const char* txt)
{ {
((TextOutput*)cookie)->print(txt, strlen(txt)); ((TextOutput*)cookie)->print(txt, strlen(txt));