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

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

Issue 2370643004: Port messages sent by WebIDBFactoryImpl to Mojo. (Closed)
Patch Set: Typemap IndexedDBDatabaseMetadata. Created 4 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_ARRAY_TRAITS_STL_H_ 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_
6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_ 6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_
7 7
8 #include <map>
9 #include <set>
8 #include <vector> 10 #include <vector>
9 11
10 #include "mojo/public/cpp/bindings/array_traits.h" 12 #include "mojo/public/cpp/bindings/array_traits.h"
11 13
12 namespace mojo { 14 namespace mojo {
13 15
14 template <typename T> 16 template <typename T>
15 struct ArrayTraits<std::vector<T>> { 17 struct ArrayTraits<std::vector<T>> {
16 using Element = T; 18 using Element = T;
17 19
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 return input.begin(); 80 return input.begin();
79 } 81 }
80 static void AdvanceIterator(ConstIterator& iterator) { 82 static void AdvanceIterator(ConstIterator& iterator) {
81 ++iterator; 83 ++iterator;
82 } 84 }
83 static const T& GetValue(ConstIterator& iterator) { 85 static const T& GetValue(ConstIterator& iterator) {
84 return *iterator; 86 return *iterator;
85 } 87 }
86 }; 88 };
87 89
90 // This ArrayTraits specialization is used only for serialization.
91 template <typename K, typename V>
92 struct ArrayTraits<std::map<K, V>> {
Ken Rockot(use gerrit already) 2016/10/14 21:50:47 I think this is probably a bit confusing to do. I
Reilly Grant (use Gerrit) 2016/10/15 00:13:42 Done. Let me know if there's a way to make usage o
93 using Element = V;
94 using ConstIterator = typename std::map<K, V>::const_iterator;
95
96 static bool IsNull(const std::map<K, V>& input) {
97 // std::map<> is always converted to non-null mojom array.
98 return false;
99 }
100
101 static size_t GetSize(const std::map<K, V>& input) { return input.size(); }
102
103 static ConstIterator GetBegin(const std::map<K, V>& input) {
104 return input.begin();
105 }
106 static void AdvanceIterator(ConstIterator& iterator) { ++iterator; }
107 static const V& GetValue(ConstIterator& iterator) { return iterator->second; }
108 };
109
88 } // namespace mojo 110 } // namespace mojo
89 111
90 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_ 112 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_STL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698