Bitcoin Core
31.1.0
P2P Digital Currency
Toggle main menu visibility
Loading...
Searching...
No Matches
src
ipc
libmultiprocess
test
mp
test
foo-types.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_TEST_FOO_TYPES_H
6
#define MP_TEST_FOO_TYPES_H
7
8
#include <
mp/proxy.h
>
9
#include <
mp/proxy-types.h
>
10
11
// IWYU pragma: begin_exports
12
#include <capnp/common.h>
13
#include <cstddef>
14
#include <mp/test/foo.capnp.h>
15
#include <
mp/type-context.h
>
16
#include <
mp/type-data.h
>
17
#include <
mp/type-decay.h
>
18
#include <
mp/type-function.h
>
19
#include <
mp/type-interface.h
>
20
#include <
mp/type-map.h
>
21
#include <
mp/type-message.h
>
22
#include <
mp/type-number.h
>
23
#include <
mp/type-pointer.h
>
24
#include <
mp/type-set.h
>
25
#include <
mp/type-string.h
>
26
#include <
mp/type-struct.h
>
27
#include <
mp/type-threadmap.h
>
28
#include <
mp/type-vector.h
>
29
#include <string>
30
#include <type_traits>
31
// IWYU pragma: end_exports
32
33
namespace
mp
{
34
namespace
test
{
35
namespace
messages
{
36
struct
ExtendedCallback
;
// IWYU pragma: export
37
struct
FooCallback
;
// IWYU pragma: export
38
struct
FooFn;
// IWYU pragma: export
39
struct
FooInterface;
// IWYU pragma: export
40
}
// namespace messages
41
42
template
<
typename
Output>
43
void
CustomBuildField
(
TypeList<FooCustom>
,
Priority<1>
,
InvokeContext
& invoke_context,
const
FooCustom
& value, Output&& output)
44
{
45
BuildField
(
TypeList<std::string>
(), invoke_context, output, value.
v1
);
46
output.setV2(value.
v2
);
47
}
48
49
template
<
typename
Input,
typename
ReadDest>
50
decltype
(
auto
)
CustomReadField
(
TypeList<FooCustom>
,
Priority<1>
,
InvokeContext
& invoke_context, Input&& input, ReadDest&& read_dest)
51
{
52
messages::FooCustom::Reader custom = input.get();
53
return
read_dest.update([&](
FooCustom
& value) {
54
value.
v1
=
ReadField
(
TypeList<std::string>
(), invoke_context,
mp::Make<mp::ValueField>
(custom.getV1()),
ReadDestTemp<std::string>
());
55
value.
v2
= custom.getV2();
56
});
57
}
58
59
}
// namespace test
60
61
template
<
typename
Input>
62
bool
CustomHasField
(
TypeList<test::FooData>
,
InvokeContext
& invoke_context,
const
Input& input)
63
{
64
// Cap'n Proto C++ cannot distinguish null vs empty Data in List(Data), so
65
// interpret empty Data as null for this specific type.
66
return
input.get().size() != 0;
67
}
68
69
inline
void
CustomBuildMessage
(
InvokeContext
& invoke_context,
70
const
test::FooMessage
& src,
71
test::messages::FooMessage::Builder&& builder)
72
{
73
builder.setMessage(src.
message
+
" build"
);
74
}
75
76
inline
void
CustomReadMessage
(
InvokeContext
& invoke_context,
77
const
test::messages::FooMessage::Reader& reader,
78
test::FooMessage
& dest)
79
{
80
dest.
message
= std::string{reader.getMessage()} +
" read"
;
81
}
82
83
inline
void
CustomBuildMessage
(
InvokeContext
& invoke_context,
84
const
test::FooMutable
& src,
85
test::messages::FooMutable::Builder&& builder)
86
{
87
builder.setMessage(src.
message
+
" build"
);
88
}
89
90
inline
void
CustomReadMessage
(
InvokeContext
& invoke_context,
91
const
test::messages::FooMutable::Reader& reader,
92
test::FooMutable
& dest)
93
{
94
dest.
message
= std::string{reader.getMessage()} +
" read"
;
95
}
96
97
inline
void
CustomPassMessage
(
InvokeContext
& invoke_context,
98
const
test::messages::FooMutable::Reader& reader,
99
test::messages::FooMutable::Builder builder,
100
std::function<
void
(
test::FooMutable
&)>&& fn)
101
{
102
test::FooMutable
mut;
103
mut.
message
= std::string{reader.getMessage()} +
" pass"
;
104
fn(mut);
105
builder.setMessage(mut.
message
+
" return"
);
106
}
107
}
// namespace mp
108
109
#endif
// MP_TEST_FOO_TYPES_H
mp::test::ExtendedCallback
Definition
foo.h:59
mp::test::FooCallback
Definition
foo.h:52
mp::test::messages
Definition
foo-types.h:35
mp::test
Definition
foo-types.h:34
mp::test::CustomBuildField
void CustomBuildField(TypeList< FooCustom >, Priority< 1 >, InvokeContext &invoke_context, const FooCustom &value, Output &&output)
Definition
foo-types.h:43
mp::test::CustomReadField
decltype(auto) CustomReadField(TypeList< FooCustom >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest)
Definition
foo-types.h:50
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::CustomPassMessage
void CustomPassMessage(InvokeContext &invoke_context, const test::messages::FooMutable::Reader &reader, test::messages::FooMutable::Builder builder, std::function< void(test::FooMutable &)> &&fn)
Definition
foo-types.h:97
mp::BuildField
void BuildField(TypeList< LocalTypes... >, Context &context, Output &&output, Values &&... values)
Definition
proxy-types.h:250
mp::CustomBuildMessage
void CustomBuildMessage(InvokeContext &invoke_context, const test::FooMessage &src, test::messages::FooMessage::Builder &&builder)
Definition
foo-types.h:69
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::CustomReadMessage
void CustomReadMessage(InvokeContext &invoke_context, const test::messages::FooMessage::Reader &reader, test::FooMessage &dest)
Definition
foo-types.h:76
mp::ReadField
decltype(auto) ReadField(TypeList< LocalTypes... >, InvokeContext &invoke_context, Input &&input, Args &&... args)
Definition
proxy-types.h:213
proxy-types.h
proxy.h
mp::InvokeContext
Definition
proxy-io.h:30
mp::Priority
Definition
util.h:109
mp::TypeList
Generic utility functions used by capnp code.
Definition
util.h:33
mp::test::FooCustom
Definition
foo.h:29
mp::test::FooCustom::v2
int v2
Definition
foo.h:31
mp::test::FooCustom::v1
std::string v1
Definition
foo.h:30
mp::test::FooMessage
Definition
foo.h:39
mp::test::FooMessage::message
std::string message
Definition
foo.h:40
mp::test::FooMutable
Definition
foo.h:44
mp::test::FooMutable::message
std::string message
Definition
foo.h:45
type-context.h
type-data.h
type-decay.h
type-function.h
type-interface.h
type-map.h
type-message.h
type-number.h
type-pointer.h
type-set.h
type-string.h
type-struct.h
type-threadmap.h
type-vector.h
Generated on
for Bitcoin Core by
1.17.0