mirror of
https://github.com/nlohmann/json
synced 2024-12-24 17:41:05 +00:00
🔨 clean up
This commit is contained in:
parent
9fc093c9e0
commit
8d3f4f21bc
@ -204,7 +204,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
const std::uint64_t E = bits >> (kPrecision - 1);
|
||||
const std::uint64_t F = bits & (kHiddenBit - 1);
|
||||
|
||||
const bool is_denormal = (E == 0);
|
||||
const bool is_denormal = E == 0;
|
||||
const diyfp v = is_denormal
|
||||
? diyfp(F, kMinExp)
|
||||
: diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
|
||||
@ -230,7 +230,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
// -----------------+------+------+-------------+-------------+--- (B)
|
||||
// v- m- v m+ v+
|
||||
|
||||
const bool lower_boundary_is_closer = (F == 0 and E > 1);
|
||||
const bool lower_boundary_is_closer = F == 0 and E > 1;
|
||||
const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
|
||||
const diyfp m_minus = lower_boundary_is_closer
|
||||
? diyfp(4 * v.f - 1, v.e - 2) // (B)
|
||||
|
@ -91,10 +91,8 @@ class binary_reader
|
||||
result = parse_ubjson_internal();
|
||||
break;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
assert(false);
|
||||
// LCOV_EXCL_STOP
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
// strict mode: next byte must be EOF
|
||||
@ -128,7 +126,7 @@ class binary_reader
|
||||
*/
|
||||
static constexpr bool little_endianess(int num = 1) noexcept
|
||||
{
|
||||
return (*reinterpret_cast<char*>(&num) == 1);
|
||||
return *reinterpret_cast<char*>(&num) == 1;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -305,13 +303,10 @@ class binary_reader
|
||||
return false;
|
||||
}
|
||||
|
||||
if (not is_array)
|
||||
{
|
||||
if (not sax->key(key))
|
||||
if (not is_array and not sax->key(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position)))
|
||||
{
|
||||
@ -1818,7 +1813,7 @@ class binary_reader
|
||||
int get()
|
||||
{
|
||||
++chars_read;
|
||||
return (current = ia->get_character());
|
||||
return current = ia->get_character();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1964,10 +1959,8 @@ class binary_reader
|
||||
error_msg += "BSON";
|
||||
break;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
assert(false);
|
||||
// LCOV_EXCL_STOP
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
return error_msg + " " + context + ": " + detail;
|
||||
|
@ -303,13 +303,12 @@ class json_sax_dom_parser
|
||||
ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
|
||||
return &(ref_stack.back()->m_value.array->back());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
assert(ref_stack.back()->is_object())
|
||||
assert(object_element);
|
||||
*object_element = BasicJsonType(std::forward<Value>(v));
|
||||
return object_element;
|
||||
}
|
||||
}
|
||||
|
||||
/// the parsed JSON value
|
||||
BasicJsonType& root;
|
||||
@ -395,13 +394,9 @@ class json_sax_dom_callback_parser
|
||||
ref_stack.push_back(val.second);
|
||||
|
||||
// check object limit
|
||||
if (ref_stack.back())
|
||||
if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive object size: " + std::to_string(len)));
|
||||
}
|
||||
JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len)));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -426,25 +421,20 @@ class json_sax_dom_callback_parser
|
||||
|
||||
bool end_object()
|
||||
{
|
||||
if (ref_stack.back())
|
||||
{
|
||||
if (not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
|
||||
if (ref_stack.back() and not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
|
||||
{
|
||||
// discard object
|
||||
*ref_stack.back() = discarded;
|
||||
}
|
||||
}
|
||||
|
||||
assert(not ref_stack.empty());
|
||||
assert(not keep_stack.empty());
|
||||
ref_stack.pop_back();
|
||||
keep_stack.pop_back();
|
||||
|
||||
if (not ref_stack.empty() and ref_stack.back())
|
||||
if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_object())
|
||||
{
|
||||
// remove discarded value
|
||||
if (ref_stack.back()->is_object())
|
||||
{
|
||||
for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
|
||||
{
|
||||
if (it->is_discarded())
|
||||
@ -454,7 +444,6 @@ class json_sax_dom_callback_parser
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -468,13 +457,9 @@ class json_sax_dom_callback_parser
|
||||
ref_stack.push_back(val.second);
|
||||
|
||||
// check array limit
|
||||
if (ref_stack.back())
|
||||
if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive array size: " + std::to_string(len)));
|
||||
}
|
||||
JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len)));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -500,13 +485,10 @@ class json_sax_dom_callback_parser
|
||||
keep_stack.pop_back();
|
||||
|
||||
// remove discarded value
|
||||
if (not keep and not ref_stack.empty())
|
||||
{
|
||||
if (ref_stack.back()->is_array())
|
||||
if (not keep and not ref_stack.empty() and ref_stack.back()->is_array())
|
||||
{
|
||||
ref_stack.back()->m_value.array->pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -600,13 +582,15 @@ class json_sax_dom_callback_parser
|
||||
// we now only expect arrays and objects
|
||||
assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
|
||||
|
||||
// array
|
||||
if (ref_stack.back()->is_array())
|
||||
{
|
||||
ref_stack.back()->m_value.array->push_back(std::move(value));
|
||||
return {true, &(ref_stack.back()->m_value.array->back())};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// object
|
||||
assert(ref_stack.back()->is_object())
|
||||
// check if we should store an element for the current key
|
||||
assert(not key_keep_stack.empty());
|
||||
const bool store_element = key_keep_stack.back();
|
||||
@ -621,7 +605,6 @@ class json_sax_dom_callback_parser
|
||||
*object_element = std::move(value);
|
||||
return {true, object_element};
|
||||
}
|
||||
}
|
||||
|
||||
/// the parsed JSON value
|
||||
BasicJsonType& root;
|
||||
|
@ -908,13 +908,9 @@ class lexer
|
||||
goto scan_number_any1;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
{
|
||||
// all other characters are rejected outside scan_number()
|
||||
assert(false);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
scan_number_minus:
|
||||
|
@ -459,7 +459,7 @@ class parser
|
||||
/// get next token from lexer
|
||||
token_type get_token()
|
||||
{
|
||||
return (last_token = m_lexer.scan());
|
||||
return last_token = m_lexer.scan();
|
||||
}
|
||||
|
||||
std::string exception_message(const token_type expected, const std::string& context)
|
||||
|
@ -344,7 +344,7 @@ class json_pointer
|
||||
std::all_of(reference_token.begin(), reference_token.end(),
|
||||
[](const char x)
|
||||
{
|
||||
return (x >= '0' and x <= '9');
|
||||
return x >= '0' and x <= '9';
|
||||
});
|
||||
|
||||
// change value to array for numbers or "-" or to object otherwise
|
||||
@ -793,7 +793,7 @@ class json_pointer
|
||||
friend bool operator==(json_pointer const& lhs,
|
||||
json_pointer const& rhs) noexcept
|
||||
{
|
||||
return (lhs.reference_tokens == rhs.reference_tokens);
|
||||
return lhs.reference_tokens == rhs.reference_tokens;
|
||||
}
|
||||
|
||||
friend bool operator!=(json_pointer const& lhs,
|
||||
|
@ -88,8 +88,8 @@
|
||||
|
||||
// manual branch prediction
|
||||
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
||||
#define JSON_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#define JSON_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#define JSON_LIKELY(x) __builtin_expect(static_cast<bool>(x), 1)
|
||||
#define JSON_UNLIKELY(x) __builtin_expect(static_cast<bool>(x), 0)
|
||||
#else
|
||||
#define JSON_LIKELY(x) x
|
||||
#define JSON_UNLIKELY(x) x
|
||||
|
@ -279,12 +279,10 @@ class serializer
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/*!
|
||||
@ -480,11 +478,9 @@ class serializer
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -545,13 +541,11 @@ class serializer
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief count digits
|
||||
@ -755,7 +749,7 @@ class serializer
|
||||
std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
|
||||
[](char c)
|
||||
{
|
||||
return (c == '.' or c == 'e');
|
||||
return c == '.' or c == 'e';
|
||||
});
|
||||
|
||||
if (value_is_int_like)
|
||||
|
@ -1325,7 +1325,7 @@ class basic_json
|
||||
case value_t::discarded:
|
||||
m_type = value_t::discarded;
|
||||
break;
|
||||
default:
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
assert_invariant();
|
||||
@ -1414,7 +1414,7 @@ class basic_json
|
||||
bool is_an_object = std::all_of(init.begin(), init.end(),
|
||||
[](const detail::json_ref<basic_json>& element_ref)
|
||||
{
|
||||
return (element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string());
|
||||
return element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string();
|
||||
});
|
||||
|
||||
// adjust type if type deduction is not wanted
|
||||
@ -2099,7 +2099,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_null() const noexcept
|
||||
{
|
||||
return (m_type == value_t::null);
|
||||
return m_type == value_t::null;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2121,7 +2121,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_boolean() const noexcept
|
||||
{
|
||||
return (m_type == value_t::boolean);
|
||||
return m_type == value_t::boolean;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2180,7 +2180,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_number_integer() const noexcept
|
||||
{
|
||||
return (m_type == value_t::number_integer or m_type == value_t::number_unsigned);
|
||||
return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2208,7 +2208,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_number_unsigned() const noexcept
|
||||
{
|
||||
return (m_type == value_t::number_unsigned);
|
||||
return m_type == value_t::number_unsigned;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2236,7 +2236,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_number_float() const noexcept
|
||||
{
|
||||
return (m_type == value_t::number_float);
|
||||
return m_type == value_t::number_float;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2258,7 +2258,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_object() const noexcept
|
||||
{
|
||||
return (m_type == value_t::object);
|
||||
return m_type == value_t::object;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2280,7 +2280,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_array() const noexcept
|
||||
{
|
||||
return (m_type == value_t::array);
|
||||
return m_type == value_t::array;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2302,7 +2302,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_string() const noexcept
|
||||
{
|
||||
return (m_type == value_t::string);
|
||||
return m_type == value_t::string;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -2329,7 +2329,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_discarded() const noexcept
|
||||
{
|
||||
return (m_type == value_t::discarded);
|
||||
return m_type == value_t::discarded;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -3990,7 +3990,7 @@ class basic_json
|
||||
template<typename KeyT>
|
||||
bool contains(KeyT&& key) const
|
||||
{
|
||||
return (is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end());
|
||||
return is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
|
||||
}
|
||||
|
||||
/// @}
|
||||
@ -5569,28 +5569,28 @@ class basic_json
|
||||
switch (lhs_type)
|
||||
{
|
||||
case value_t::array:
|
||||
return (*lhs.m_value.array == *rhs.m_value.array);
|
||||
return *lhs.m_value.array == *rhs.m_value.array;
|
||||
|
||||
case value_t::object:
|
||||
return (*lhs.m_value.object == *rhs.m_value.object);
|
||||
return *lhs.m_value.object == *rhs.m_value.object;
|
||||
|
||||
case value_t::null:
|
||||
return true;
|
||||
|
||||
case value_t::string:
|
||||
return (*lhs.m_value.string == *rhs.m_value.string);
|
||||
return *lhs.m_value.string == *rhs.m_value.string;
|
||||
|
||||
case value_t::boolean:
|
||||
return (lhs.m_value.boolean == rhs.m_value.boolean);
|
||||
return lhs.m_value.boolean == rhs.m_value.boolean;
|
||||
|
||||
case value_t::number_integer:
|
||||
return (lhs.m_value.number_integer == rhs.m_value.number_integer);
|
||||
return lhs.m_value.number_integer == rhs.m_value.number_integer;
|
||||
|
||||
case value_t::number_unsigned:
|
||||
return (lhs.m_value.number_unsigned == rhs.m_value.number_unsigned);
|
||||
return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
|
||||
|
||||
case value_t::number_float:
|
||||
return (lhs.m_value.number_float == rhs.m_value.number_float);
|
||||
return lhs.m_value.number_float == rhs.m_value.number_float;
|
||||
|
||||
default:
|
||||
return false;
|
||||
@ -5598,27 +5598,27 @@ class basic_json
|
||||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
|
||||
{
|
||||
return (static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float);
|
||||
return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
|
||||
{
|
||||
return (lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer));
|
||||
return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
|
||||
}
|
||||
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
|
||||
{
|
||||
return (static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float);
|
||||
return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
|
||||
{
|
||||
return (lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned));
|
||||
return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
|
||||
}
|
||||
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
|
||||
{
|
||||
return (static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer);
|
||||
return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
|
||||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
|
||||
{
|
||||
return (lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned));
|
||||
return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -5632,7 +5632,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs == basic_json(rhs));
|
||||
return lhs == basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5643,7 +5643,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) == rhs);
|
||||
return basic_json(lhs) == rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5677,7 +5677,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs != basic_json(rhs));
|
||||
return lhs != basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5688,7 +5688,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) != rhs);
|
||||
return basic_json(lhs) != rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5727,7 +5727,7 @@ class basic_json
|
||||
switch (lhs_type)
|
||||
{
|
||||
case value_t::array:
|
||||
return (*lhs.m_value.array) < (*rhs.m_value.array);
|
||||
return *lhs.m_value.array < *rhs.m_value.array;
|
||||
|
||||
case value_t::object:
|
||||
return *lhs.m_value.object < *rhs.m_value.object;
|
||||
@ -5793,7 +5793,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs < basic_json(rhs));
|
||||
return lhs < basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5804,7 +5804,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) < rhs);
|
||||
return basic_json(lhs) < rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5839,7 +5839,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs <= basic_json(rhs));
|
||||
return lhs <= basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5850,7 +5850,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) <= rhs);
|
||||
return basic_json(lhs) <= rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5885,7 +5885,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs > basic_json(rhs));
|
||||
return lhs > basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5896,7 +5896,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) > rhs);
|
||||
return basic_json(lhs) > rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5931,7 +5931,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs >= basic_json(rhs));
|
||||
return lhs >= basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5942,7 +5942,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) >= rhs);
|
||||
return basic_json(lhs) >= rhs;
|
||||
}
|
||||
|
||||
/// @}
|
||||
@ -5988,8 +5988,8 @@ class basic_json
|
||||
friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
|
||||
{
|
||||
// read width member and use it as indentation parameter if nonzero
|
||||
const bool pretty_print = (o.width() > 0);
|
||||
const auto indentation = (pretty_print ? o.width() : 0);
|
||||
const bool pretty_print = o.width() > 0;
|
||||
const auto indentation = pretty_print ? o.width() : 0;
|
||||
|
||||
// reset width to 0 for subsequent calls to this stream
|
||||
o.width(0);
|
||||
@ -7495,9 +7495,9 @@ class basic_json
|
||||
if (ptr.empty())
|
||||
{
|
||||
result = val;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// make sure the top element of the pointer exists
|
||||
json_pointer top_pointer = ptr.top();
|
||||
if (top_pointer != ptr)
|
||||
@ -7541,14 +7541,9 @@ class basic_json
|
||||
break;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
{
|
||||
// if there exists a parent it cannot be primitive
|
||||
assert(false);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
};
|
||||
|
||||
@ -7768,9 +7763,9 @@ class basic_json
|
||||
{
|
||||
{"op", "replace"}, {"path", path}, {"value", target}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
switch (source.type())
|
||||
{
|
||||
case value_t::array:
|
||||
@ -7869,7 +7864,6 @@ class basic_json
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -539,8 +539,8 @@ class other_error : public exception
|
||||
|
||||
// manual branch prediction
|
||||
#if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__)
|
||||
#define JSON_LIKELY(x) __builtin_expect(!!(x), 1)
|
||||
#define JSON_UNLIKELY(x) __builtin_expect(!!(x), 0)
|
||||
#define JSON_LIKELY(x) __builtin_expect(static_cast<bool>(x), 1)
|
||||
#define JSON_UNLIKELY(x) __builtin_expect(static_cast<bool>(x), 0)
|
||||
#else
|
||||
#define JSON_LIKELY(x) x
|
||||
#define JSON_UNLIKELY(x) x
|
||||
@ -2981,13 +2981,12 @@ class json_sax_dom_parser
|
||||
ref_stack.back()->m_value.array->emplace_back(std::forward<Value>(v));
|
||||
return &(ref_stack.back()->m_value.array->back());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
assert(ref_stack.back()->is_object())
|
||||
assert(object_element);
|
||||
*object_element = BasicJsonType(std::forward<Value>(v));
|
||||
return object_element;
|
||||
}
|
||||
}
|
||||
|
||||
/// the parsed JSON value
|
||||
BasicJsonType& root;
|
||||
@ -3073,13 +3072,9 @@ class json_sax_dom_callback_parser
|
||||
ref_stack.push_back(val.second);
|
||||
|
||||
// check object limit
|
||||
if (ref_stack.back())
|
||||
if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive object size: " + std::to_string(len)));
|
||||
}
|
||||
JSON_THROW(out_of_range::create(408, "excessive object size: " + std::to_string(len)));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -3104,25 +3099,20 @@ class json_sax_dom_callback_parser
|
||||
|
||||
bool end_object()
|
||||
{
|
||||
if (ref_stack.back())
|
||||
{
|
||||
if (not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
|
||||
if (ref_stack.back() and not callback(static_cast<int>(ref_stack.size()) - 1, parse_event_t::object_end, *ref_stack.back()))
|
||||
{
|
||||
// discard object
|
||||
*ref_stack.back() = discarded;
|
||||
}
|
||||
}
|
||||
|
||||
assert(not ref_stack.empty());
|
||||
assert(not keep_stack.empty());
|
||||
ref_stack.pop_back();
|
||||
keep_stack.pop_back();
|
||||
|
||||
if (not ref_stack.empty() and ref_stack.back())
|
||||
if (not ref_stack.empty() and ref_stack.back() and ref_stack.back()->is_object())
|
||||
{
|
||||
// remove discarded value
|
||||
if (ref_stack.back()->is_object())
|
||||
{
|
||||
for (auto it = ref_stack.back()->begin(); it != ref_stack.back()->end(); ++it)
|
||||
{
|
||||
if (it->is_discarded())
|
||||
@ -3132,7 +3122,6 @@ class json_sax_dom_callback_parser
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -3146,13 +3135,9 @@ class json_sax_dom_callback_parser
|
||||
ref_stack.push_back(val.second);
|
||||
|
||||
// check array limit
|
||||
if (ref_stack.back())
|
||||
if (ref_stack.back() and JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
if (JSON_UNLIKELY(len != std::size_t(-1) and len > ref_stack.back()->max_size()))
|
||||
{
|
||||
JSON_THROW(out_of_range::create(408,
|
||||
"excessive array size: " + std::to_string(len)));
|
||||
}
|
||||
JSON_THROW(out_of_range::create(408, "excessive array size: " + std::to_string(len)));
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -3178,13 +3163,10 @@ class json_sax_dom_callback_parser
|
||||
keep_stack.pop_back();
|
||||
|
||||
// remove discarded value
|
||||
if (not keep and not ref_stack.empty())
|
||||
{
|
||||
if (ref_stack.back()->is_array())
|
||||
if (not keep and not ref_stack.empty() and ref_stack.back()->is_array())
|
||||
{
|
||||
ref_stack.back()->m_value.array->pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -3278,13 +3260,15 @@ class json_sax_dom_callback_parser
|
||||
// we now only expect arrays and objects
|
||||
assert(ref_stack.back()->is_array() or ref_stack.back()->is_object());
|
||||
|
||||
// array
|
||||
if (ref_stack.back()->is_array())
|
||||
{
|
||||
ref_stack.back()->m_value.array->push_back(std::move(value));
|
||||
return {true, &(ref_stack.back()->m_value.array->back())};
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// object
|
||||
assert(ref_stack.back()->is_object())
|
||||
// check if we should store an element for the current key
|
||||
assert(not key_keep_stack.empty());
|
||||
const bool store_element = key_keep_stack.back();
|
||||
@ -3299,7 +3283,6 @@ class json_sax_dom_callback_parser
|
||||
*object_element = std::move(value);
|
||||
return {true, object_element};
|
||||
}
|
||||
}
|
||||
|
||||
/// the parsed JSON value
|
||||
BasicJsonType& root;
|
||||
@ -3616,10 +3599,8 @@ class binary_reader
|
||||
result = parse_ubjson_internal();
|
||||
break;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
assert(false);
|
||||
// LCOV_EXCL_STOP
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
// strict mode: next byte must be EOF
|
||||
@ -3653,7 +3634,7 @@ class binary_reader
|
||||
*/
|
||||
static constexpr bool little_endianess(int num = 1) noexcept
|
||||
{
|
||||
return (*reinterpret_cast<char*>(&num) == 1);
|
||||
return *reinterpret_cast<char*>(&num) == 1;
|
||||
}
|
||||
|
||||
private:
|
||||
@ -3830,13 +3811,10 @@ class binary_reader
|
||||
return false;
|
||||
}
|
||||
|
||||
if (not is_array)
|
||||
{
|
||||
if (not sax->key(key))
|
||||
if (not is_array and not sax->key(key))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (JSON_UNLIKELY(not parse_bson_element_internal(element_type, element_type_parse_position)))
|
||||
{
|
||||
@ -5343,7 +5321,7 @@ class binary_reader
|
||||
int get()
|
||||
{
|
||||
++chars_read;
|
||||
return (current = ia->get_character());
|
||||
return current = ia->get_character();
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -5489,10 +5467,8 @@ class binary_reader
|
||||
error_msg += "BSON";
|
||||
break;
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
assert(false);
|
||||
// LCOV_EXCL_STOP
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
return error_msg + " " + context + ": " + detail;
|
||||
@ -6433,13 +6409,9 @@ class lexer
|
||||
goto scan_number_any1;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
{
|
||||
// all other characters are rejected outside scan_number()
|
||||
assert(false);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
|
||||
scan_number_minus:
|
||||
@ -7501,7 +7473,7 @@ class parser
|
||||
/// get next token from lexer
|
||||
token_type get_token()
|
||||
{
|
||||
return (last_token = m_lexer.scan());
|
||||
return last_token = m_lexer.scan();
|
||||
}
|
||||
|
||||
std::string exception_message(const token_type expected, const std::string& context)
|
||||
@ -8791,7 +8763,7 @@ class json_pointer
|
||||
std::all_of(reference_token.begin(), reference_token.end(),
|
||||
[](const char x)
|
||||
{
|
||||
return (x >= '0' and x <= '9');
|
||||
return x >= '0' and x <= '9';
|
||||
});
|
||||
|
||||
// change value to array for numbers or "-" or to object otherwise
|
||||
@ -9240,7 +9212,7 @@ class json_pointer
|
||||
friend bool operator==(json_pointer const& lhs,
|
||||
json_pointer const& rhs) noexcept
|
||||
{
|
||||
return (lhs.reference_tokens == rhs.reference_tokens);
|
||||
return lhs.reference_tokens == rhs.reference_tokens;
|
||||
}
|
||||
|
||||
friend bool operator!=(json_pointer const& lhs,
|
||||
@ -11016,7 +10988,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
const std::uint64_t E = bits >> (kPrecision - 1);
|
||||
const std::uint64_t F = bits & (kHiddenBit - 1);
|
||||
|
||||
const bool is_denormal = (E == 0);
|
||||
const bool is_denormal = E == 0;
|
||||
const diyfp v = is_denormal
|
||||
? diyfp(F, kMinExp)
|
||||
: diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
|
||||
@ -11042,7 +11014,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
// -----------------+------+------+-------------+-------------+--- (B)
|
||||
// v- m- v m+ v+
|
||||
|
||||
const bool lower_boundary_is_closer = (F == 0 and E > 1);
|
||||
const bool lower_boundary_is_closer = F == 0 and E > 1;
|
||||
const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
|
||||
const diyfp m_minus = lower_boundary_is_closer
|
||||
? diyfp(4 * v.f - 1, v.e - 2) // (B)
|
||||
@ -12178,12 +12150,10 @@ class serializer
|
||||
return;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
/*!
|
||||
@ -12379,11 +12349,9 @@ class serializer
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -12444,13 +12412,11 @@ class serializer
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief count digits
|
||||
@ -12654,7 +12620,7 @@ class serializer
|
||||
std::none_of(number_buffer.begin(), number_buffer.begin() + len + 1,
|
||||
[](char c)
|
||||
{
|
||||
return (c == '.' or c == 'e');
|
||||
return c == '.' or c == 'e';
|
||||
});
|
||||
|
||||
if (value_is_int_like)
|
||||
@ -14002,7 +13968,7 @@ class basic_json
|
||||
case value_t::discarded:
|
||||
m_type = value_t::discarded;
|
||||
break;
|
||||
default:
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
assert_invariant();
|
||||
@ -14091,7 +14057,7 @@ class basic_json
|
||||
bool is_an_object = std::all_of(init.begin(), init.end(),
|
||||
[](const detail::json_ref<basic_json>& element_ref)
|
||||
{
|
||||
return (element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string());
|
||||
return element_ref->is_array() and element_ref->size() == 2 and (*element_ref)[0].is_string();
|
||||
});
|
||||
|
||||
// adjust type if type deduction is not wanted
|
||||
@ -14776,7 +14742,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_null() const noexcept
|
||||
{
|
||||
return (m_type == value_t::null);
|
||||
return m_type == value_t::null;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -14798,7 +14764,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_boolean() const noexcept
|
||||
{
|
||||
return (m_type == value_t::boolean);
|
||||
return m_type == value_t::boolean;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -14857,7 +14823,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_number_integer() const noexcept
|
||||
{
|
||||
return (m_type == value_t::number_integer or m_type == value_t::number_unsigned);
|
||||
return m_type == value_t::number_integer or m_type == value_t::number_unsigned;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -14885,7 +14851,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_number_unsigned() const noexcept
|
||||
{
|
||||
return (m_type == value_t::number_unsigned);
|
||||
return m_type == value_t::number_unsigned;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -14913,7 +14879,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_number_float() const noexcept
|
||||
{
|
||||
return (m_type == value_t::number_float);
|
||||
return m_type == value_t::number_float;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -14935,7 +14901,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_object() const noexcept
|
||||
{
|
||||
return (m_type == value_t::object);
|
||||
return m_type == value_t::object;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -14957,7 +14923,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_array() const noexcept
|
||||
{
|
||||
return (m_type == value_t::array);
|
||||
return m_type == value_t::array;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -14979,7 +14945,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_string() const noexcept
|
||||
{
|
||||
return (m_type == value_t::string);
|
||||
return m_type == value_t::string;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -15006,7 +14972,7 @@ class basic_json
|
||||
*/
|
||||
constexpr bool is_discarded() const noexcept
|
||||
{
|
||||
return (m_type == value_t::discarded);
|
||||
return m_type == value_t::discarded;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -16667,7 +16633,7 @@ class basic_json
|
||||
template<typename KeyT>
|
||||
bool contains(KeyT&& key) const
|
||||
{
|
||||
return (is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end());
|
||||
return is_object() and m_value.object->find(std::forward<KeyT>(key)) != m_value.object->end();
|
||||
}
|
||||
|
||||
/// @}
|
||||
@ -18246,28 +18212,28 @@ class basic_json
|
||||
switch (lhs_type)
|
||||
{
|
||||
case value_t::array:
|
||||
return (*lhs.m_value.array == *rhs.m_value.array);
|
||||
return *lhs.m_value.array == *rhs.m_value.array;
|
||||
|
||||
case value_t::object:
|
||||
return (*lhs.m_value.object == *rhs.m_value.object);
|
||||
return *lhs.m_value.object == *rhs.m_value.object;
|
||||
|
||||
case value_t::null:
|
||||
return true;
|
||||
|
||||
case value_t::string:
|
||||
return (*lhs.m_value.string == *rhs.m_value.string);
|
||||
return *lhs.m_value.string == *rhs.m_value.string;
|
||||
|
||||
case value_t::boolean:
|
||||
return (lhs.m_value.boolean == rhs.m_value.boolean);
|
||||
return lhs.m_value.boolean == rhs.m_value.boolean;
|
||||
|
||||
case value_t::number_integer:
|
||||
return (lhs.m_value.number_integer == rhs.m_value.number_integer);
|
||||
return lhs.m_value.number_integer == rhs.m_value.number_integer;
|
||||
|
||||
case value_t::number_unsigned:
|
||||
return (lhs.m_value.number_unsigned == rhs.m_value.number_unsigned);
|
||||
return lhs.m_value.number_unsigned == rhs.m_value.number_unsigned;
|
||||
|
||||
case value_t::number_float:
|
||||
return (lhs.m_value.number_float == rhs.m_value.number_float);
|
||||
return lhs.m_value.number_float == rhs.m_value.number_float;
|
||||
|
||||
default:
|
||||
return false;
|
||||
@ -18275,27 +18241,27 @@ class basic_json
|
||||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_float)
|
||||
{
|
||||
return (static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float);
|
||||
return static_cast<number_float_t>(lhs.m_value.number_integer) == rhs.m_value.number_float;
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_integer)
|
||||
{
|
||||
return (lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer));
|
||||
return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_integer);
|
||||
}
|
||||
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_float)
|
||||
{
|
||||
return (static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float);
|
||||
return static_cast<number_float_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_float;
|
||||
}
|
||||
else if (lhs_type == value_t::number_float and rhs_type == value_t::number_unsigned)
|
||||
{
|
||||
return (lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned));
|
||||
return lhs.m_value.number_float == static_cast<number_float_t>(rhs.m_value.number_unsigned);
|
||||
}
|
||||
else if (lhs_type == value_t::number_unsigned and rhs_type == value_t::number_integer)
|
||||
{
|
||||
return (static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer);
|
||||
return static_cast<number_integer_t>(lhs.m_value.number_unsigned) == rhs.m_value.number_integer;
|
||||
}
|
||||
else if (lhs_type == value_t::number_integer and rhs_type == value_t::number_unsigned)
|
||||
{
|
||||
return (lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned));
|
||||
return lhs.m_value.number_integer == static_cast<number_integer_t>(rhs.m_value.number_unsigned);
|
||||
}
|
||||
|
||||
return false;
|
||||
@ -18309,7 +18275,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator==(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs == basic_json(rhs));
|
||||
return lhs == basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18320,7 +18286,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator==(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) == rhs);
|
||||
return basic_json(lhs) == rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18354,7 +18320,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator!=(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs != basic_json(rhs));
|
||||
return lhs != basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18365,7 +18331,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator!=(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) != rhs);
|
||||
return basic_json(lhs) != rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18404,7 +18370,7 @@ class basic_json
|
||||
switch (lhs_type)
|
||||
{
|
||||
case value_t::array:
|
||||
return (*lhs.m_value.array) < (*rhs.m_value.array);
|
||||
return *lhs.m_value.array < *rhs.m_value.array;
|
||||
|
||||
case value_t::object:
|
||||
return *lhs.m_value.object < *rhs.m_value.object;
|
||||
@ -18470,7 +18436,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs < basic_json(rhs));
|
||||
return lhs < basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18481,7 +18447,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) < rhs);
|
||||
return basic_json(lhs) < rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18516,7 +18482,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<=(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs <= basic_json(rhs));
|
||||
return lhs <= basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18527,7 +18493,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator<=(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) <= rhs);
|
||||
return basic_json(lhs) <= rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18562,7 +18528,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs > basic_json(rhs));
|
||||
return lhs > basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18573,7 +18539,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) > rhs);
|
||||
return basic_json(lhs) > rhs;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18608,7 +18574,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>=(const_reference lhs, const ScalarType rhs) noexcept
|
||||
{
|
||||
return (lhs >= basic_json(rhs));
|
||||
return lhs >= basic_json(rhs);
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -18619,7 +18585,7 @@ class basic_json
|
||||
std::is_scalar<ScalarType>::value, int>::type = 0>
|
||||
friend bool operator>=(const ScalarType lhs, const_reference rhs) noexcept
|
||||
{
|
||||
return (basic_json(lhs) >= rhs);
|
||||
return basic_json(lhs) >= rhs;
|
||||
}
|
||||
|
||||
/// @}
|
||||
@ -18665,8 +18631,8 @@ class basic_json
|
||||
friend std::ostream& operator<<(std::ostream& o, const basic_json& j)
|
||||
{
|
||||
// read width member and use it as indentation parameter if nonzero
|
||||
const bool pretty_print = (o.width() > 0);
|
||||
const auto indentation = (pretty_print ? o.width() : 0);
|
||||
const bool pretty_print = o.width() > 0;
|
||||
const auto indentation = pretty_print ? o.width() : 0;
|
||||
|
||||
// reset width to 0 for subsequent calls to this stream
|
||||
o.width(0);
|
||||
@ -20172,9 +20138,9 @@ class basic_json
|
||||
if (ptr.empty())
|
||||
{
|
||||
result = val;
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// make sure the top element of the pointer exists
|
||||
json_pointer top_pointer = ptr.top();
|
||||
if (top_pointer != ptr)
|
||||
@ -20218,14 +20184,9 @@ class basic_json
|
||||
break;
|
||||
}
|
||||
|
||||
// LCOV_EXCL_START
|
||||
default:
|
||||
{
|
||||
// if there exists a parent it cannot be primitive
|
||||
assert(false);
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
}
|
||||
default: // LCOV_EXCL_LINE
|
||||
assert(false); // LCOV_EXCL_LINE
|
||||
}
|
||||
};
|
||||
|
||||
@ -20445,9 +20406,9 @@ class basic_json
|
||||
{
|
||||
{"op", "replace"}, {"path", path}, {"value", target}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
switch (source.type())
|
||||
{
|
||||
case value_t::array:
|
||||
@ -20546,7 +20507,6 @@ class basic_json
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user