Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
ipc
libmultiprocess
include
mp
type-vector.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_VECTOR_H
6
#define MP_PROXY_TYPE_VECTOR_H
7
8
#include <
mp/proxy-types.h
>
9
#include <
mp/util.h
>
10
11
namespace
mp
{
12
template
<
typename
LocalType,
typename
Value,
typename
Output>
13
void
CustomBuildField
(
TypeList
<std::vector<LocalType>>,
14
Priority<1>
,
15
InvokeContext
& invoke_context,
16
Value&& value,
17
Output&& output)
18
{
19
// FIXME dedup with set handler below
20
auto
list = output.init(value.size());
21
size_t
i = 0;
22
for
(
auto
it = value.begin(); it != value.end(); ++it, ++i) {
23
BuildField
(
TypeList<LocalType>
(), invoke_context,
ListOutput
<
typename
decltype
(list)::Builds>(list, i), *it);
24
}
25
}
26
27
inline
static
bool
BuildPrimitive
(
InvokeContext
& invoke_context, std::vector<bool>::const_reference value,
TypeList<bool>
)
28
{
29
return
value;
30
}
31
32
template
<
typename
LocalType,
typename
Input,
typename
ReadDest>
33
decltype
(
auto
)
CustomReadField
(
TypeList
<std::vector<LocalType>>,
34
Priority<1>
,
35
InvokeContext
& invoke_context,
36
Input&& input,
37
ReadDest&& read_dest)
38
{
39
return
read_dest.update([&](
auto
& value) {
40
auto
data = input.get();
41
value.clear();
42
value.reserve(data.size());
43
for
(
auto
item : data) {
44
ReadField
(
TypeList<LocalType>
(), invoke_context,
Make<ValueField>
(item),
45
ReadDestEmplace
(
TypeList<LocalType>
(), [&](
auto
&&...
args
) ->
auto
& {
46
value.emplace_back(std::forward<
decltype
(
args
)>(
args
)...);
47
return
value.back();
48
}));
49
}
50
});
51
}
52
53
template
<
typename
Input,
typename
ReadDest>
54
decltype
(
auto
)
CustomReadField
(
TypeList
<std::vector<bool>>,
55
Priority<1>
,
56
InvokeContext
& invoke_context,
57
Input&& input,
58
ReadDest&& read_dest)
59
{
60
return
read_dest.update([&](
auto
& value) {
61
auto
data = input.get();
62
value.clear();
63
value.reserve(data.size());
64
for
(
auto
item : data) {
65
value.push_back(
ReadField
(
TypeList<bool>
(), invoke_context,
Make<ValueField>
(item),
ReadDestTemp<bool>
()));
66
}
67
});
68
}
69
}
// namespace mp
70
71
#endif
// MP_PROXY_TYPE_VECTOR_H
args
ArgsManager & args
Definition
bitcoind.cpp:277
util.h
mp
Functions to serialize / deserialize common bitcoin types.
Definition
common-types.h:57
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::BuildPrimitive
LocalType BuildPrimitive(InvokeContext &invoke_context, const Value &value, TypeList< LocalType >, typename std::enable_if< std::is_enum< Value >::value >::type *enable=nullptr)
Definition
type-number.h:12
mp::Make
Class< Types..., std::remove_reference_t< Args >... > Make(Args &&... args)
Definition
util.h:46
mp::ReadDestTemp
auto ReadDestTemp()
Definition
proxy-types.h:133
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
proxy-types.h
mp::InvokeContext
Definition
proxy-io.h:30
mp::ListOutput
Definition
proxy-types.h:264
mp::Priority
Definition
util.h:109
mp::ReadDestEmplace
Definition
proxy-types.h:95
mp::TypeList
Generic utility functions used by capnp code.
Definition
util.h:33
Generated on
for Bitcoin Core by
1.17.0