OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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_STRUCT_TRAITS_H_ | 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_ |
6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_ | 6 #define MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_ |
7 | 7 |
8 namespace mojo { | 8 namespace mojo { |
9 | 9 |
10 // This must be specialized for any type |T| to be serialized/deserialized as | 10 // This must be specialized for any type |T| to be serialized/deserialized as |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 // | 48 // |
49 // Getters for fields of other types are called once. | 49 // Getters for fields of other types are called once. |
50 // | 50 // |
51 // 2. A static Read() method to set the contents of a |T| instance from a | 51 // 2. A static Read() method to set the contents of a |T| instance from a |
52 // |MojomType|DataView (e.g., if |MojomType| is test::Example, the data | 52 // |MojomType|DataView (e.g., if |MojomType| is test::Example, the data |
53 // view will be test::ExampleDataView). | 53 // view will be test::ExampleDataView). |
54 // | 54 // |
55 // static bool Read(|MojomType|DataView data, T* output); | 55 // static bool Read(|MojomType|DataView data, T* output); |
56 // | 56 // |
57 // The generated |MojomType|DataView type provides a convenient, | 57 // The generated |MojomType|DataView type provides a convenient, |
58 // inexpensive view of a serialized struct's field data. | 58 // inexpensive view of a serialized struct's field data. The caller |
| 59 // guarantees that |!data.is_null()|. |
59 // | 60 // |
60 // Returning false indicates invalid incoming data and causes the message | 61 // Returning false indicates invalid incoming data and causes the message |
61 // pipe receiving it to be disconnected. Therefore, you can do custom | 62 // pipe receiving it to be disconnected. Therefore, you can do custom |
62 // validation for |T| in this method. | 63 // validation for |T| in this method. |
63 // | 64 // |
64 // 3. [Optional] A static IsNull() method indicating whether a given |T| | 65 // 3. [Optional] A static IsNull() method indicating whether a given |T| |
65 // instance is null: | 66 // instance is null: |
66 // | 67 // |
67 // static bool IsNull(const T& input); | 68 // static bool IsNull(const T& input); |
68 // | 69 // |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
143 // | 144 // |
144 // static bool Read(FooDataView data, CustomFoo* output); | 145 // static bool Read(FooDataView data, CustomFoo* output); |
145 // }; | 146 // }; |
146 // | 147 // |
147 template <typename MojomType, typename T> | 148 template <typename MojomType, typename T> |
148 struct StructTraits; | 149 struct StructTraits; |
149 | 150 |
150 } // namespace mojo | 151 } // namespace mojo |
151 | 152 |
152 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_ | 153 #endif // MOJO_PUBLIC_CPP_BINDINGS_STRUCT_TRAITS_H_ |
OLD | NEW |