File tree Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Expand file tree Collapse file tree 3 files changed +13
-11
lines changed Original file line number Diff line number Diff line change 55file (READ ${JSON_SOURCE_PATH} hex_content HEX)
66string (REGEX MATCHALL "([A-Za-z0-9][A-Za-z0-9])" bytes "${hex_content} " )
77
8- file (WRITE ${HEADER_PATH} "#include <string >\n " )
8+ file (WRITE ${HEADER_PATH} "#include <string_view >\n " )
99file (APPEND ${HEADER_PATH} "namespace json_tests{\n " )
1010get_filename_component (json_source_basename ${JSON_SOURCE_PATH} NAME_WE )
11- file (APPEND ${HEADER_PATH} "static const std::string ${json_source_basename} {\n " )
11+ file (APPEND ${HEADER_PATH} "inline constexpr char detail_ ${json_source_basename} _bytes[] {\n " )
1212
1313set (i 0)
1414foreach (byte ${bytes} )
@@ -21,4 +21,6 @@ foreach(byte ${bytes})
2121 endif ()
2222endforeach ()
2323
24- file (APPEND ${HEADER_PATH} "\n };};" )
24+ file (APPEND ${HEADER_PATH} "\n };\n " )
25+ file (APPEND ${HEADER_PATH} "inline constexpr std::string_view ${json_source_basename} {std::begin(detail_${json_source_basename} _bytes), std::end(detail_${json_source_basename} _bytes)};" )
26+ file (APPEND ${HEADER_PATH} "\n }" )
Original file line number Diff line number Diff line change 1- // Copyright (c) 2023 The Bitcoin Core developers
1+ // Copyright (c) 2023-present The Bitcoin Core developers
22// Distributed under the MIT software license, see the accompanying
33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#include < test/util/json.h>
66
7- #include < string >
7+ #include < univalue.h >
88#include < util/check.h>
99
10- #include < univalue.h >
10+ #include < string_view >
1111
12- UniValue read_json (const std::string& jsondata)
12+ UniValue read_json (std::string_view jsondata)
1313{
1414 UniValue v;
1515 Assert (v.read (jsondata) && v.isArray ());
Original file line number Diff line number Diff line change 1- // Copyright (c) 2023 The Bitcoin Core developers
1+ // Copyright (c) 2023-present The Bitcoin Core developers
22// Distributed under the MIT software license, see the accompanying
33// file COPYING or http://www.opensource.org/licenses/mit-license.php.
44
55#ifndef BITCOIN_TEST_UTIL_JSON_H
66#define BITCOIN_TEST_UTIL_JSON_H
77
8- #include < string>
9-
108#include < univalue.h>
119
12- UniValue read_json (const std::string& jsondata);
10+ #include < string_view>
11+
12+ UniValue read_json (std::string_view jsondata);
1313
1414#endif // BITCOIN_TEST_UTIL_JSON_H
You can’t perform that action at this time.
0 commit comments