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

Side by Side Diff: mojo/public/cpp/bindings/string.h

Issue 406913002: Add operator<< for mojo::String for logging use (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove blank line Created 6 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "mojo/public/cpp/bindings/lib/array_internal.h" 10 #include "mojo/public/cpp/bindings/lib/array_internal.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 inline bool operator==(const char* a, const String& b) { 99 inline bool operator==(const char* a, const String& b) {
100 return !b.is_null() && a == b.get(); 100 return !b.is_null() && a == b.get();
101 } 101 }
102 inline bool operator==(const String& a, const char* b) { 102 inline bool operator==(const String& a, const char* b) {
103 return !a.is_null() && a.get() == b; 103 return !a.is_null() && a.get() == b;
104 } 104 }
105 inline bool operator!=(const String& a, const String& b) { return !(a == b); } 105 inline bool operator!=(const String& a, const String& b) { return !(a == b); }
106 inline bool operator!=(const char* a, const String& b) { return !(a == b); } 106 inline bool operator!=(const char* a, const String& b) { return !(a == b); }
107 inline bool operator!=(const String& a, const char* b) { return !(a == b); } 107 inline bool operator!=(const String& a, const char* b) { return !(a == b); }
108 108
109 inline std::ostream& operator<<(std::ostream& out, const String& s) {
110 return out << s.get();
111 }
112
109 // TODO(darin): Add similar variants of operator<,<=,>,>= 113 // TODO(darin): Add similar variants of operator<,<=,>,>=
110 114
111 template <> 115 template <>
112 class TypeConverter<String, std::string> { 116 class TypeConverter<String, std::string> {
113 public: 117 public:
114 static String ConvertFrom(const std::string& input) { 118 static String ConvertFrom(const std::string& input) {
115 return String(input); 119 return String(input);
116 } 120 }
117 static std::string ConvertTo(const String& input) { 121 static std::string ConvertTo(const String& input) {
118 return input; 122 return input;
(...skipping 24 matching lines...) Expand all
143 public: 147 public:
144 // |input| may be null, in which case a null String will be returned. 148 // |input| may be null, in which case a null String will be returned.
145 static String ConvertFrom(const char* input) { 149 static String ConvertFrom(const char* input) {
146 return String(input); 150 return String(input);
147 } 151 }
148 }; 152 };
149 153
150 } // namespace mojo 154 } // namespace mojo
151 155
152 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ 156 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698