OLD | NEW |
---|---|
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_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_H_ |
7 | 7 |
8 namespace mojo { | 8 namespace mojo { |
9 | 9 |
10 // This must be specialized for any UserType to be serialized/deserialized as | 10 // This must be specialized for any type |T| to be serialized/deserialized as |
11 // a mojom array. | 11 // a mojom array. |
12 // | 12 // |
13 // TODO(yzshen): This is work in progress. Add better documentation once the | 13 // Usually you would like to do a partial specialization for an array/vector |
14 // interface becomes more stable. | 14 // template. Imagine you want to specialize it for CustomArray<>, you need to |
15 template <typename UserType> | 15 // implement: |
16 // | |
17 // template <typename T> | |
18 // struct ArrayTraits<CustomArray<T>> { | |
19 // using Element = T; | |
20 // | |
21 // // This two methods are optional. Please see comments in struct_traits.h | |
Ken Rockot(use gerrit already)
2016/05/13 20:40:46
nit: These two methods
yzshen1
2016/05/13 20:47:43
Thanks! Done.
| |
22 // static bool IsNull(const CustomArray<T>& input); | |
23 // static void SetToNull(CustomArray<T>* output); | |
24 // | |
25 // static size_t GetSize(const CustomArray<T>& input); | |
26 // | |
27 // static T* GetData(CustomArray<T>& input); | |
28 // static const T* GetData(const CustomArray<T>& input); | |
29 // | |
30 // static T& GetAt(CustomArray<T>& input, size_t index); | |
31 // static const T& GetAt(const CustomArray<T>& input, size_t index); | |
32 // | |
33 // static void Resize(CustomArray<T>& input, size_t size); | |
34 // }; | |
35 // | |
36 template <typename T> | |
16 struct ArrayTraits; | 37 struct ArrayTraits; |
17 | 38 |
18 } // namespace mojo | 39 } // namespace mojo |
19 | 40 |
20 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_H_ | 41 #endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_H_ |
OLD | NEW |