Merge 96129bd96d into 7efe875495
This commit is contained in:
commit
96349aee66
@ -71,7 +71,7 @@ class json_pointer
|
||||
string_t{},
|
||||
[](const string_t& a, const string_t& b)
|
||||
{
|
||||
return detail::concat(a, '/', detail::escape(b));
|
||||
return detail::concat<string_t>(a, '/', detail::escape(b));
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -4702,7 +4702,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// the valid JSON Patch operations
|
||||
enum class patch_operations {add, remove, replace, move, copy, test, invalid};
|
||||
|
||||
const auto get_op = [](const std::string & op)
|
||||
const auto get_op = [](const StringType & op)
|
||||
{
|
||||
if (op == "add")
|
||||
{
|
||||
@ -4839,8 +4839,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
for (const auto& val : json_patch)
|
||||
{
|
||||
// wrapper to get a value for an operation
|
||||
const auto get_value = [&val](const std::string & op,
|
||||
const std::string & member,
|
||||
const auto get_value = [&val](const StringType & op,
|
||||
const StringType & member,
|
||||
bool string_type) -> basic_json &
|
||||
{
|
||||
// find value
|
||||
@ -4874,8 +4874,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
}
|
||||
|
||||
// collect mandatory members
|
||||
const auto op = get_value("op", "op", true).template get<std::string>();
|
||||
const auto path = get_value(op, "path", true).template get<std::string>();
|
||||
const auto op = get_value("op", "op", true).template get<StringType>();
|
||||
const auto path = get_value(op, "path", true).template get<StringType>();
|
||||
json_pointer ptr(path);
|
||||
|
||||
switch (get_op(op))
|
||||
@ -4901,7 +4901,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
case patch_operations::move:
|
||||
{
|
||||
const auto from_path = get_value("move", "from", true).template get<std::string>();
|
||||
const auto from_path = get_value("move", "from", true).template get<StringType>();
|
||||
json_pointer from_ptr(from_path);
|
||||
|
||||
// the "from" location must exist - use at()
|
||||
@ -4918,7 +4918,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
case patch_operations::copy:
|
||||
{
|
||||
const auto from_path = get_value("copy", "from", true).template get<std::string>();
|
||||
const auto from_path = get_value("copy", "from", true).template get<StringType>();
|
||||
const json_pointer from_ptr(from_path);
|
||||
|
||||
// the "from" location must exist - use at()
|
||||
@ -4978,7 +4978,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/diff/
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
static basic_json diff(const basic_json& source, const basic_json& target,
|
||||
const std::string& path = "")
|
||||
const StringType& path = "")
|
||||
{
|
||||
// the patch
|
||||
basic_json result(value_t::array);
|
||||
@ -5007,8 +5007,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
std::size_t i = 0;
|
||||
while (i < source.size() && i < target.size())
|
||||
{
|
||||
StringType array_index_str;
|
||||
{
|
||||
using namespace detail;
|
||||
int_to_string(array_index_str, i);
|
||||
}
|
||||
|
||||
// recursive call to compare array values at index i
|
||||
auto temp_diff = diff(source[i], target[i], detail::concat(path, '/', std::to_string(i)));
|
||||
auto temp_diff = diff(source[i], target[i], detail::concat<StringType>(path, '/', array_index_str));
|
||||
result.insert(result.end(), temp_diff.begin(), temp_diff.end());
|
||||
++i;
|
||||
}
|
||||
@ -5022,10 +5028,17 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
{
|
||||
// add operations in reverse order to avoid invalid
|
||||
// indices
|
||||
|
||||
StringType array_index_str;
|
||||
{
|
||||
using namespace detail;
|
||||
int_to_string(array_index_str, i);
|
||||
}
|
||||
|
||||
result.insert(result.begin() + end_index, object(
|
||||
{
|
||||
{"op", "remove"},
|
||||
{"path", detail::concat(path, '/', std::to_string(i))}
|
||||
{"path", detail::concat<StringType>(path, '/', array_index_str)}
|
||||
}));
|
||||
++i;
|
||||
}
|
||||
@ -5036,7 +5049,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
result.push_back(
|
||||
{
|
||||
{"op", "add"},
|
||||
{"path", detail::concat(path, "/-")},
|
||||
{"path", detail::concat<StringType>(path, "/-")},
|
||||
{"value", target[i]}
|
||||
});
|
||||
++i;
|
||||
@ -5051,7 +5064,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
for (auto it = source.cbegin(); it != source.cend(); ++it)
|
||||
{
|
||||
// escape the key name to be used in a JSON patch
|
||||
const auto path_key = detail::concat(path, '/', detail::escape(it.key()));
|
||||
const auto path_key = detail::concat<StringType>(path, '/', detail::escape(it.key()));
|
||||
|
||||
if (target.find(it.key()) != target.end())
|
||||
{
|
||||
@ -5075,7 +5088,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
if (source.find(it.key()) == source.end())
|
||||
{
|
||||
// found a key that is not in this -> add it
|
||||
const auto path_key = detail::concat(path, '/', detail::escape(it.key()));
|
||||
const auto path_key = detail::concat<StringType>(path, '/', detail::escape(it.key()));
|
||||
result.push_back(
|
||||
{
|
||||
{"op", "add"}, {"path", path_key},
|
||||
|
||||
@ -41,7 +41,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <utility>
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
@ -54,7 +53,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// This file contains all macro definitions affecting or depending on the ABI
|
||||
|
||||
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
|
||||
@ -156,7 +154,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <algorithm> // transform
|
||||
#include <array> // array
|
||||
#include <forward_list> // forward_list
|
||||
@ -179,7 +176,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstddef> // nullptr_t
|
||||
#include <exception> // exception
|
||||
#if JSON_DIAGNOSTICS
|
||||
@ -199,7 +195,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <array> // array
|
||||
#include <cstddef> // size_t
|
||||
#include <cstdint> // uint8_t
|
||||
@ -215,7 +210,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <utility> // declval, pair
|
||||
// #include <nlohmann/detail/meta/detected.hpp>
|
||||
// __ _____ _____ _____
|
||||
@ -227,7 +221,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <type_traits>
|
||||
|
||||
// #include <nlohmann/detail/meta/void_t.hpp>
|
||||
@ -240,7 +233,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
|
||||
@ -2946,7 +2938,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
|
||||
@ -3021,7 +3012,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstddef> // size_t
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
@ -3064,7 +3054,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <array> // array
|
||||
#include <cstddef> // size_t
|
||||
#include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
|
||||
@ -3237,7 +3226,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <limits> // numeric_limits
|
||||
#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
|
||||
#include <utility> // declval
|
||||
@ -3254,7 +3242,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <iterator> // random_access_iterator_tag
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
@ -3322,7 +3309,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// #include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
|
||||
@ -3342,7 +3328,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// #include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
|
||||
@ -4217,7 +4202,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstring> // strlen
|
||||
#include <string> // string
|
||||
#include <utility> // forward
|
||||
@ -4603,7 +4587,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
|
||||
@ -4627,7 +4610,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// #include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
|
||||
@ -5133,7 +5115,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <algorithm> // copy
|
||||
#include <iterator> // begin, end
|
||||
#include <string> // string
|
||||
@ -5153,7 +5134,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstddef> // size_t
|
||||
#include <iterator> // input_iterator_tag
|
||||
#include <string> // string, to_string
|
||||
@ -5875,7 +5855,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstdint> // uint8_t, uint64_t
|
||||
#include <tuple> // tie
|
||||
#include <utility> // move
|
||||
@ -5987,7 +5966,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstdint> // uint8_t
|
||||
#include <cstddef> // size_t
|
||||
#include <functional> // hash
|
||||
@ -6120,7 +6098,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <algorithm> // generate_n
|
||||
#include <array> // array
|
||||
#include <cmath> // ldexp
|
||||
@ -6146,7 +6123,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <array> // array
|
||||
#include <cstddef> // size_t
|
||||
#include <cstring> // strlen
|
||||
@ -6643,7 +6619,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstddef>
|
||||
#include <string> // string
|
||||
#include <utility> // move
|
||||
@ -7375,7 +7350,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <array> // array
|
||||
#include <clocale> // localeconv
|
||||
#include <cstddef> // size_t
|
||||
@ -9016,7 +8990,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstdint> // size_t
|
||||
#include <utility> // declval
|
||||
#include <string> // string
|
||||
@ -12168,7 +12141,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cmath> // isfinite
|
||||
#include <cstdint> // uint8_t
|
||||
#include <functional> // function
|
||||
@ -12697,7 +12669,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// #include <nlohmann/detail/abi_macros.hpp>
|
||||
|
||||
// #include <nlohmann/detail/iterators/primitive_iterator.hpp>
|
||||
@ -12710,7 +12681,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstddef> // ptrdiff_t
|
||||
#include <limits> // numeric_limits
|
||||
|
||||
@ -12869,7 +12839,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <iterator> // iterator, random_access_iterator_tag, bidirectional_iterator_tag, advance, next
|
||||
#include <type_traits> // conditional, is_const, remove_const
|
||||
|
||||
@ -13631,7 +13600,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <cstddef> // ptrdiff_t
|
||||
#include <iterator> // reverse_iterator
|
||||
#include <utility> // declval
|
||||
@ -13808,7 +13776,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <algorithm> // all_of
|
||||
#include <cctype> // isdigit
|
||||
#include <cerrno> // errno, ERANGE
|
||||
@ -13877,7 +13844,7 @@ class json_pointer
|
||||
string_t{},
|
||||
[](const string_t& a, const string_t& b)
|
||||
{
|
||||
return detail::concat(a, '/', detail::escape(b));
|
||||
return detail::concat<string_t>(a, '/', detail::escape(b));
|
||||
});
|
||||
}
|
||||
|
||||
@ -14803,7 +14770,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <initializer_list>
|
||||
#include <utility>
|
||||
|
||||
@ -14895,7 +14861,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <algorithm> // reverse
|
||||
#include <array> // array
|
||||
#include <map> // map
|
||||
@ -14921,7 +14886,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <algorithm> // copy
|
||||
#include <cstddef> // size_t
|
||||
#include <iterator> // back_inserter
|
||||
@ -16890,7 +16854,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <algorithm> // reverse, remove, fill, find, none_of
|
||||
#include <array> // array
|
||||
#include <clocale> // localeconv, lconv
|
||||
@ -16915,7 +16878,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <array> // array
|
||||
#include <cmath> // signbit, isfinite
|
||||
#include <cstdint> // intN_t, uintN_t
|
||||
@ -19010,7 +18972,6 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#include <functional> // equal_to, less
|
||||
#include <initializer_list> // initializer_list
|
||||
#include <iterator> // input_iterator_tag, iterator_traits
|
||||
@ -24005,7 +23966,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// the valid JSON Patch operations
|
||||
enum class patch_operations {add, remove, replace, move, copy, test, invalid};
|
||||
|
||||
const auto get_op = [](const std::string & op)
|
||||
const auto get_op = [](const StringType & op)
|
||||
{
|
||||
if (op == "add")
|
||||
{
|
||||
@ -24142,8 +24103,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
for (const auto& val : json_patch)
|
||||
{
|
||||
// wrapper to get a value for an operation
|
||||
const auto get_value = [&val](const std::string & op,
|
||||
const std::string & member,
|
||||
const auto get_value = [&val](const StringType & op,
|
||||
const StringType & member,
|
||||
bool string_type) -> basic_json &
|
||||
{
|
||||
// find value
|
||||
@ -24177,8 +24138,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
}
|
||||
|
||||
// collect mandatory members
|
||||
const auto op = get_value("op", "op", true).template get<std::string>();
|
||||
const auto path = get_value(op, "path", true).template get<std::string>();
|
||||
const auto op = get_value("op", "op", true).template get<StringType>();
|
||||
const auto path = get_value(op, "path", true).template get<StringType>();
|
||||
json_pointer ptr(path);
|
||||
|
||||
switch (get_op(op))
|
||||
@ -24204,7 +24165,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
case patch_operations::move:
|
||||
{
|
||||
const auto from_path = get_value("move", "from", true).template get<std::string>();
|
||||
const auto from_path = get_value("move", "from", true).template get<StringType>();
|
||||
json_pointer from_ptr(from_path);
|
||||
|
||||
// the "from" location must exist - use at()
|
||||
@ -24221,7 +24182,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
case patch_operations::copy:
|
||||
{
|
||||
const auto from_path = get_value("copy", "from", true).template get<std::string>();
|
||||
const auto from_path = get_value("copy", "from", true).template get<StringType>();
|
||||
const json_pointer from_ptr(from_path);
|
||||
|
||||
// the "from" location must exist - use at()
|
||||
@ -24281,7 +24242,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/diff/
|
||||
JSON_HEDLEY_WARN_UNUSED_RESULT
|
||||
static basic_json diff(const basic_json& source, const basic_json& target,
|
||||
const std::string& path = "")
|
||||
const StringType& path = "")
|
||||
{
|
||||
// the patch
|
||||
basic_json result(value_t::array);
|
||||
@ -24310,8 +24271,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
std::size_t i = 0;
|
||||
while (i < source.size() && i < target.size())
|
||||
{
|
||||
StringType array_index_str;
|
||||
{
|
||||
using namespace detail;
|
||||
int_to_string(array_index_str, i);
|
||||
}
|
||||
|
||||
// recursive call to compare array values at index i
|
||||
auto temp_diff = diff(source[i], target[i], detail::concat(path, '/', std::to_string(i)));
|
||||
auto temp_diff = diff(source[i], target[i], detail::concat<StringType>(path, '/', array_index_str));
|
||||
result.insert(result.end(), temp_diff.begin(), temp_diff.end());
|
||||
++i;
|
||||
}
|
||||
@ -24325,10 +24292,17 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
{
|
||||
// add operations in reverse order to avoid invalid
|
||||
// indices
|
||||
|
||||
StringType array_index_str;
|
||||
{
|
||||
using namespace detail;
|
||||
int_to_string(array_index_str, i);
|
||||
}
|
||||
|
||||
result.insert(result.begin() + end_index, object(
|
||||
{
|
||||
{"op", "remove"},
|
||||
{"path", detail::concat(path, '/', std::to_string(i))}
|
||||
{"path", detail::concat<StringType>(path, '/', array_index_str)}
|
||||
}));
|
||||
++i;
|
||||
}
|
||||
@ -24339,7 +24313,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
result.push_back(
|
||||
{
|
||||
{"op", "add"},
|
||||
{"path", detail::concat(path, "/-")},
|
||||
{"path", detail::concat<StringType>(path, "/-")},
|
||||
{"value", target[i]}
|
||||
});
|
||||
++i;
|
||||
@ -24354,7 +24328,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
for (auto it = source.cbegin(); it != source.cend(); ++it)
|
||||
{
|
||||
// escape the key name to be used in a JSON patch
|
||||
const auto path_key = detail::concat(path, '/', detail::escape(it.key()));
|
||||
const auto path_key = detail::concat<StringType>(path, '/', detail::escape(it.key()));
|
||||
|
||||
if (target.find(it.key()) != target.end())
|
||||
{
|
||||
@ -24378,7 +24352,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
if (source.find(it.key()) == source.end())
|
||||
{
|
||||
// found a key that is not in this -> add it
|
||||
const auto path_key = detail::concat(path, '/', detail::escape(it.key()));
|
||||
const auto path_key = detail::concat<StringType>(path, '/', detail::escape(it.key()));
|
||||
result.push_back(
|
||||
{
|
||||
{"op", "add"}, {"path", path_key},
|
||||
@ -24566,7 +24540,6 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// restore clang diagnostic settings
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
@ -24611,7 +24584,6 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
#undef JSON_HEDLEY_ALWAYS_INLINE
|
||||
#undef JSON_HEDLEY_ARM_VERSION
|
||||
#undef JSON_HEDLEY_ARM_VERSION_CHECK
|
||||
@ -24762,5 +24734,4 @@ inline void swap(nlohmann::NLOHMANN_BASIC_JSON_TPL& j1, nlohmann::NLOHMANN_BASIC
|
||||
#undef JSON_HEDLEY_FALL_THROUGH
|
||||
|
||||
|
||||
|
||||
#endif // INCLUDE_NLOHMANN_JSON_HPP_
|
||||
|
||||
@ -25,7 +25,6 @@
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
||||
|
||||
|
||||
// This file contains all macro definitions affecting or depending on the ABI
|
||||
|
||||
#ifndef JSON_SKIP_LIBRARY_VERSION_CHECK
|
||||
|
||||
@ -35,10 +35,33 @@ class alt_string
|
||||
alt_string(size_t count, char chr): str_impl(count, chr) {}
|
||||
alt_string() = default;
|
||||
|
||||
template <typename...TParams>
|
||||
alt_string& append(TParams&& ...params)
|
||||
alt_string& append(std::size_t count, char ch)
|
||||
{
|
||||
str_impl.append(std::forward<TParams>(params)...);
|
||||
str_impl.append(count, ch);
|
||||
return *this;
|
||||
}
|
||||
|
||||
alt_string& append(const alt_string& str)
|
||||
{
|
||||
str_impl.append(str.str_impl);
|
||||
return *this;
|
||||
}
|
||||
|
||||
alt_string& append(const char* s, std::size_t count)
|
||||
{
|
||||
str_impl.append(s, count);
|
||||
return *this;
|
||||
}
|
||||
|
||||
alt_string& append(const char* s)
|
||||
{
|
||||
str_impl.append(s);
|
||||
return *this;
|
||||
}
|
||||
|
||||
alt_string& operator+=(char ch)
|
||||
{
|
||||
str_impl += ch;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -74,6 +97,11 @@ class alt_string
|
||||
return str_impl.size();
|
||||
}
|
||||
|
||||
void reserve (std::size_t n)
|
||||
{
|
||||
str_impl.reserve(n);
|
||||
}
|
||||
|
||||
void resize (std::size_t n)
|
||||
{
|
||||
str_impl.resize(n);
|
||||
@ -318,5 +346,18 @@ TEST_CASE("alternative string type")
|
||||
|
||||
CHECK(j.at(alt_json::json_pointer("/foo/0")) == j["foo"][0]);
|
||||
CHECK(j.at(alt_json::json_pointer("/foo/1")) == j["foo"][1]);
|
||||
|
||||
// ensures successful compilation
|
||||
CHECK(alt_json::json_pointer("/foo/0").to_string() == "/foo/0");
|
||||
}
|
||||
|
||||
SECTION("JSON patch")
|
||||
{
|
||||
// for now, just ensures successful compilation (see #4134)
|
||||
alt_json base, target;
|
||||
alt_json patch = alt_json::array();
|
||||
|
||||
base.patch(patch);
|
||||
CHECK_NOTHROW(alt_json::diff(target, base));
|
||||
}
|
||||
}
|
||||
|
||||
@ -339,13 +339,13 @@ TEST_CASE("BJData")
|
||||
std::vector<int32_t> const numbers
|
||||
{
|
||||
-32769,
|
||||
-100000,
|
||||
-1000000,
|
||||
-10000000,
|
||||
-100000000,
|
||||
-1000000000,
|
||||
-2147483647 - 1, // https://stackoverflow.com/a/29356002/266378
|
||||
};
|
||||
-100000,
|
||||
-1000000,
|
||||
-10000000,
|
||||
-100000000,
|
||||
-1000000000,
|
||||
-2147483647 - 1, // https://stackoverflow.com/a/29356002/266378
|
||||
};
|
||||
for (const auto i : numbers)
|
||||
{
|
||||
CAPTURE(i)
|
||||
|
||||
@ -241,13 +241,13 @@ TEST_CASE("CBOR")
|
||||
const std::vector<int64_t> numbers
|
||||
{
|
||||
-65537,
|
||||
-100000,
|
||||
-1000000,
|
||||
-10000000,
|
||||
-100000000,
|
||||
-1000000000,
|
||||
-4294967296,
|
||||
};
|
||||
-100000,
|
||||
-1000000,
|
||||
-10000000,
|
||||
-100000000,
|
||||
-1000000000,
|
||||
-4294967296,
|
||||
};
|
||||
for (const auto i : numbers)
|
||||
{
|
||||
CAPTURE(i)
|
||||
|
||||
@ -479,11 +479,11 @@ TEST_CASE("MessagePack")
|
||||
std::vector<int32_t> const numbers
|
||||
{
|
||||
-32769,
|
||||
-65536,
|
||||
-77777,
|
||||
-1048576,
|
||||
-2147483648LL,
|
||||
};
|
||||
-65536,
|
||||
-77777,
|
||||
-1048576,
|
||||
-2147483648LL,
|
||||
};
|
||||
for (auto i : numbers)
|
||||
{
|
||||
CAPTURE(i)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user