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

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

Issue 646773005: mojo: Switch the clipboard interface over to using map<>. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: vtl nits + operator[] Created 6 years, 2 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
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 <map> 8 #include <map>
9 9
10 #include "mojo/public/cpp/bindings/lib/map_internal.h" 10 #include "mojo/public/cpp/bindings/lib/map_internal.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 void insert(KeyForwardType key, ValueForwardType value) { 81 void insert(KeyForwardType key, ValueForwardType value) {
82 is_null_ = false; 82 is_null_ = false;
83 Traits::Insert(&map_, key, value); 83 Traits::Insert(&map_, key, value);
84 } 84 }
85 85
86 ValueRefType at(KeyForwardType key) { return Traits::at(&map_, key); } 86 ValueRefType at(KeyForwardType key) { return Traits::at(&map_, key); }
87 ValueConstRefType at(KeyForwardType key) const { 87 ValueConstRefType at(KeyForwardType key) const {
88 return Traits::at(&map_, key); 88 return Traits::at(&map_, key);
89 } 89 }
90 90
91 ValueRefType operator[](KeyForwardType key) {
92 return Traits::Index(&map_, key);
93 }
94
91 void Swap(Map<Key, Value>* other) { 95 void Swap(Map<Key, Value>* other) {
92 std::swap(is_null_, other->is_null_); 96 std::swap(is_null_, other->is_null_);
93 map_.swap(other->map_); 97 map_.swap(other->map_);
94 } 98 }
95 void Swap(std::map<Key, Value>* other) { 99 void Swap(std::map<Key, Value>* other) {
96 is_null_ = false; 100 is_null_ = false;
97 map_.swap(*other); 101 map_.swap(*other);
98 } 102 }
99 103
100 // This moves all values in the map to a set of parallel arrays. This action 104 // This moves all values in the map to a set of parallel arrays. This action
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 TypeConverter<STLValue, MojoValue>::Convert(it.GetValue()))); 220 TypeConverter<STLValue, MojoValue>::Convert(it.GetValue())));
217 } 221 }
218 } 222 }
219 return result; 223 return result;
220 } 224 }
221 }; 225 };
222 226
223 } // namespace mojo 227 } // namespace mojo
224 228
225 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_ 229 #endif // MOJO_PUBLIC_CPP_BINDINGS_MAP_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698