OLD | NEW |
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 Loading... |
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 Loading... |
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_ |
OLD | NEW |