Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(150)

Unified Diff: third_party/WebKit/Source/wtf/text/WTFString.cpp

Issue 1807853003: Deprecate some macros in wtf/Assertions.h in favor of base/logging.h (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Many updates Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/wtf/text/WTFString.cpp
diff --git a/third_party/WebKit/Source/wtf/text/WTFString.cpp b/third_party/WebKit/Source/wtf/text/WTFString.cpp
index b67387516f033f4813df7bf79234e99544ceb1a4..1f4be45f87acef6bedd922841e4f166d8b614173 100644
--- a/third_party/WebKit/Source/wtf/text/WTFString.cpp
+++ b/third_party/WebKit/Source/wtf/text/WTFString.cpp
@@ -1198,6 +1198,49 @@ const String& emptyString16Bit()
return emptyString;
}
+std::ostream& operator<<(std::ostream& out, const String& string)
+{
+ if (string.isNull())
+ return out << "<null>";
+
+ out << '"';
+ for (unsigned index = 0; index < string.length(); ++index) {
+ // Print shorthands for select cases.
+ UChar character = string[index];
+ switch (character) {
+ case '\t':
+ out << "\\t";
+ break;
+ case '\n':
+ out << "\\n";
+ break;
+ case '\r':
+ out << "\\r";
+ break;
+ case '"':
+ out << "\\\"";
+ break;
+ case '\\':
+ out << "\\\\";
+ break;
+ default:
+ if (character >= 0x20 && character < 0x7F) {
esprehn 2016/03/18 04:58:31 This is just isASCII ?
tkent 2016/03/18 05:19:20 I changed it to isASCIIPrintable()
+ out << static_cast<char>(character);
+ } else {
+ // Print "\uXXXX" for control or non-ASCII characters.
+ out << "\\u";
+ out.width(4);
+ out.fill('0');
+ out.setf(std::ios_base::hex, std::ios_base::basefield);
+ out.setf(std::ios::uppercase);
+ out << character;
+ }
+ break;
+ }
+ }
+ return out << '"';
+}
+
} // namespace WTF
#ifndef NDEBUG

Powered by Google App Engine
This is Rietveld 408576698