Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
ipc
libmultiprocess
include
mp
type-tuple.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_TUPLE_H
6
#define MP_PROXY_TYPE_TUPLE_H
7
8
#include <
mp/util.h
>
9
10
namespace
mp
{
11
// TODO: Should generalize this to work with arbitrary length tuples, not just length 2-tuples.
12
template
<
typename
KeyLocalType,
typename
ValueLocalType,
typename
Value,
typename
Output>
13
void
CustomBuildField
(
TypeList
<std::tuple<KeyLocalType, ValueLocalType>>,
14
Priority<1>
,
15
InvokeContext
& invoke_context,
16
Value&& value,
17
Output&& output)
18
{
19
auto
pair = output.init();
20
using
Accessors =
typename
ProxyStruct
<
typename
decltype
(pair)::Builds>::Accessors;
21
BuildField
(
TypeList<KeyLocalType>
(), invoke_context,
Make
<
StructField
, std::tuple_element_t<0, Accessors>>(pair), std::get<0>(value));
22
BuildField
(
TypeList<ValueLocalType>
(), invoke_context,
Make
<
StructField
, std::tuple_element_t<1, Accessors>>(pair), std::get<1>(value));
23
}
24
25
// TODO: Should generalize this to work with arbitrary length tuples, not just length 2-tuples.
26
template
<
typename
KeyLocalType,
typename
ValueLocalType,
typename
Input,
typename
ReadDest>
27
decltype
(
auto
)
CustomReadField
(
TypeList
<std::tuple<KeyLocalType, ValueLocalType>>,
28
Priority<1>
,
29
InvokeContext
& invoke_context,
30
Input&& input,
31
ReadDest&& read_dest)
32
{
33
return
read_dest.update([&](
auto
& value) {
34
const
auto
& pair = input.get();
35
using
Struct =
ProxyStruct
<
typename
Decay
<
decltype
(pair)>::Reads>;
36
using
Accessors =
typename
Struct::Accessors;
37
ReadField
(
TypeList<KeyLocalType>
(), invoke_context,
Make
<
StructField
, std::tuple_element_t<0, Accessors>>(pair),
38
ReadDestUpdate
(std::get<0>(value)));
39
ReadField
(
TypeList<ValueLocalType>
(), invoke_context,
Make
<
StructField
, std::tuple_element_t<1, Accessors>>(pair),
40
ReadDestUpdate
(std::get<1>(value)));
41
});
42
}
43
}
// namespace mp
44
45
#endif
// MP_PROXY_TYPE_TUPLE_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::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::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::InvokeContext
Definition
proxy-io.h:30
mp::Priority
Definition
util.h:109
mp::ProxyStruct
Mapping from capnp struct type to struct traits (specializations are generated by proxy-codegen....
Definition
proxy.h:32
mp::ReadDestUpdate
Definition
proxy-types.h:146
mp::StructField
Definition
proxy-types.h:34
mp::TypeList
Generic utility functions used by capnp code.
Definition
util.h:33
Generated on
for Bitcoin Core by
1.17.0