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

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

Issue 2226853002: Mojo C++ bindings: add support for UnionTraits. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@85_10_inline_more
Patch Set: . Created 4 years, 4 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
(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_
OLDNEW
« no previous file with comments | « mojo/public/cpp/bindings/lib/serialization_forward.h ('k') | mojo/public/tools/bindings/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698