@@ -5275,7 +5275,6 @@ NLOHMANN_JSON_NAMESPACE_END
5275
5275
5276
5276
#include <cstddef> // size_t
5277
5277
#include <iterator> // forward_iterator_tag
5278
- #include <string> // string, to_string
5279
5278
#include <tuple> // tuple_size, get, tuple_element
5280
5279
#include <utility> // move
5281
5280
@@ -5287,20 +5286,53 @@ NLOHMANN_JSON_NAMESPACE_END
5287
5286
5288
5287
// #include <nlohmann/detail/meta/type_traits.hpp>
5289
5288
5290
- // #include <nlohmann/detail/value_t.hpp>
5289
+ // #include <nlohmann/detail/string_utils.hpp>
5290
+ // __ _____ _____ _____
5291
+ // __| | __| | | | JSON for Modern C++
5292
+ // | | |__ | | | | | | version 3.11.3
5293
+ // |_____|_____|_____|_|___| https://github.com/nlohmann/json
5294
+ //
5295
+ // SPDX-FileCopyrightText: 2013 - 2024 Niels Lohmann <https://nlohmann.me>
5296
+ // SPDX-License-Identifier: MIT
5297
+
5298
+
5299
+
5300
+ #include <cstddef> // size_t
5301
+ #include <string> // string, to_string
5302
+
5303
+ // #include <nlohmann/detail/abi_macros.hpp>
5291
5304
5292
5305
5293
5306
NLOHMANN_JSON_NAMESPACE_BEGIN
5294
5307
namespace detail
5295
5308
{
5296
5309
5297
- template<typename string_type >
5298
- void int_to_string( string_type & target, std::size_t value )
5310
+ template<typename StringType >
5311
+ void int_to_string(StringType & target, std::size_t value)
5299
5312
{
5300
5313
// For ADL
5301
5314
using std::to_string;
5302
5315
target = to_string(value);
5303
5316
}
5317
+
5318
+ template<typename StringType>
5319
+ StringType to_string(std::size_t value)
5320
+ {
5321
+ StringType result;
5322
+ int_to_string(result, value);
5323
+ return result;
5324
+ }
5325
+
5326
+ } // namespace detail
5327
+ NLOHMANN_JSON_NAMESPACE_END
5328
+
5329
+ // #include <nlohmann/detail/value_t.hpp>
5330
+
5331
+
5332
+ NLOHMANN_JSON_NAMESPACE_BEGIN
5333
+ namespace detail
5334
+ {
5335
+
5304
5336
template<typename IteratorType> class iteration_proxy_value
5305
5337
{
5306
5338
public:
@@ -15125,6 +15157,8 @@ NLOHMANN_JSON_NAMESPACE_END
15125
15157
15126
15158
// #include <nlohmann/detail/string_escape.hpp>
15127
15159
15160
+ // #include <nlohmann/detail/string_utils.hpp>
15161
+
15128
15162
// #include <nlohmann/detail/meta/cpp_future.hpp>
15129
15163
15130
15164
// #include <nlohmann/detail/meta/type_traits.hpp>
@@ -24249,7 +24283,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24249
24283
// the valid JSON Patch operations
24250
24284
enum class patch_operations {add, remove, replace, move, copy, test, invalid};
24251
24285
24252
- const auto get_op = [](const std::string & op)
24286
+ const auto get_op = [](const string_t & op)
24253
24287
{
24254
24288
if (op == "add")
24255
24289
{
@@ -24386,8 +24420,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24386
24420
for (const auto& val : json_patch)
24387
24421
{
24388
24422
// wrapper to get a value for an operation
24389
- const auto get_value = [&val](const std::string & op,
24390
- const std::string & member,
24423
+ const auto get_value = [&val](const string_t & op,
24424
+ const string_t & member,
24391
24425
bool string_type) -> basic_json &
24392
24426
{
24393
24427
// find value
@@ -24421,8 +24455,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24421
24455
}
24422
24456
24423
24457
// collect mandatory members
24424
- const auto op = get_value("op", "op", true).template get<std::string >();
24425
- const auto path = get_value(op, "path", true).template get<std::string >();
24458
+ const auto op = get_value("op", "op", true).template get<string_t >();
24459
+ const auto path = get_value(op, "path", true).template get<string_t >();
24426
24460
json_pointer ptr(path);
24427
24461
24428
24462
switch (get_op(op))
@@ -24448,7 +24482,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24448
24482
24449
24483
case patch_operations::move:
24450
24484
{
24451
- const auto from_path = get_value("move", "from", true).template get<std::string >();
24485
+ const auto from_path = get_value("move", "from", true).template get<string_t >();
24452
24486
json_pointer from_ptr(from_path);
24453
24487
24454
24488
// the "from" location must exist - use at()
@@ -24465,7 +24499,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24465
24499
24466
24500
case patch_operations::copy:
24467
24501
{
24468
- const auto from_path = get_value("copy", "from", true).template get<std::string >();
24502
+ const auto from_path = get_value("copy", "from", true).template get<string_t >();
24469
24503
const json_pointer from_ptr(from_path);
24470
24504
24471
24505
// the "from" location must exist - use at()
@@ -24525,7 +24559,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24525
24559
/// @sa https://json.nlohmann.me/api/basic_json/diff/
24526
24560
JSON_HEDLEY_WARN_UNUSED_RESULT
24527
24561
static basic_json diff(const basic_json& source, const basic_json& target,
24528
- const std::string & path = "")
24562
+ const string_t & path = "")
24529
24563
{
24530
24564
// the patch
24531
24565
basic_json result(value_t::array);
@@ -24555,7 +24589,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24555
24589
while (i < source.size() && i < target.size())
24556
24590
{
24557
24591
// recursive call to compare array values at index i
24558
- auto temp_diff = diff(source[i], target[i], detail::concat(path, '/', std ::to_string(i)));
24592
+ auto temp_diff = diff(source[i], target[i], detail::concat<string_t> (path, '/', detail ::to_string<string_t> (i)));
24559
24593
result.insert(result.end(), temp_diff.begin(), temp_diff.end());
24560
24594
++i;
24561
24595
}
@@ -24572,7 +24606,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24572
24606
result.insert(result.begin() + end_index, object(
24573
24607
{
24574
24608
{"op", "remove"},
24575
- {"path", detail::concat(path, '/', std ::to_string(i))}
24609
+ {"path", detail::concat<string_t> (path, '/', detail ::to_string<string_t> (i))}
24576
24610
}));
24577
24611
++i;
24578
24612
}
@@ -24583,7 +24617,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24583
24617
result.push_back(
24584
24618
{
24585
24619
{"op", "add"},
24586
- {"path", detail::concat(path, "/-")},
24620
+ {"path", detail::concat<string_t> (path, "/-")},
24587
24621
{"value", target[i]}
24588
24622
});
24589
24623
++i;
@@ -24598,7 +24632,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24598
24632
for (auto it = source.cbegin(); it != source.cend(); ++it)
24599
24633
{
24600
24634
// escape the key name to be used in a JSON patch
24601
- const auto path_key = detail::concat(path, '/', detail::escape(it.key()));
24635
+ const auto path_key = detail::concat<string_t> (path, '/', detail::escape(it.key()));
24602
24636
24603
24637
if (target.find(it.key()) != target.end())
24604
24638
{
@@ -24622,7 +24656,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
24622
24656
if (source.find(it.key()) == source.end())
24623
24657
{
24624
24658
// found a key that is not in this -> add it
24625
- const auto path_key = detail::concat(path, '/', detail::escape(it.key()));
24659
+ const auto path_key = detail::concat<string_t> (path, '/', detail::escape(it.key()));
24626
24660
result.push_back(
24627
24661
{
24628
24662
{"op", "add"}, {"path", path_key},
0 commit comments