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 <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
| 10 #include <functional> |
10 #include <string> | 11 #include <string> |
11 | 12 |
12 #include "base/logging.h" | 13 #include "base/logging.h" |
13 #include "mojo/public/cpp/bindings/lib/array_internal.h" | 14 #include "mojo/public/cpp/bindings/lib/array_internal.h" |
14 #include "mojo/public/cpp/bindings/type_converter.h" | 15 #include "mojo/public/cpp/bindings/type_converter.h" |
15 | 16 |
16 namespace mojo { | 17 namespace mojo { |
17 | 18 |
18 // A UTF-8 encoded character string that can be null. Provides functions that | 19 // A UTF-8 encoded character string that can be null. Provides functions that |
19 // are similar to std::string, along with access to the underlying std::string | 20 // are similar to std::string, along with access to the underlying std::string |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 }; | 187 }; |
187 | 188 |
188 template <> | 189 template <> |
189 struct TypeConverter<String, const char*> { | 190 struct TypeConverter<String, const char*> { |
190 // |input| may be null, in which case a null String will be returned. | 191 // |input| may be null, in which case a null String will be returned. |
191 static String Convert(const char* input) { return String(input); } | 192 static String Convert(const char* input) { return String(input); } |
192 }; | 193 }; |
193 | 194 |
194 } // namespace mojo | 195 } // namespace mojo |
195 | 196 |
| 197 namespace std { |
| 198 |
| 199 template <> |
| 200 struct hash<mojo::String> { |
| 201 size_t operator()(const mojo::String& value) const { |
| 202 return hash<std::string>()(value.get()); |
| 203 } |
| 204 }; |
| 205 |
| 206 } // namespace std |
| 207 |
196 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ | 208 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRING_H_ |
OLD | NEW |