Bond
 
Loading...
Searching...
No Matches
tags.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <bond/core/config.h>
7
8#include "nonassignable.h"
9
10#include <bond/core/bond_const_enum.h>
11
12#include <type_traits>
13
14namespace bond
15{
16
17struct Metadata;
18
19// Used to get qualified name of enum using generated GetTypeName
20struct qualified_name_tag
21{};
22
23
24BOND_STATIC_CONSTEXPR qualified_name_tag qualified_name = {};
25
26
27// A serializing transform accepts fields of a structure
28struct serializing_transform_tag
29{};
30
31
32// A deserializing transform accepts fields from serialized payload
33struct deserializing_transform_tag
34{};
35
36
37// A modifying transform gets non-const access to struct fields
38struct modifying_transform_tag
39{};
40
41
42struct Transform
43 : detail::nonassignable
44{
45 bool OmittedField(uint16_t /*id*/, const Metadata& /*metadata*/, BondDataType /*type*/) const
46 {
47 return false;
48 }
49
50 template <typename Field>
51 bool OmittedField(const Field&) const
52 {
53 return false;
54 }
55};
56
57
60 : Transform
61{
62 typedef serializing_transform_tag transform_category;
63};
64
65
68 : Transform
69{
70 typedef deserializing_transform_tag transform_category;
71};
72
73
76 : Transform
77{
78 typedef modifying_transform_tag transform_category;
79};
80
81
82template <typename T, typename Unused = void> struct
83is_serializing_transform
84 : std::is_base_of<SerializingTransform, T> {};
85
86
87template <typename T, typename Unused = void> struct
88is_deserializing_transform
89 : std::is_base_of<DeserializingTransform, T> {};
90
91
92template <typename T, typename Unused = void> struct
93is_modifying_transform
94 : std::is_base_of<ModifyingTransform, T> {};
95
96
97} // namespace bond
namespace bond
Definition: apply.h:17
Base class for deserializing transforms.
Definition: tags.h:69
Base class for transforms which modify a Bond type instance.
Definition: tags.h:77
Base class for serializing transforms.
Definition: tags.h:61