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_STRING_H
6 : : #define MP_PROXY_TYPE_STRING_H
7 : :
8 : : #include <mp/util.h>
9 : :
10 : : namespace mp {
11 : : template <typename Value, typename Output>
12 [ - + ]: 12 : void CustomBuildField(TypeList<std::string>,
13 : : Priority<1>,
14 : : InvokeContext& invoke_context,
15 : : Value&& value,
16 : : Output&& output)
17 : : {
18 [ - + ]: 12 : auto result = output.init(value.size());
19 : 12 : memcpy(result.begin(), value.data(), value.size());
20 : 12 : }
21 : :
22 : : template <typename Input, typename ReadDest>
23 : 12 : decltype(auto) CustomReadField(TypeList<std::string>,
24 : : Priority<1>,
25 : : InvokeContext& invoke_context,
26 : : Input&& input,
27 : : ReadDest&& read_dest)
28 : : {
29 : 12 : auto data = input.get();
30 : 12 : return read_dest.construct(CharCast(data.begin()), data.size());
31 : : }
32 : : } // namespace mp
33 : :
34 : : #endif // MP_PROXY_TYPE_STRING_H
|