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

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

Issue 1519673002: Add helpers for logging mojom objects. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: rebase Created 5 years 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
« no previous file with comments | « mojo/public/cpp/bindings/map.h ('k') | mojo/public/cpp/bindings/struct_ptr.h » ('j') | 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 <iosfwd>
8 #include <string> 9 #include <string>
9 10
10 #include "mojo/public/cpp/bindings/lib/array_internal.h" 11 #include "mojo/public/cpp/bindings/lib/array_internal.h"
11 #include "mojo/public/cpp/bindings/type_converter.h" 12 #include "mojo/public/cpp/bindings/type_converter.h"
12 #include "mojo/public/cpp/environment/logging.h" 13 #include "mojo/public/cpp/environment/logging.h"
13 14
14 namespace mojo { 15 namespace mojo {
15 16
16 // A UTF-8 encoded character string that can be null. Provides functions that 17 // A UTF-8 encoded character string that can be null. Provides functions that
17 // are similar to std::string, along with access to the underlying std::string 18 // are similar to std::string, along with access to the underlying std::string
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 inline bool operator!=(const String& a, const String& b) { 116 inline bool operator!=(const String& a, const String& b) {
116 return !(a == b); 117 return !(a == b);
117 } 118 }
118 inline bool operator!=(const char* a, const String& b) { 119 inline bool operator!=(const char* a, const String& b) {
119 return !(a == b); 120 return !(a == b);
120 } 121 }
121 inline bool operator!=(const String& a, const char* b) { 122 inline bool operator!=(const String& a, const char* b) {
122 return !(a == b); 123 return !(a == b);
123 } 124 }
124 125
126 // TODO(jeffbrown): Decide whether this should print a sentinel value
127 // such as "<null>" when formatting null strings.
125 inline std::ostream& operator<<(std::ostream& out, const String& s) { 128 inline std::ostream& operator<<(std::ostream& out, const String& s) {
126 return out << s.get(); 129 return out << s.get();
127 } 130 }
128 131
129 inline bool operator<(const String& a, const String& b) { 132 inline bool operator<(const String& a, const String& b) {
130 if (a.is_null()) 133 if (a.is_null())
131 return !b.is_null(); 134 return !b.is_null();
132 if (b.is_null()) 135 if (b.is_null())
133 return false; 136 return false;
134 137
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 169
167 template <> 170 template <>
168 struct TypeConverter<String, const char*> { 171 struct TypeConverter<String, const char*> {
169 // |input| may be null, in which case a null String will be returned. 172 // |input| may be null, in which case a null String will be returned.
170 static String Convert(const char* input) { return String(input); } 173 static String Convert(const char* input) { return String(input); }
171 }; 174 };
172 175
173 } // namespace mojo 176 } // namespace mojo
174 177
175 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ 178 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/map.h ('k') | mojo/public/cpp/bindings/struct_ptr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698