Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
ipc
libmultiprocess
include
mp
type-struct.h
Go to the documentation of this file.
1
// Copyright (c) The Bitcoin Core developers
2
// Distributed under the MIT software license, see the accompanying
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
5
#ifndef MP_PROXY_TYPE_STRUCT_H
6
#define MP_PROXY_TYPE_STRUCT_H
7
8
#include <
mp/util.h
>
9
10
namespace
mp
{
11
template
<
size_t
index,
typename
LocalType,
typename
Value,
typename
Output>
12
void
BuildOne
(
TypeList<LocalType>
param,
13
InvokeContext
& invoke_context,
14
Output&& output,
15
Value&& value,
16
typename
std::enable_if < index<
ProxyType<LocalType>::fields
>::type * enable =
nullptr
)
17
{
18
using
Index = std::integral_constant<size_t, index>;
19
using
Struct =
typename
ProxyType<LocalType>::Struct
;
20
using
Accessor
=
typename
std::tuple_element<index, typename ProxyStruct<Struct>::Accessors>::type;
21
auto
&& field_output =
Make<StructField, Accessor>
(output);
22
auto
&& field_value = value.*
ProxyType<LocalType>::get
(Index());
23
BuildField
(
TypeList
<
Decay
<
decltype
(field_value)>>(), invoke_context, field_output, field_value);
24
BuildOne<index + 1>
(param, invoke_context, output, value);
25
}
26
27
template
<
size_t
index,
typename
LocalType,
typename
Value,
typename
Output>
28
void
BuildOne
(
TypeList<LocalType>
param,
29
InvokeContext
& invoke_context,
30
Output&& output,
31
Value&& value,
32
typename
std::enable_if<index ==
ProxyType<LocalType>::fields
>::type* enable =
nullptr
)
33
{
34
}
35
36
template
<
typename
LocalType,
typename
Value,
typename
Output>
37
void
CustomBuildField
(
TypeList<LocalType>
local_type,
38
Priority<1>
,
39
InvokeContext
& invoke_context,
40
Value&& value,
41
Output&& output,
42
typename
ProxyType<LocalType>::Struct
* enable =
nullptr
)
43
{
44
BuildOne<0>
(local_type, invoke_context, output.init(), value);
45
}
46
47
template
<
size_t
index,
typename
LocalType,
typename
Input,
typename
Value>
48
void
ReadOne
(
TypeList<LocalType>
param,
49
InvokeContext
& invoke_context,
50
Input&& input,
51
Value&& value,
52
typename
std::enable_if<index !=
ProxyType<LocalType>::fields
>::type* enable =
nullptr
)
53
{
54
using
Index = std::integral_constant<size_t, index>;
55
using
Struct =
typename
ProxyType<LocalType>::Struct
;
56
using
Accessor
=
typename
std::tuple_element<index, typename ProxyStruct<Struct>::Accessors>::type;
57
const
auto
& struc = input.get();
58
auto
&& field_value = value.*
ProxyType<LocalType>::get
(Index());
59
ReadField
(
TypeList
<
RemoveCvRef
<
decltype
(field_value)>>(), invoke_context,
Make<StructField, Accessor>
(struc),
60
ReadDestUpdate
(field_value));
61
ReadOne<index + 1>
(param, invoke_context, input, value);
62
}
63
64
template
<
size_t
index,
typename
LocalType,
typename
Input,
typename
Value>
65
void
ReadOne
(
TypeList<LocalType>
param,
66
InvokeContext
& invoke_context,
67
Input& input,
68
Value& value,
69
typename
std::enable_if<index ==
ProxyType<LocalType>::fields
>::type* enable =
nullptr
)
70
{
71
}
72
73
template
<
typename
LocalType,
typename
Input,
typename
ReadDest>
74
decltype
(
auto
)
CustomReadField
(
TypeList<LocalType>
param,
75
Priority<1>
,
76
InvokeContext
& invoke_context,
77
Input&& input,
78
ReadDest&& read_dest,
79
typename
ProxyType<LocalType>::Struct
* enable =
nullptr
)
80
{
81
return
read_dest.update([&](
auto
& value) {
ReadOne<0>
(param, invoke_context, input, value); });
82
}
83
}
// namespace mp
84
85
#endif
// MP_PROXY_TYPE_STRUCT_H
util.h
mp
Functions to serialize / deserialize common bitcoin types.
Definition
common-types.h:57
mp::Decay
std::decay_t< T > Decay
Type helper abbreviating std::decay.
Definition
util.h:86
mp::BuildField
void BuildField(TypeList< LocalTypes... >, Context &context, Output &&output, Values &&... values)
Definition
proxy-types.h:250
mp::BuildOne
void BuildOne(TypeList< LocalType > param, InvokeContext &invoke_context, Output &&output, Value &&value, typename std::enable_if< index< ProxyType< LocalType >::fields >::type *enable=nullptr)
Definition
type-struct.h:12
mp::CustomReadField
decltype(auto) CustomReadField(TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest)
Definition
common-types.h:83
mp::Make
Class< Types..., std::remove_reference_t< Args >... > Make(Args &&... args)
Definition
util.h:46
mp::RemoveCvRef
std::remove_cv_t< std::remove_reference_t< T > > RemoveCvRef
Substitutue for std::remove_cvref_t.
Definition
util.h:82
mp::ReadField
decltype(auto) ReadField(TypeList< LocalTypes... >, InvokeContext &invoke_context, Input &&input, Args &&... args)
Definition
proxy-types.h:213
mp::CustomBuildField
void CustomBuildField(TypeList< LocalType >, Priority< 1 >, InvokeContext &invoke_context, Value &&value, Output &&output)
Definition
common-types.h:63
mp::ReadOne
void ReadOne(TypeList< LocalType > param, InvokeContext &invoke_context, Input &&input, Value &&value, typename std::enable_if< index !=ProxyType< LocalType >::fields >::type *enable=nullptr)
Definition
type-struct.h:48
mp::Accessor
Accessor type holding flags that determine how to access a message field.
Definition
proxy.h:316
mp::InvokeContext
Definition
proxy-io.h:30
mp::Priority
Definition
util.h:109
mp::ProxyType
Mapping from local c++ type to capnp type and traits (specializations are generated by proxy-codegen....
Definition
proxy.h:34
mp::ReadDestUpdate
Definition
proxy-types.h:146
mp::TypeList
Generic utility functions used by capnp code.
Definition
util.h:33
Generated on
for Bitcoin Core by
1.17.0