| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_ |
| 6 #define MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_ |
| 7 |
| 8 namespace mojo { |
| 9 |
| 10 // This must be specialized for any type |T| to be serialized/deserialized as |
| 11 // a mojom union of type |MojomType|. |
| 12 // |
| 13 // Similar to StructTraits, each specialization of UnionTraits implements the |
| 14 // following methods: |
| 15 // 1. Getters for each field in the Mojom type. |
| 16 // 2. Read() method. |
| 17 // 3. [Optional] IsNull() and SetToNull(). |
| 18 // 4. [Optional] SetUpContext() and TearDownContext(). |
| 19 // Please see the documentation of StructTraits for details of these methods. |
| 20 // |
| 21 // Unlike StructTraits, there is one more method to implement: |
| 22 // 5. A static GetTag() method indicating which field is the current active |
| 23 // field for serialization: |
| 24 // |
| 25 // static |MojomType|DataView::Tag GetTag(const T& input); |
| 26 // |
| 27 // During serialization, only the field getter corresponding to this tag |
| 28 // will be called. |
| 29 // |
| 30 template <typename MojomType, typename T> |
| 31 struct UnionTraits; |
| 32 |
| 33 } // namespace mojo |
| 34 |
| 35 #endif // MOJO_PUBLIC_CPP_BINDINGS_UNION_TRAITS_H_ |
| OLD | NEW |