Bitcoin Core
32.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-optional.h
>
24
#include <
mp/type-pointer.h
>
25
#include <
mp/type-set.h
>
26
#include <
mp/type-string.h
>
27
#include <
mp/type-struct.h
>
28
#include <
mp/type-threadmap.h
>
29
#include <
mp/type-unordered-set.h
>
30
#include <
mp/type-vector.h
>
31
#include <string>
32
#include <type_traits>
33
// IWYU pragma: end_exports
34
35
namespace
mp
{
36
namespace
test
{
37
namespace
messages
{
38
struct
ExtendedCallback
;
// IWYU pragma: export
39
struct
FooCallback
;
// IWYU pragma: export
40
struct
FooFn;
// IWYU pragma: export
41
struct
FooInterface;
// IWYU pragma: export
42
}
// namespace messages
43
44
template
<
typename
Output>
45
void
CustomBuildField
(
TypeList<FooCustom>
,
Priority<1>
,
InvokeContext
& invoke_context,
const
FooCustom
& value, Output&& output)
46
{
47
BuildField
(
TypeList<std::string>
(), invoke_context, output, value.
v1
);
48
output.setV2(value.
v2
);
49
}
50
51
template
<
typename
Input,
typename
ReadDest>
52
decltype
(
auto
)
CustomReadField
(
TypeList<FooCustom>
,
Priority<1>
,
InvokeContext
& invoke_context, Input&& input, ReadDest&& read_dest)
53
{
54
messages::FooCustom::Reader custom = input.get();
55
return
read_dest.update([&](
FooCustom
& value) {
56
value.
v1
=
ReadField
(
TypeList<std::string>
(), invoke_context,
mp::Make<mp::ValueField>
(custom.getV1()),
ReadDestTemp<std::string>
());
57
value.
v2
= custom.getV2();
58
});
59
}
60
61
}
// namespace test
62
63
template
<
typename
Input>
64
bool
CustomHasField
(
TypeList<test::FooData>
,
InvokeContext
& invoke_context,
const
Input& input)
65
{
66
// Cap'n Proto C++ cannot distinguish null vs empty Data in List(Data), so
67
// interpret empty Data as null for this specific type.
68
return
input.get().size() != 0;
69
}
70
71
inline
void
CustomBuildMessage
(
InvokeContext
& invoke_context,
72
const
test::FooMessage
& src,
73
test::messages::FooMessage::Builder&& builder)
74
{
75
builder.setMessage(src.
message
+
" build"
);
76
}
77
78
inline
void
CustomReadMessage
(
InvokeContext
& invoke_context,
79
const
test::messages::FooMessage::Reader&
reader
,
80
test::FooMessage
& dest)
81
{
82
dest.
message
= std::string{
reader
.getMessage()} +
" read"
;
83
}
84
85
inline
void
CustomBuildMessage
(
InvokeContext
& invoke_context,
86
const
test::FooMutable
& src,
87
test::messages::FooMutable::Builder&& builder)
88
{
89
builder.setMessage(src.
message
+
" build"
);
90
}
91
92
inline
void
CustomReadMessage
(
InvokeContext
& invoke_context,
93
const
test::messages::FooMutable::Reader&
reader
,
94
test::FooMutable
& dest)
95
{
96
dest.
message
= std::string{
reader
.getMessage()} +
" read"
;
97
}
98
99
inline
void
CustomPassMessage
(
InvokeContext
& invoke_context,
100
const
test::messages::FooMutable::Reader&
reader
,
101
test::messages::FooMutable::Builder builder,
102
std::function<
void
(
test::FooMutable
&)>&& fn)
103
{
104
test::FooMutable
mut;
105
mut.
message
= std::string{
reader
.getMessage()} +
" pass"
;
106
fn(mut);
107
builder.setMessage(mut.
message
+
" return"
);
108
}
109
}
// namespace mp
110
111
#endif
// MP_TEST_FOO_TYPES_H
mp::test::ExtendedCallback
Definition
foo.h:64
mp::test::FooCallback
Definition
foo.h:57
reader
LineReader reader("GET / HTTP/1.0\r\nHost: ", MAX_HEADERS_SIZE)
mp::test::messages
Definition
foo-types.h:37
mp::test
Definition
foo-types.h:36
mp::test::CustomBuildField
void CustomBuildField(TypeList< FooCustom >, Priority< 1 >, InvokeContext &invoke_context, const FooCustom &value, Output &&output)
Definition
foo-types.h:45
mp::test::CustomReadField
decltype(auto) CustomReadField(TypeList< FooCustom >, Priority< 1 >, InvokeContext &invoke_context, Input &&input, ReadDest &&read_dest)
Definition
foo-types.h:52
mp
Functions to serialize / deserialize common bitcoin types.
Definition
common-types.h:58
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:99
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:71
mp::Make
Class< Types..., std::remove_reference_t< Args >... > Make(Args &&... args)
Definition
util.h:52
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:78
mp::ReadField
decltype(auto) ReadField(TypeList< LocalTypes... >, InvokeContext &invoke_context, Input &&input, Args &&... args)
Definition
proxy-types.h:213
mp::CustomHasField
bool CustomHasField(TypeList< CTransaction >, InvokeContext &invoke_context, const Input &input)
Definition
common-types.h:141
proxy-types.h
proxy.h
mp::InvokeContext
Definition
proxy-io.h:33
mp::Priority
Definition
util.h:115
mp::TypeList
Generic utility functions used by capnp code.
Definition
util.h:39
mp::test::FooCustom
Definition
foo.h:34
mp::test::FooCustom::v2
int v2
Definition
foo.h:36
mp::test::FooCustom::v1
std::string v1
Definition
foo.h:35
mp::test::FooMessage
Definition
foo.h:44
mp::test::FooMessage::message
std::string message
Definition
foo.h:45
mp::test::FooMutable
Definition
foo.h:49
mp::test::FooMutable::message
std::string message
Definition
foo.h:50
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-optional.h
type-pointer.h
type-set.h
type-string.h
type-struct.h
type-threadmap.h
type-unordered-set.h
type-vector.h
Generated on
for Bitcoin Core by
1.18.0