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

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

Issue 2511883006: Mojo C++ bindings: switch services/ui/public/interfaces mojom target to use STL types. (Closed)
Patch Set: . Created 4 years, 1 month 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 | « no previous file | services/ui/public/cpp/tests/test_window_tree.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_MAP_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 #include <map> 9 #include <map>
10 #include <unordered_map> 10 #include <unordered_map>
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 for (auto it = input.begin(); it != input.end(); ++it) { 292 for (auto it = input.begin(); it != input.end(); ++it) {
293 result.insert(std::make_pair( 293 result.insert(std::make_pair(
294 TypeConverter<STLKey, MojoKey>::Convert(it->first), 294 TypeConverter<STLKey, MojoKey>::Convert(it->first),
295 TypeConverter<STLValue, MojoValue>::Convert(it->second))); 295 TypeConverter<STLValue, MojoValue>::Convert(it->second)));
296 } 296 }
297 } 297 }
298 return result; 298 return result;
299 } 299 }
300 }; 300 };
301 301
302 // TODO(yzshen): These conversion functions should be removed and callsites
303 // should be revisited and changed to use the same map type.
304 template <typename Key, typename Value>
305 std::unordered_map<Key, Value> MapToUnorderedMap(
306 const std::map<Key, Value>& input) {
307 return std::unordered_map<Key, Value>(input.begin(), input.end());
308 }
309
310 template <typename Key, typename Value>
311 std::unordered_map<Key, Value> MapToUnorderedMap(std::map<Key, Value>&& input) {
312 return std::unordered_map<Key, Value>(std::make_move_iterator(input.begin()),
313 std::make_move_iterator(input.end()));
314 }
315
316 template <typename Key, typename Value>
317 std::map<Key, Value> UnorderedMapToMap(
318 const std::unordered_map<Key, Value>& input) {
319 return std::map<Key, Value>(input.begin(), input.end());
320 }
321
322 template <typename Key, typename Value>
323 std::map<Key, Value> UnorderedMapToMap(std::unordered_map<Key, Value>&& input) {
324 return std::map<Key, Value>(std::make_move_iterator(input.begin()),
325 std::make_move_iterator(input.end()));
326 }
327
302 } // namespace mojo 328 } // namespace mojo
303 329
304 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ 330 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
OLDNEW
« no previous file with comments | « no previous file | services/ui/public/cpp/tests/test_window_tree.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698