mirror of
https://github.com/nlohmann/json.git
synced 2025-07-31 10:24:23 +03:00
Fix typos (#4748)
* ✏️ fix typos Signed-off-by: Niels Lohmann <mail@nlohmann.me> * ✏️ address review comments Signed-off-by: Niels Lohmann <mail@nlohmann.me> * ✏️ address review comments Signed-off-by: Niels Lohmann <mail@nlohmann.me> --------- Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@ -2394,7 +2394,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
|
||||
// C++ language standard detection
|
||||
// if the user manually specified the used c++ version this is skipped
|
||||
// if the user manually specified the used C++ version, this is skipped
|
||||
#if !defined(JSON_HAS_CPP_23) && !defined(JSON_HAS_CPP_20) && !defined(JSON_HAS_CPP_17) && !defined(JSON_HAS_CPP_14) && !defined(JSON_HAS_CPP_11)
|
||||
#if (defined(__cplusplus) && __cplusplus > 202002L) || (defined(_MSVC_LANG) && _MSVC_LANG > 202002L)
|
||||
#define JSON_HAS_CPP_23
|
||||
@ -2491,7 +2491,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#endif
|
||||
|
||||
#ifndef JSON_HAS_RANGES
|
||||
// ranges header shipping in GCC 11.1.0 (released 2021-04-27) has syntax error
|
||||
// ranges header shipping in GCC 11.1.0 (released 2021-04-27) has a syntax error
|
||||
#if defined(__GLIBCXX__) && __GLIBCXX__ == 20210427
|
||||
#define JSON_HAS_RANGES 0
|
||||
#elif defined(__cpp_lib_ranges)
|
||||
@ -2568,7 +2568,7 @@ JSON_HEDLEY_DIAGNOSTIC_POP
|
||||
#define JSON_ASSERT(x) assert(x)
|
||||
#endif
|
||||
|
||||
// allow to access some private functions (needed by the test suite)
|
||||
// allow accessing some private functions (needed by the test suite)
|
||||
#if defined(JSON_TESTS_PRIVATE)
|
||||
#define JSON_PRIVATE_UNLESS_TESTED public
|
||||
#else
|
||||
@ -3096,10 +3096,10 @@ inline void replace_substring(StringType& s, const StringType& f,
|
||||
const StringType& t)
|
||||
{
|
||||
JSON_ASSERT(!f.empty());
|
||||
for (auto pos = s.find(f); // find first occurrence of f
|
||||
for (auto pos = s.find(f); // find the first occurrence of f
|
||||
pos != StringType::npos; // make sure f was found
|
||||
s.replace(pos, f.size(), t), // replace with t, and
|
||||
pos = s.find(f, pos + t.size())) // find next occurrence of f
|
||||
pos = s.find(f, pos + t.size())) // find the next occurrence of f
|
||||
{}
|
||||
}
|
||||
|
||||
@ -3579,12 +3579,12 @@ namespace detail
|
||||
|
||||
// Note to maintainers:
|
||||
//
|
||||
// Every trait in this file expects a non CV-qualified type.
|
||||
// Every trait in this file expects a non-CV-qualified type.
|
||||
// The only exceptions are in the 'aliases for detected' section
|
||||
// (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
|
||||
// (i.e., those of the form: decltype(T::member_function(std::declval<T>())))
|
||||
//
|
||||
// In this case, T has to be properly CV-qualified to constraint the function arguments
|
||||
// (e.g. to_json(BasicJsonType&, const T&))
|
||||
// (e.g., to_json(BasicJsonType&, const T&))
|
||||
|
||||
template<typename> struct is_basic_json : std::false_type {};
|
||||
|
||||
@ -3592,7 +3592,7 @@ NLOHMANN_BASIC_JSON_TPL_DECLARATION
|
||||
struct is_basic_json<NLOHMANN_BASIC_JSON_TPL> : std::true_type {};
|
||||
|
||||
// used by exceptions create() member functions
|
||||
// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t
|
||||
// true_type for the pointer to possibly cv-qualified basic_json or std::nullptr_t
|
||||
// false_type otherwise
|
||||
template<typename BasicJsonContext>
|
||||
struct is_basic_json_context :
|
||||
@ -3818,7 +3818,7 @@ template<class B> struct negation : std::integral_constant < bool, !B::value > {
|
||||
|
||||
// Reimplementation of is_constructible and is_default_constructible, due to them being broken for
|
||||
// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367).
|
||||
// This causes compile errors in e.g. clang 3.5 or gcc 4.9.
|
||||
// This causes compile errors in e.g., Clang 3.5 or GCC 4.9.
|
||||
template <typename T>
|
||||
struct is_default_constructible : std::is_default_constructible<T> {};
|
||||
|
||||
@ -3898,7 +3898,7 @@ using range_value_t = value_type_t<iterator_traits<iterator_t<T>>>;
|
||||
|
||||
// The following implementation of is_complete_type is taken from
|
||||
// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/
|
||||
// and is written by Xiang Fan who agreed to using it in this library.
|
||||
// and is written by Xiang Fan who agreed to use it in this library.
|
||||
|
||||
template<typename T, typename = void>
|
||||
struct is_complete_type : std::false_type {};
|
||||
@ -4135,7 +4135,7 @@ decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
|
||||
template<typename T>
|
||||
using detect_is_transparent = typename T::is_transparent;
|
||||
|
||||
// type trait to check if KeyType can be used as object key (without a BasicJsonType)
|
||||
// type trait to check if KeyType can be used as an object key (without a BasicJsonType)
|
||||
// see is_usable_as_basic_json_key_type below
|
||||
template<typename Comparator, typename ObjectKeyType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
|
||||
bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
|
||||
@ -4149,7 +4149,7 @@ using is_usable_as_key_type = typename std::conditional <
|
||||
std::true_type,
|
||||
std::false_type >::type;
|
||||
|
||||
// type trait to check if KeyType can be used as object key
|
||||
// type trait to check if KeyType can be used as an object key
|
||||
// true if:
|
||||
// - KeyType is comparable with BasicJsonType::object_t::key_type
|
||||
// - if ExcludeObjectKeyType is true, KeyType is not BasicJsonType::object_t::key_type
|
||||
@ -4513,7 +4513,7 @@ NLOHMANN_JSON_NAMESPACE_END
|
||||
// emitted in every translation unit. This issue cannot be fixed with a
|
||||
// header-only library as there is no implementation file to move these
|
||||
// functions to. As a result, we suppress this warning here to avoid client
|
||||
// code to stumble over this. See https://github.com/nlohmann/json/issues/4087
|
||||
// code stumbling over this. See https://github.com/nlohmann/json/issues/4087
|
||||
// for a discussion.
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic push
|
||||
@ -5209,7 +5209,7 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
|
||||
}
|
||||
|
||||
// overload for arithmetic types, not chosen for basic_json template arguments
|
||||
// (BooleanType, etc..); note: Is it really necessary to provide explicit
|
||||
// (BooleanType, etc.); note: Is it really necessary to provide explicit
|
||||
// overloads for boolean_t etc. in case of a custom BooleanType which is not
|
||||
// an arithmetic type?
|
||||
template < typename BasicJsonType, typename ArithmeticType,
|
||||
@ -6595,7 +6595,7 @@ class input_stream_adapter
|
||||
: is(&i), sb(i.rdbuf())
|
||||
{}
|
||||
|
||||
// delete because of pointer members
|
||||
// deleted because of pointer members
|
||||
input_stream_adapter(const input_stream_adapter&) = delete;
|
||||
input_stream_adapter& operator=(input_stream_adapter&) = delete;
|
||||
input_stream_adapter& operator=(input_stream_adapter&&) = delete;
|
||||
@ -6609,7 +6609,7 @@ class input_stream_adapter
|
||||
|
||||
// std::istream/std::streambuf use std::char_traits<char>::to_int_type, to
|
||||
// ensure that std::char_traits<char>::eof() and the character 0xFF do not
|
||||
// end up as the same value, e.g. 0xFFFFFFFF.
|
||||
// end up as the same value, e.g., 0xFFFFFFFF.
|
||||
std::char_traits<char>::int_type get_character()
|
||||
{
|
||||
auto res = sb->sbumpc();
|
||||
@ -6831,7 +6831,7 @@ class wide_string_input_adapter
|
||||
|
||||
typename std::char_traits<char>::int_type get_character() noexcept
|
||||
{
|
||||
// check if buffer needs to be filled
|
||||
// check if the buffer needs to be filled
|
||||
if (utf8_bytes_index == utf8_bytes_filled)
|
||||
{
|
||||
fill_buffer<sizeof(WideCharType)>();
|
||||
@ -7188,7 +7188,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
, decimal_point_char(static_cast<char_int_type>(get_decimal_point()))
|
||||
{}
|
||||
|
||||
// delete because of pointer members
|
||||
// deleted because of pointer members
|
||||
lexer(const lexer&) = delete;
|
||||
lexer(lexer&&) = default; // NOLINT(hicpp-noexcept-move,performance-noexcept-move-constructor)
|
||||
lexer& operator=(lexer&) = delete;
|
||||
@ -7323,10 +7323,10 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
|
||||
while (true)
|
||||
{
|
||||
// get next character
|
||||
// get the next character
|
||||
switch (get())
|
||||
{
|
||||
// end of file while parsing string
|
||||
// end of file while parsing the string
|
||||
case char_traits<char_type>::eof():
|
||||
{
|
||||
error_message = "invalid string: missing closing quote";
|
||||
@ -7412,7 +7412,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
(static_cast<unsigned int>(codepoint1) << 10u)
|
||||
// low surrogate occupies the least significant 15 bits
|
||||
+ static_cast<unsigned int>(codepoint2)
|
||||
// there is still the 0xD800, 0xDC00 and 0x10000 noise
|
||||
// there is still the 0xD800, 0xDC00, and 0x10000 noise
|
||||
// in the result, so we have to subtract with:
|
||||
// (0xD800 << 10) + DC00 - 0x10000 = 0x35FDC00
|
||||
- 0x35FDC00u);
|
||||
@ -7438,7 +7438,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
}
|
||||
}
|
||||
|
||||
// result of the above calculation yields a proper codepoint
|
||||
// the result of the above calculation yields a proper codepoint
|
||||
JSON_ASSERT(0x00 <= codepoint && codepoint <= 0x10FFFF);
|
||||
|
||||
// translate codepoint into bytes
|
||||
@ -7889,7 +7889,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
break;
|
||||
}
|
||||
|
||||
// remaining bytes (80..C1 and F5..FF) are ill-formed
|
||||
// the remaining bytes (80..C1 and F5..FF) are ill-formed
|
||||
default:
|
||||
{
|
||||
error_message = "invalid string: ill-formed UTF-8 byte";
|
||||
@ -8034,7 +8034,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||
reset();
|
||||
|
||||
// the type of the parsed number; initially set to unsigned; will be
|
||||
// changed if minus sign, decimal point or exponent is read
|
||||
// changed if minus sign, decimal point, or exponent is read
|
||||
token_type number_type = token_type::value_unsigned;
|
||||
|
||||
// state (init): we just found out we need to scan a number
|
||||
@ -8406,7 +8406,7 @@ scan_number_done:
|
||||
|
||||
if (next_unget)
|
||||
{
|
||||
// just reset the next_unget variable and work with current
|
||||
// only reset the next_unget variable and work with current
|
||||
next_unget = false;
|
||||
}
|
||||
else
|
||||
@ -8585,7 +8585,7 @@ scan_number_done:
|
||||
return token_type::parse_error;
|
||||
}
|
||||
|
||||
// read next character and ignore whitespace
|
||||
// read the next character and ignore whitespace
|
||||
skip_whitespace();
|
||||
|
||||
// ignore comments
|
||||
@ -8949,7 +8949,7 @@ class json_sax_dom_parser
|
||||
JSON_ASSERT(!ref_stack.empty());
|
||||
JSON_ASSERT(ref_stack.back()->is_object());
|
||||
|
||||
// add null at given key and store the reference for later
|
||||
// add null at the given key and store the reference for later
|
||||
object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val));
|
||||
return true;
|
||||
}
|
||||
@ -9265,11 +9265,11 @@ class json_sax_dom_callback_parser
|
||||
{
|
||||
BasicJsonType k = BasicJsonType(val);
|
||||
|
||||
// check callback for key
|
||||
// check callback for the key
|
||||
const bool keep = callback(static_cast<int>(ref_stack.size()), parse_event_t::key, k);
|
||||
key_keep_stack.push_back(keep);
|
||||
|
||||
// add discarded value at given key and store the reference for later
|
||||
// add discarded value at the given key and store the reference for later
|
||||
if (keep && ref_stack.back())
|
||||
{
|
||||
object_element = &(ref_stack.back()->m_data.m_value.object->operator[](val) = discarded);
|
||||
@ -10149,7 +10149,7 @@ class binary_reader
|
||||
return get_number<std::uint64_t, true>(input_format_t::bson, value) && sax->number_unsigned(value);
|
||||
}
|
||||
|
||||
default: // anything else not supported (yet)
|
||||
default: // anything else is not supported (yet)
|
||||
{
|
||||
std::array<char, 3> cr{{}};
|
||||
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
|
||||
@ -10546,7 +10546,7 @@ class binary_reader
|
||||
case 0xD2:
|
||||
case 0xD3:
|
||||
case 0xD4:
|
||||
case 0xD8: // tagged item (1 bytes follow)
|
||||
case 0xD8: // tagged item (1 byte follows)
|
||||
case 0xD9: // tagged item (2 bytes follow)
|
||||
case 0xDA: // tagged item (4 bytes follow)
|
||||
case 0xDB: // tagged item (8 bytes follow)
|
||||
@ -10598,7 +10598,7 @@ class binary_reader
|
||||
case cbor_tag_handler_t::store:
|
||||
{
|
||||
binary_t b;
|
||||
// use binary subtype and store in binary container
|
||||
// use binary subtype and store in a binary container
|
||||
switch (current)
|
||||
{
|
||||
case 0xD8:
|
||||
@ -10667,7 +10667,7 @@ class binary_reader
|
||||
const auto byte1 = static_cast<unsigned char>(byte1_raw);
|
||||
const auto byte2 = static_cast<unsigned char>(byte2_raw);
|
||||
|
||||
// code from RFC 7049, Appendix D, Figure 3:
|
||||
// Code from RFC 7049, Appendix D, Figure 3:
|
||||
// As half-precision floating-point numbers were only added
|
||||
// to IEEE 754 in 2008, today's programming platforms often
|
||||
// still only have limited support for them. It is very
|
||||
@ -11974,7 +11974,7 @@ class binary_reader
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (is_ndarray) // ndarray dimensional vector can only contain integers, and can not embed another array
|
||||
if (is_ndarray) // ndarray dimensional vector can only contain integers and cannot embed another array
|
||||
{
|
||||
return sax->parse_error(chars_read, get_token_string(), parse_error::create(113, chars_read, exception_message(input_format, "ndarray dimensional vector is not allowed", "size"), nullptr));
|
||||
}
|
||||
@ -12232,7 +12232,7 @@ class binary_reader
|
||||
const auto byte1 = static_cast<unsigned char>(byte1_raw);
|
||||
const auto byte2 = static_cast<unsigned char>(byte2_raw);
|
||||
|
||||
// code from RFC 7049, Appendix D, Figure 3:
|
||||
// Code from RFC 7049, Appendix D, Figure 3:
|
||||
// As half-precision floating-point numbers were only added
|
||||
// to IEEE 754 in 2008, today's programming platforms often
|
||||
// still only have limited support for them. It is very
|
||||
@ -12520,7 +12520,7 @@ class binary_reader
|
||||
|
||||
bool get_ubjson_high_precision_number()
|
||||
{
|
||||
// get size of following number string
|
||||
// get the size of the following number string
|
||||
std::size_t size{};
|
||||
bool no_ndarray = true;
|
||||
auto res = get_ubjson_size_value(size, no_ndarray);
|
||||
@ -12618,7 +12618,7 @@ class binary_reader
|
||||
chars_read += new_chars_read;
|
||||
if (JSON_HEDLEY_UNLIKELY(new_chars_read < sizeof(T)))
|
||||
{
|
||||
// in case of failure, advance position by 1 to report failing location
|
||||
// in case of failure, advance position by 1 to report the failing location
|
||||
++chars_read;
|
||||
sax->parse_error(chars_read, "<end of file>", parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context), nullptr));
|
||||
return false;
|
||||
@ -13016,7 +13016,7 @@ class parser
|
||||
exception_message(token_type::end_of_input, "value"), nullptr));
|
||||
}
|
||||
|
||||
// in case of an error, return discarded value
|
||||
// in case of an error, return a discarded value
|
||||
if (sdp.is_errored())
|
||||
{
|
||||
result = value_t::discarded;
|
||||
@ -13043,7 +13043,7 @@ class parser
|
||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::end_of_input, "value"), nullptr));
|
||||
}
|
||||
|
||||
// in case of an error, return discarded value
|
||||
// in case of an error, return a discarded value
|
||||
if (sdp.is_errored())
|
||||
{
|
||||
result = value_t::discarded;
|
||||
@ -13246,7 +13246,7 @@ class parser
|
||||
|
||||
case token_type::parse_error:
|
||||
{
|
||||
// using "uninitialized" to avoid "expected" message
|
||||
// using "uninitialized" to avoid an "expected" message
|
||||
return sax->parse_error(m_lexer.get_position(),
|
||||
m_lexer.get_token_string(),
|
||||
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), nullptr));
|
||||
@ -13466,9 +13466,9 @@ namespace detail
|
||||
@brief an iterator for primitive JSON types
|
||||
|
||||
This class models an iterator for primitive JSON types (boolean, number,
|
||||
string). It's only purpose is to allow the iterator/const_iterator classes
|
||||
string). Its only purpose is to allow the iterator/const_iterator classes
|
||||
to "iterate" over primitive values. Internally, the iterator is modeled by
|
||||
a `difference_type` variable. Value begin_value (`0`) models the begin,
|
||||
a `difference_type` variable. Value begin_value (`0`) models the begin and
|
||||
end_value (`1`) models past the end.
|
||||
*/
|
||||
class primitive_iterator_t
|
||||
@ -13633,7 +13633,7 @@ NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// forward declare, to be able to friend it later on
|
||||
// forward declare to be able to friend it later on
|
||||
template<typename IteratorType> class iteration_proxy;
|
||||
template<typename IteratorType> class iteration_proxy_value;
|
||||
|
||||
@ -14841,7 +14841,7 @@ class json_pointer
|
||||
{
|
||||
if (reference_token == "0")
|
||||
{
|
||||
// start a new array if reference token is 0
|
||||
// start a new array if the reference token is 0
|
||||
result = &result->operator[](0);
|
||||
}
|
||||
else
|
||||
@ -14870,7 +14870,7 @@ class json_pointer
|
||||
The following code is only reached if there exists a reference
|
||||
token _and_ the current value is primitive. In this case, we have
|
||||
an error situation, because primitive values may only occur as
|
||||
single value; that is, with an empty list of reference tokens.
|
||||
a single value; that is, with an empty list of reference tokens.
|
||||
*/
|
||||
case detail::value_t::string:
|
||||
case detail::value_t::boolean:
|
||||
@ -14914,7 +14914,7 @@ class json_pointer
|
||||
// convert null values to arrays or objects before continuing
|
||||
if (ptr->is_null())
|
||||
{
|
||||
// check if reference token is a number
|
||||
// check if the reference token is a number
|
||||
const bool nums =
|
||||
std::all_of(reference_token.begin(), reference_token.end(),
|
||||
[](const unsigned char x)
|
||||
@ -14922,7 +14922,7 @@ class json_pointer
|
||||
return std::isdigit(x);
|
||||
});
|
||||
|
||||
// change value to array for numbers or "-" or to object otherwise
|
||||
// change value to an array for numbers or "-" or to object otherwise
|
||||
*ptr = (nums || reference_token == "-")
|
||||
? detail::value_t::array
|
||||
: detail::value_t::object;
|
||||
@ -15165,7 +15165,7 @@ class json_pointer
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!('1' <= reference_token[0] && reference_token[0] <= '9')))
|
||||
{
|
||||
// first char should be between '1' and '9'
|
||||
// the first char should be between '1' and '9'
|
||||
return false;
|
||||
}
|
||||
for (std::size_t i = 1; i < reference_token.size(); i++)
|
||||
@ -15229,7 +15229,7 @@ class json_pointer
|
||||
return result;
|
||||
}
|
||||
|
||||
// check if nonempty reference string begins with slash
|
||||
// check if a nonempty reference string begins with slash
|
||||
if (JSON_HEDLEY_UNLIKELY(reference_string[0] != '/'))
|
||||
{
|
||||
JSON_THROW(detail::parse_error::create(107, 1, detail::concat("JSON pointer must be empty or begin with '/' - was: '", reference_string, "'"), nullptr));
|
||||
@ -15303,7 +15303,7 @@ class json_pointer
|
||||
}
|
||||
else
|
||||
{
|
||||
// iterate array and use index as reference string
|
||||
// iterate array and use index as a reference string
|
||||
for (std::size_t i = 0; i < value.m_data.m_value.array->size(); ++i)
|
||||
{
|
||||
flatten(detail::concat<string_t>(reference_string, '/', std::to_string(i)),
|
||||
@ -15341,7 +15341,7 @@ class json_pointer
|
||||
case detail::value_t::discarded:
|
||||
default:
|
||||
{
|
||||
// add primitive value with its reference string
|
||||
// add a primitive value with its reference string
|
||||
result[reference_string] = value;
|
||||
break;
|
||||
}
|
||||
@ -15377,17 +15377,17 @@ class json_pointer
|
||||
JSON_THROW(detail::type_error::create(315, "values in object must be primitive", &element.second));
|
||||
}
|
||||
|
||||
// assign value to reference pointed to by JSON pointer; Note that if
|
||||
// the JSON pointer is "" (i.e., points to the whole value), function
|
||||
// get_and_create returns a reference to result itself. An assignment
|
||||
// will then create a primitive value.
|
||||
// Assign the value to the reference pointed to by JSON pointer. Note
|
||||
// that if the JSON pointer is "" (i.e., points to the whole value),
|
||||
// function get_and_create returns a reference to the result itself.
|
||||
// An assignment will then create a primitive value.
|
||||
json_pointer(element.first).get_and_create(result) = element.second;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// can't use conversion operator because of ambiguity
|
||||
// can't use the conversion operator because of ambiguity
|
||||
json_pointer<string_t> convert() const&
|
||||
{
|
||||
json_pointer<string_t> result;
|
||||
@ -15482,7 +15482,7 @@ class json_pointer
|
||||
};
|
||||
|
||||
#if !JSON_HAS_THREE_WAY_COMPARISON
|
||||
// functions cannot be defined inside class due to ODR violations
|
||||
// functions cannot be defined inside the class due to ODR violations
|
||||
template<typename RefStringTypeLhs, typename RefStringTypeRhs>
|
||||
inline bool operator==(const json_pointer<RefStringTypeLhs>& lhs,
|
||||
const json_pointer<RefStringTypeRhs>& rhs) noexcept
|
||||
@ -17344,7 +17344,7 @@ class binary_writer
|
||||
{
|
||||
return 'L';
|
||||
}
|
||||
// anything else is treated as high-precision number
|
||||
// anything else is treated as a high-precision number
|
||||
return 'H'; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
@ -17382,7 +17382,7 @@ class binary_writer
|
||||
{
|
||||
return 'M';
|
||||
}
|
||||
// anything else is treated as high-precision number
|
||||
// anything else is treated as a high-precision number
|
||||
return 'H'; // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
@ -17548,11 +17548,11 @@ class binary_writer
|
||||
template<typename NumberType>
|
||||
void write_number(const NumberType n, const bool OutputIsLittleEndian = false)
|
||||
{
|
||||
// step 1: write number to array of length NumberType
|
||||
// step 1: write the number to an array of length NumberType
|
||||
std::array<CharType, sizeof(NumberType)> vec{};
|
||||
std::memcpy(vec.data(), &n, sizeof(NumberType));
|
||||
|
||||
// step 2: write array to output (with possible reordering)
|
||||
// step 2: write the array to output (with possible reordering)
|
||||
if (is_little_endian != OutputIsLittleEndian)
|
||||
{
|
||||
// reverse byte order prior to conversion if necessary
|
||||
@ -17802,7 +17802,7 @@ struct diyfp // f * 2^e
|
||||
// p_lo = p0_lo + (Q << 32)
|
||||
//
|
||||
// But in this particular case here, the full p_lo is not required.
|
||||
// Effectively we only need to add the highest bit in p_lo to p_hi (and
|
||||
// Effectively, we only need to add the highest bit in p_lo to p_hi (and
|
||||
// Q_hi + 1 does not overflow).
|
||||
|
||||
Q += std::uint64_t{1} << (64u - 32u - 1u); // round, ties up
|
||||
@ -17892,7 +17892,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
// Compute the boundaries m- and m+ of the floating-point value
|
||||
// v = f * 2^e.
|
||||
//
|
||||
// Determine v- and v+, the floating-point predecessor and successor if v,
|
||||
// Determine v- and v+, the floating-point predecessor and successor of v,
|
||||
// respectively.
|
||||
//
|
||||
// v- = v - 2^e if f != 2^(p-1) or e == e_min (A)
|
||||
@ -18047,7 +18047,7 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
|
||||
// (A smaller distance gamma-alpha would require a larger table.)
|
||||
|
||||
// NB:
|
||||
// Actually this function returns c, such that -60 <= e_c + e + 64 <= -34.
|
||||
// Actually, this function returns c, such that -60 <= e_c + e + 64 <= -34.
|
||||
|
||||
constexpr int kCachedPowersMinDecExp = -300;
|
||||
constexpr int kCachedPowersDecStep = 8;
|
||||
@ -18359,8 +18359,8 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
||||
|
||||
decimal_exponent += n;
|
||||
|
||||
// We may now just stop. But instead look if the buffer could be
|
||||
// decremented to bring V closer to w.
|
||||
// We may now just stop. But instead, it looks as if the buffer
|
||||
// could be decremented to bring V closer to w.
|
||||
//
|
||||
// pow10 = 10^n is now 1 ulp in the decimal representation V.
|
||||
// The rounding procedure works with diyfp's with an implicit
|
||||
@ -18767,7 +18767,7 @@ char* to_chars(char* first, const char* last, FloatType value)
|
||||
// Compute v = buffer * 10^decimal_exponent.
|
||||
// The decimal digits are stored in the buffer, which needs to be interpreted
|
||||
// as an unsigned decimal integer.
|
||||
// len is the length of the buffer, i.e. the number of decimal digits.
|
||||
// len is the length of the buffer, i.e., the number of decimal digits.
|
||||
int len = 0;
|
||||
int decimal_exponent = 0;
|
||||
dtoa_impl::grisu2(first, len, decimal_exponent, value);
|
||||
@ -18848,7 +18848,7 @@ class serializer
|
||||
, error_handler(error_handler_)
|
||||
{}
|
||||
|
||||
// delete because of pointer members
|
||||
// deleted because of pointer members
|
||||
serializer(const serializer&) = delete;
|
||||
serializer& operator=(const serializer&) = delete;
|
||||
serializer(serializer&&) = delete;
|
||||
@ -19346,7 +19346,7 @@ class serializer
|
||||
break;
|
||||
}
|
||||
|
||||
default: // decode found yet incomplete multi-byte code point
|
||||
default: // decode found yet incomplete multibyte code point
|
||||
{
|
||||
if (!ensure_ascii)
|
||||
{
|
||||
@ -19600,7 +19600,7 @@ class serializer
|
||||
|
||||
void dump_float(number_float_t x, std::false_type /*is_ieee_single_or_double*/)
|
||||
{
|
||||
// get number of digits for a float -> text -> float round-trip
|
||||
// get the number of digits for a float -> text -> float round-trip
|
||||
static constexpr auto d = std::numeric_limits<number_float_t>::max_digits10;
|
||||
|
||||
// the actual conversion
|
||||
@ -19609,10 +19609,10 @@ class serializer
|
||||
|
||||
// negative value indicates an error
|
||||
JSON_ASSERT(len > 0);
|
||||
// check if buffer was large enough
|
||||
// check if the buffer was large enough
|
||||
JSON_ASSERT(static_cast<std::size_t>(len) < number_buffer.size());
|
||||
|
||||
// erase thousands separator
|
||||
// erase thousands separators
|
||||
if (thousands_sep != '\0')
|
||||
{
|
||||
// NOLINTNEXTLINE(readability-qualified-auto,llvm-qualified-auto): std::remove returns an iterator, see https://github.com/nlohmann/json/issues/3081
|
||||
@ -19720,8 +19720,8 @@ class serializer
|
||||
* Helper function for dump_integer
|
||||
*
|
||||
* This function takes a negative signed integer and returns its absolute
|
||||
* value as unsigned integer. The plus/minus shuffling is necessary as we can
|
||||
* not directly remove the sign of an arbitrary signed integer as the
|
||||
* value as an unsigned integer. The plus/minus shuffling is necessary as we
|
||||
* cannot directly remove the sign of an arbitrary signed integer as the
|
||||
* absolute values of INT_MIN and INT_MAX are usually not the same. See
|
||||
* #1708 for details.
|
||||
*/
|
||||
@ -19995,7 +19995,7 @@ template <class Key, class T, class IgnoredLess = std::less<Key>,
|
||||
|
||||
// Since we cannot move const Keys, we re-construct them in place.
|
||||
// We start at first and re-construct (viz. copy) the elements from
|
||||
// the back of the vector. Example for first iteration:
|
||||
// the back of the vector. Example for the first iteration:
|
||||
|
||||
// ,--------.
|
||||
// v | destroy e and re-construct with h
|
||||
@ -20629,7 +20629,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
(t == value_t::binary && binary == nullptr)
|
||||
)
|
||||
{
|
||||
//not initialized (e.g. due to exception in the ctor)
|
||||
//not initialized (e.g., due to exception in the ctor)
|
||||
return;
|
||||
}
|
||||
if (t == value_t::array || t == value_t::object)
|
||||
@ -20654,7 +20654,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
while (!stack.empty())
|
||||
{
|
||||
// move the last item to local variable to be processed
|
||||
// move the last item to a local variable to be processed
|
||||
basic_json current_item(std::move(stack.back()));
|
||||
stack.pop_back();
|
||||
|
||||
@ -20676,7 +20676,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
current_item.m_data.m_value.object->clear();
|
||||
}
|
||||
|
||||
// it's now safe that current_item get destructed
|
||||
// it's now safe that current_item gets destructed
|
||||
// since it doesn't have any children
|
||||
}
|
||||
}
|
||||
@ -20984,20 +20984,20 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
{
|
||||
// The cast is to ensure op[size_type] is called, bearing in mind size_type may not be int;
|
||||
// (many string types can be constructed from 0 via its null-pointer guise, so we get a
|
||||
// broken call to op[key_type], the wrong semantics and a 4804 warning on Windows)
|
||||
// broken call to op[key_type], the wrong semantics, and a 4804 warning on Windows)
|
||||
return element_ref->is_array() && element_ref->size() == 2 && (*element_ref)[static_cast<size_type>(0)].is_string();
|
||||
});
|
||||
|
||||
// adjust type if type deduction is not wanted
|
||||
if (!type_deduction)
|
||||
{
|
||||
// if array is wanted, do not create an object though possible
|
||||
// if an array is wanted, do not create an object though possible
|
||||
if (manual_type == value_t::array)
|
||||
{
|
||||
is_an_object = false;
|
||||
}
|
||||
|
||||
// if object is wanted but impossible, throw an exception
|
||||
// if an object is wanted but impossible, throw an exception
|
||||
if (JSON_HEDLEY_UNLIKELY(manual_type == value_t::object && !is_an_object))
|
||||
{
|
||||
JSON_THROW(type_error::create(301, "cannot create object from initializer list", nullptr));
|
||||
@ -21006,7 +21006,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
|
||||
if (is_an_object)
|
||||
{
|
||||
// the initializer list is a list of pairs -> create object
|
||||
// the initializer list is a list of pairs -> create an object
|
||||
m_data.m_type = value_t::object;
|
||||
m_data.m_value = value_t::object;
|
||||
|
||||
@ -21020,7 +21020,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
}
|
||||
else
|
||||
{
|
||||
// the initializer list describes an array -> create array
|
||||
// the initializer list describes an array -> create an array
|
||||
m_data.m_type = value_t::array;
|
||||
m_data.m_value.array = create<array_t>(init.begin(), init.end());
|
||||
}
|
||||
@ -21108,16 +21108,16 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_ASSERT(first.m_object != nullptr);
|
||||
JSON_ASSERT(last.m_object != nullptr);
|
||||
|
||||
// make sure iterator fits the current value
|
||||
// make sure the iterator fits the current value
|
||||
if (JSON_HEDLEY_UNLIKELY(first.m_object != last.m_object))
|
||||
{
|
||||
JSON_THROW(invalid_iterator::create(201, "iterators are not compatible", nullptr));
|
||||
}
|
||||
|
||||
// copy type from first iterator
|
||||
// copy type from the first iterator
|
||||
m_data.m_type = first.m_object->m_data.m_type;
|
||||
|
||||
// check if iterator range is complete for primitive values
|
||||
// check if the iterator range is complete for primitive values
|
||||
switch (m_data.m_type)
|
||||
{
|
||||
case value_t::boolean:
|
||||
@ -21297,7 +21297,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
, end_position(other.end_position) // cppcheck-suppress[accessForwarded] TODO check
|
||||
#endif
|
||||
{
|
||||
// check that passed value is valid
|
||||
// check that the passed value is valid
|
||||
other.assert_invariant(false); // cppcheck-suppress[accessForwarded]
|
||||
|
||||
// invalidate payload
|
||||
@ -21323,7 +21323,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
std::is_nothrow_move_assignable<json_base_class_t>::value
|
||||
)
|
||||
{
|
||||
// check that passed value is valid
|
||||
// check that the passed value is valid
|
||||
other.assert_invariant();
|
||||
|
||||
using std::swap;
|
||||
@ -22039,7 +22039,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
}
|
||||
JSON_CATCH (std::out_of_range&)
|
||||
{
|
||||
// create better exception explanation
|
||||
// create a better exception explanation
|
||||
JSON_THROW(out_of_range::create(401, detail::concat("array index ", std::to_string(idx), " is out of range"), this));
|
||||
} // cppcheck-suppress[missingReturn]
|
||||
}
|
||||
@ -22062,7 +22062,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
}
|
||||
JSON_CATCH (std::out_of_range&)
|
||||
{
|
||||
// create better exception explanation
|
||||
// create a better exception explanation
|
||||
JSON_THROW(out_of_range::create(401, detail::concat("array index ", std::to_string(idx), " is out of range"), this));
|
||||
} // cppcheck-suppress[missingReturn]
|
||||
}
|
||||
@ -22152,7 +22152,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||
reference operator[](size_type idx)
|
||||
{
|
||||
// implicitly convert null value to an empty array
|
||||
// implicitly convert a null value to an empty array
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::array;
|
||||
@ -22163,7 +22163,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// operator[] only works for arrays
|
||||
if (JSON_HEDLEY_LIKELY(is_array()))
|
||||
{
|
||||
// fill up array with null values if given idx is outside range
|
||||
// fill up the array with null values if given idx is outside the range
|
||||
if (idx >= m_data.m_value.array->size())
|
||||
{
|
||||
#if JSON_DIAGNOSTICS
|
||||
@ -22211,7 +22211,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator%5B%5D/
|
||||
reference operator[](typename object_t::key_type key) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// implicitly convert null value to an empty object
|
||||
// implicitly convert a null value to an empty object
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::object;
|
||||
@ -22264,7 +22264,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
detail::is_usable_as_basic_json_key_type<basic_json_t, KeyType>::value, int > = 0 >
|
||||
reference operator[](KeyType && key)
|
||||
{
|
||||
// implicitly convert null value to an empty object
|
||||
// implicitly convert a null value to an empty object
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::object;
|
||||
@ -22321,7 +22321,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// value only works for objects
|
||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||
{
|
||||
// if key is found, return value and given default value otherwise
|
||||
// If 'key' is found, return its value. Otherwise, return `default_value'.
|
||||
const auto it = find(key);
|
||||
if (it != end())
|
||||
{
|
||||
@ -22346,7 +22346,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// value only works for objects
|
||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||
{
|
||||
// if key is found, return value and given default value otherwise
|
||||
// If 'key' is found, return its value. Otherwise, return `default_value'.
|
||||
const auto it = find(key);
|
||||
if (it != end())
|
||||
{
|
||||
@ -22372,7 +22372,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// value only works for objects
|
||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||
{
|
||||
// if key is found, return value and given default value otherwise
|
||||
// If 'key' is found, return its value. Otherwise, return `default_value'.
|
||||
const auto it = find(std::forward<KeyType>(key));
|
||||
if (it != end())
|
||||
{
|
||||
@ -22399,7 +22399,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// value only works for objects
|
||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||
{
|
||||
// if key is found, return value and given default value otherwise
|
||||
// If 'key' is found, return its value. Otherwise, return `default_value'.
|
||||
const auto it = find(std::forward<KeyType>(key));
|
||||
if (it != end())
|
||||
{
|
||||
@ -22422,7 +22422,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// value only works for objects
|
||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||
{
|
||||
// if pointer resolves a value, return it or use default value
|
||||
// If the pointer resolves to a value, return it. Otherwise, return
|
||||
// 'default_value'.
|
||||
JSON_TRY
|
||||
{
|
||||
return ptr.get_checked(this).template get<ValueType>();
|
||||
@ -22447,7 +22448,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// value only works for objects
|
||||
if (JSON_HEDLEY_LIKELY(is_object()))
|
||||
{
|
||||
// if pointer resolves a value, return it or use default value
|
||||
// If the pointer resolves to a value, return it. Otherwise, return
|
||||
// 'default_value'.
|
||||
JSON_TRY
|
||||
{
|
||||
return ptr.get_checked(this).template get<ReturnType>();
|
||||
@ -22521,7 +22523,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int > = 0 >
|
||||
IteratorType erase(IteratorType pos) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// make sure iterator fits the current value
|
||||
// make sure the iterator fits the current value
|
||||
if (JSON_HEDLEY_UNLIKELY(this != pos.m_object))
|
||||
{
|
||||
JSON_THROW(invalid_iterator::create(202, "iterator does not fit current value", this));
|
||||
@ -22591,7 +22593,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
std::is_same<IteratorType, typename basic_json_t::const_iterator>::value, int > = 0 >
|
||||
IteratorType erase(IteratorType first, IteratorType last) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// make sure iterator fits the current value
|
||||
// make sure the iterator fits the current value
|
||||
if (JSON_HEDLEY_UNLIKELY(this != first.m_object || this != last.m_object))
|
||||
{
|
||||
JSON_THROW(invalid_iterator::create(203, "iterators do not fit current value", this));
|
||||
@ -23186,7 +23188,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_THROW(type_error::create(308, detail::concat("cannot use push_back() with ", type_name()), this));
|
||||
}
|
||||
|
||||
// transform null object into an array
|
||||
// transform a null object into an array
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::array;
|
||||
@ -23194,7 +23196,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
assert_invariant();
|
||||
}
|
||||
|
||||
// add element to array (move semantics)
|
||||
// add the element to the array (move semantics)
|
||||
const auto old_capacity = m_data.m_value.array->capacity();
|
||||
m_data.m_value.array->push_back(std::move(val));
|
||||
set_parent(m_data.m_value.array->back(), old_capacity);
|
||||
@ -23219,7 +23221,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_THROW(type_error::create(308, detail::concat("cannot use push_back() with ", type_name()), this));
|
||||
}
|
||||
|
||||
// transform null object into an array
|
||||
// transform a null object into an array
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::array;
|
||||
@ -23227,7 +23229,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
assert_invariant();
|
||||
}
|
||||
|
||||
// add element to array
|
||||
// add the element to the array
|
||||
const auto old_capacity = m_data.m_value.array->capacity();
|
||||
m_data.m_value.array->push_back(val);
|
||||
set_parent(m_data.m_value.array->back(), old_capacity);
|
||||
@ -23251,7 +23253,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_THROW(type_error::create(308, detail::concat("cannot use push_back() with ", type_name()), this));
|
||||
}
|
||||
|
||||
// transform null object into an object
|
||||
// transform a null object into an object
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::object;
|
||||
@ -23259,7 +23261,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
assert_invariant();
|
||||
}
|
||||
|
||||
// add element to object
|
||||
// add the element to the object
|
||||
auto res = m_data.m_value.object->insert(val);
|
||||
set_parent(res.first->second);
|
||||
}
|
||||
@ -23307,7 +23309,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_THROW(type_error::create(311, detail::concat("cannot use emplace_back() with ", type_name()), this));
|
||||
}
|
||||
|
||||
// transform null object into an array
|
||||
// transform a null object into an array
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::array;
|
||||
@ -23315,7 +23317,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
assert_invariant();
|
||||
}
|
||||
|
||||
// add element to array (perfect forwarding)
|
||||
// add the element to the array (perfect forwarding)
|
||||
const auto old_capacity = m_data.m_value.array->capacity();
|
||||
m_data.m_value.array->emplace_back(std::forward<Args>(args)...);
|
||||
return set_parent(m_data.m_value.array->back(), old_capacity);
|
||||
@ -23332,7 +23334,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
JSON_THROW(type_error::create(311, detail::concat("cannot use emplace() with ", type_name()), this));
|
||||
}
|
||||
|
||||
// transform null object into an object
|
||||
// transform a null object into an object
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::object;
|
||||
@ -23340,11 +23342,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
assert_invariant();
|
||||
}
|
||||
|
||||
// add element to array (perfect forwarding)
|
||||
// add the element to the array (perfect forwarding)
|
||||
auto res = m_data.m_value.object->emplace(std::forward<Args>(args)...);
|
||||
set_parent(res.first->second);
|
||||
|
||||
// create result iterator and set iterator to the result of emplace
|
||||
// create a result iterator and set iterator to the result of emplace
|
||||
auto it = begin();
|
||||
it.m_it.object_iterator = res.first;
|
||||
|
||||
@ -23508,7 +23510,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/update/
|
||||
void update(const_iterator first, const_iterator last, bool merge_objects = false) // NOLINT(performance-unnecessary-value-param)
|
||||
{
|
||||
// implicitly convert null value to an empty object
|
||||
// implicitly convert a null value to an empty object
|
||||
if (is_null())
|
||||
{
|
||||
m_data.m_type = value_t::object;
|
||||
@ -24068,7 +24070,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// @sa https://json.nlohmann.me/api/basic_json/operator_ltlt/
|
||||
friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
|
||||
{
|
||||
// read width member and use it as indentation parameter if nonzero
|
||||
// read width member and use it as the indentation parameter if nonzero
|
||||
const bool pretty_print = o.width() > 0;
|
||||
const auto indentation = pretty_print ? o.width() : 0;
|
||||
|
||||
@ -24863,7 +24865,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
result.at(top_pointer);
|
||||
}
|
||||
|
||||
// get reference to parent of JSON pointer ptr
|
||||
// get reference to the parent of the JSON pointer ptr
|
||||
const auto last_path = ptr.back();
|
||||
ptr.pop_back();
|
||||
// parent must exist when performing patch add per RFC6902 specs
|
||||
@ -24901,7 +24903,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
break;
|
||||
}
|
||||
|
||||
// if there exists a parent it cannot be primitive
|
||||
// if there exists a parent, it cannot be primitive
|
||||
case value_t::string: // LCOV_EXCL_LINE
|
||||
case value_t::boolean: // LCOV_EXCL_LINE
|
||||
case value_t::number_integer: // LCOV_EXCL_LINE
|
||||
@ -24917,7 +24919,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// wrapper for "remove" operation; remove value at ptr
|
||||
const auto operation_remove = [this, & result](json_pointer & ptr)
|
||||
{
|
||||
// get reference to parent of JSON pointer ptr
|
||||
// get reference to the parent of the JSON pointer ptr
|
||||
const auto last_path = ptr.back();
|
||||
ptr.pop_back();
|
||||
basic_json& parent = result.at(ptr);
|
||||
@ -24963,14 +24965,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// context-sensitive error message
|
||||
const auto error_msg = (op == "op") ? "operation" : detail::concat("operation '", op, '\''); // NOLINT(bugprone-unused-local-non-trivial-variable)
|
||||
|
||||
// check if desired value is present
|
||||
// check if the desired value is present
|
||||
if (JSON_HEDLEY_UNLIKELY(it == val.m_data.m_value.object->end()))
|
||||
{
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
JSON_THROW(parse_error::create(105, 0, detail::concat(error_msg, " must have member '", member, "'"), &val));
|
||||
}
|
||||
|
||||
// check if result is of type string
|
||||
// check if the result is of type string
|
||||
if (JSON_HEDLEY_UNLIKELY(string_type && !it->second.is_string()))
|
||||
{
|
||||
// NOLINTNEXTLINE(performance-inefficient-string-concatenation)
|
||||
@ -25059,7 +25061,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// ignore out of range errors: success remains false
|
||||
}
|
||||
|
||||
// throw an exception if test fails
|
||||
// throw an exception if the test fails
|
||||
if (JSON_HEDLEY_UNLIKELY(!success))
|
||||
{
|
||||
JSON_THROW(other_error::create(501, detail::concat("unsuccessful: ", val.dump()), &val));
|
||||
@ -25097,7 +25099,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
// the patch
|
||||
basic_json result(value_t::array);
|
||||
|
||||
// if the values are the same, return empty patch
|
||||
// if the values are the same, return an empty patch
|
||||
if (source == target)
|
||||
{
|
||||
return result;
|
||||
@ -25211,7 +25213,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
case value_t::discarded:
|
||||
default:
|
||||
{
|
||||
// both primitive type: replace value
|
||||
// both primitive types: replace value
|
||||
result.push_back(
|
||||
{
|
||||
{"op", "replace"}, {"path", path}, {"value", target}
|
||||
|
Reference in New Issue
Block a user