libhwbinder: TextOuptput fix
Add support of std::endl
Add back support of char
Add back support of bool
Add back support of String16
Test: run /data/nativetest(64)/hwbinderTextOutputTest
Bug: 32181382
Change-Id: Id27b6a943db6784deb4ff07169ddaa02cd3a6c20
diff --git a/include/hwbinder/TextOutput.h b/include/hwbinder/TextOutput.h
index 77ea764..d92c442 100644
--- a/include/hwbinder/TextOutput.h
+++ b/include/hwbinder/TextOutput.h
@@ -18,6 +18,7 @@
#define ANDROID_HARDWARE_TEXTOUTPUT_H
#include <utils/Errors.h>
+#include <utils/String8.h>
#include <stdint.h>
#include <string.h>
@@ -25,8 +26,6 @@
// ---------------------------------------------------------------------------
namespace android {
-class String8;
-class String16;
namespace hardware {
class TextOutput
@@ -121,6 +120,32 @@
};
TextOutput& operator<<(TextOutput& to, const HexDump& val);
+inline TextOutput& operator<<(TextOutput& to,
+ decltype(std::endl<char,
+ std::char_traits<char>>)
+ /*val*/) {
+ endl(to);
+ return to;
+}
+
+inline TextOutput& operator<<(TextOutput& to, const char &c)
+{
+ to.print(&c, 1);
+ return to;
+}
+
+inline TextOutput& operator<<(TextOutput& to, const bool &val)
+{
+ if (val) to.print("true", 4);
+ else to.print("false", 5);
+ return to;
+}
+
+inline TextOutput& operator<<(TextOutput& to, const String16& val)
+{
+ to << String8(val).string();
+ return to;
+}
// ---------------------------------------------------------------------------
// No user servicable parts below.