Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
ipc
libmultiprocess
include
mp
type-optional.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_OPTIONAL_H
6
#define MP_PROXY_TYPE_OPTIONAL_H
7
8
#include <
mp/util.h
>
9
10
namespace
mp
{
11
template
<
typename
LocalType,
typename
Value,
typename
Output>
12
void
CustomBuildField
(
TypeList
<std::optional<LocalType>>,
13
Priority<1>
,
14
InvokeContext
& invoke_context,
15
Value&& value,
16
Output&& output)
17
{
18
if
(value) {
19
output.setHas();
20
BuildField
(
TypeList<LocalType>
(), invoke_context, output, *std::forward<Value>(value));
21
}
22
}
23
24
template
<
typename
LocalType,
typename
Input,
typename
ReadDest>
25
decltype
(
auto
)
CustomReadField
(
TypeList
<std::optional<LocalType>>,
26
Priority<1>
,
27
InvokeContext
& invoke_context,
28
Input&& input,
29
ReadDest&& read_dest)
30
{
31
return
read_dest.update([&](
auto
& value) {
32
if
(!
CustomHasField
(
TypeList<LocalType>
(), invoke_context, input)) {
33
value.reset();
34
}
else
if
(value) {
35
ReadField
(
TypeList<LocalType>
(), invoke_context, input,
ReadDestUpdate
(*value));
36
}
else
{
37
ReadField
(
TypeList<LocalType>
(), invoke_context, input,
38
ReadDestEmplace
(
TypeList<LocalType>
(), [&](
auto
&&...
args
) ->
auto
& {
39
value.emplace(std::forward<
decltype
(
args
)>(
args
)...);
40
return
*value;
41
}));
42
}
43
});
44
}
45
}
// namespace mp
46
47
#endif
// MP_PROXY_TYPE_OPTIONAL_H
args
ArgsManager & args
Definition
bitcoind.cpp:277
util.h
mp
Functions to serialize / deserialize common bitcoin types.
Definition
common-types.h:57
mp::CustomHasField
bool CustomHasField(TypeList< LocalTypes... >, InvokeContext &invoke_context, const Input &input)
Definition
proxy-types.h:207
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::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::ReadDestEmplace
Definition
proxy-types.h:95
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