OSDN Git Service

Bring back overloading to print String8/16.
authorJeff Sharkey <jsharkey@android.com>
Thu, 30 May 2013 20:53:39 +0000 (13:53 -0700)
committerJeff Sharkey <jsharkey@android.com>
Thu, 30 May 2013 21:04:28 +0000 (14:04 -0700)
Change-Id: Iecab20db2b8574d5f1e6fdefdc2c8d4ce6c37121

include/binder/TextOutput.h
libs/binder/TextOutput.cpp

index de2fbbe..974a194 100644 (file)
@@ -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 
 {
index 9637334..db3e858 100644 (file)
@@ -18,6 +18,9 @@
 
 #include <binder/Debug.h>
 
+#include <utils/String8.h>
+#include <utils/String16.h>
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -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));