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 5
5
file (READ ${JSON_SOURCE_PATH} hex_content HEX )
6
6
string (REGEX MATCHALL "([A-Za-z0-9][A-Za-z0-9])" bytes "${hex_content} " )
7
7
8
- file (WRITE ${HEADER_PATH} "#include <string >\n " )
8
+ file (WRITE ${HEADER_PATH} "#include <string_view >\n " )
9
9
file (APPEND ${HEADER_PATH} "namespace json_tests{\n " )
10
10
get_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 " )
12
12
13
13
set (i 0 )
14
14
foreach (byte ${bytes} )
@@ -21,4 +21,6 @@ foreach(byte ${bytes})
21
21
endif ()
22
22
endforeach ()
23
23
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
2
2
// Distributed under the MIT software license, see the accompanying
3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#include < test/util/json.h>
6
6
7
- #include < string >
7
+ #include < univalue.h >
8
8
#include < util/check.h>
9
9
10
- #include < univalue.h >
10
+ #include < string_view >
11
11
12
- UniValue read_json (const std::string& jsondata)
12
+ UniValue read_json (std::string_view jsondata)
13
13
{
14
14
UniValue v;
15
15
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
2
2
// Distributed under the MIT software license, see the accompanying
3
3
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
4
5
5
#ifndef BITCOIN_TEST_UTIL_JSON_H
6
6
#define BITCOIN_TEST_UTIL_JSON_H
7
7
8
- #include < string>
9
-
10
8
#include < univalue.h>
11
9
12
- UniValue read_json (const std::string& jsondata);
10
+ #include < string_view>
11
+
12
+ UniValue read_json (std::string_view jsondata);
13
13
14
14
#endif // BITCOIN_TEST_UTIL_JSON_H
You can’t perform that action at this time.
0 commit comments