Add shared detail helpers for the #5891 cleanup
Add detail::is_primitive(value_t), detail::hex4_lower(), detail::utf8_shape(), detail::input_format_name(), detail::empty_input_message(), the exception ids 116, 319, 320 and 416 to detail::exception_id, and make detail::is_ascii_copyable() constexpr. Later commits switch the duplicated code over to them. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
5 files changed
+142
-1
No files matched your search
@@ -177,6 +177,35 @@ inline bool owns_memory(const value_t t) noexcept
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
@brief whether a value of the given type is neither an object nor an array
|
||||
|
||||
Unlike basic_json::is_primitive(), this includes value_t::discarded: it names
|
||||
the types for which iterators, JSON Pointer resolution, and the serializer take
|
||||
the "single value" path. Every enumerator is listed so that -Wswitch-enum flags
|
||||
this function when a new type is added.
|
||||
*/
|
||||
inline bool is_primitive(const value_t t) noexcept
|
||||
{
|
||||
switch (t)
|
||||
{
|
||||
case value_t::object:
|
||||
case value_t::array:
|
||||
return false;
|
||||
|
||||
case value_t::null:
|
||||
case value_t::string:
|
||||
case value_t::boolean:
|
||||
case value_t::number_integer:
|
||||
case value_t::number_unsigned:
|
||||
case value_t::number_float:
|
||||
case value_t::binary:
|
||||
case value_t::discarded:
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
@brief compare an integer with a floating point number without precision loss
|
||||
|
||||
Reference in new issue
Block a user