Branch data Line data Source code
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_SET_H
6 : : #define MP_PROXY_TYPE_SET_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 : 0 : void CustomBuildField(TypeList<std::set<LocalType>>,
14 : : Priority<1>,
15 : : InvokeContext& invoke_context,
16 : : Value&& value,
17 : : Output&& output)
18 : : {
19 : : // FIXME dededup with vector handler above
20 : 0 : auto list = output.init(value.size());
21 : 0 : size_t i = 0;
22 [ # # ]: 0 : for (const auto& elem : value) {
23 : 0 : BuildField(TypeList<LocalType>(), invoke_context, ListOutput<typename decltype(list)::Builds>(list, i), elem);
24 : 0 : ++i;
25 : : }
26 : 0 : }
27 : :
28 : : template <typename LocalType, typename Input, typename ReadDest>
29 : 0 : decltype(auto) CustomReadField(TypeList<std::set<LocalType>>,
30 : : Priority<1>,
31 : : InvokeContext& invoke_context,
32 : : Input&& input,
33 : : ReadDest&& read_dest)
34 : : {
35 : 0 : return read_dest.update([&](auto& value) {
36 : 0 : auto data = input.get();
37 : 0 : value.clear();
38 [ # # ]: 0 : for (auto item : data) {
39 : 0 : ReadField(TypeList<LocalType>(), invoke_context, Make<ValueField>(item),
40 : 0 : ReadDestEmplace(TypeList<const LocalType>(), [&](auto&&... args) -> auto& {
41 : 0 : return *value.emplace(std::forward<decltype(args)>(args)...).first;
42 : : }));
43 : : }
44 : 0 : });
45 : : }
46 : : } // namespace mp
47 : :
48 : : #endif // MP_PROXY_TYPE_SET_H
|