Merge branch 'develop' of https://github.com/nlohmann/json into bon8

 Conflicts:
	doc/mkdocs/docs/api/basic_json/index.md
	doc/mkdocs/docs/features/binary_formats/bson.md
	doc/mkdocs/docs/features/binary_formats/index.md
	doc/mkdocs/mkdocs.yml
	include/nlohmann/json.hpp
	single_include/nlohmann/json.hpp
This commit is contained in:
Niels Lohmann
2021-12-31 14:53:13 +01:00
427 changed files with 6293 additions and 13280 deletions

View File

@@ -42,7 +42,7 @@ enum class cbor_tag_handler_t
@note from https://stackoverflow.com/a/1001328/266378
*/
static inline bool little_endianess(int num = 1) noexcept
static inline bool little_endianness(int num = 1) noexcept
{
return *reinterpret_cast<char*>(&num) == 1;
}
@@ -165,7 +165,7 @@ class binary_reader
std::int32_t document_size{};
get_number<std::int32_t, true>(input_format_t::bson, document_size);
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast<std::size_t>(-1))))
{
return false;
}
@@ -322,7 +322,7 @@ class binary_reader
default: // anything else not supported (yet)
{
std::array<char, 3> cr{{}};
(std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(element_type))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
return sax->parse_error(element_type_parse_position, std::string(cr.data()), parse_error::create(114, element_type_parse_position, "Unsupported BSON record type 0x" + std::string(cr.data()), BasicJsonType()));
}
}
@@ -383,7 +383,7 @@ class binary_reader
std::int32_t document_size{};
get_number<std::int32_t, true>(input_format_t::bson, document_size);
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast<std::size_t>(-1))))
{
return false;
}
@@ -642,7 +642,7 @@ class binary_reader
}
case 0x9F: // array (indefinite length)
return get_cbor_array(std::size_t(-1), tag_handler);
return get_cbor_array(static_cast<std::size_t>(-1), tag_handler);
// map (0x00..0x17 pairs of data items follow)
case 0xA0:
@@ -696,7 +696,7 @@ class binary_reader
}
case 0xBF: // map (indefinite length)
return get_cbor_object(std::size_t(-1), tag_handler);
return get_cbor_object(static_cast<std::size_t>(-1), tag_handler);
case 0xC6: // tagged item
case 0xC7:
@@ -1080,7 +1080,7 @@ class binary_reader
}
/*!
@param[in] len the length of the array or std::size_t(-1) for an
@param[in] len the length of the array or static_cast<std::size_t>(-1) for an
array of indefinite size
@param[in] tag_handler how CBOR tags should be treated
@return whether array creation completed
@@ -1093,7 +1093,7 @@ class binary_reader
return false;
}
if (len != std::size_t(-1))
if (len != static_cast<std::size_t>(-1))
{
for (std::size_t i = 0; i < len; ++i)
{
@@ -1118,7 +1118,7 @@ class binary_reader
}
/*!
@param[in] len the length of the object or std::size_t(-1) for an
@param[in] len the length of the object or static_cast<std::size_t>(-1) for an
object of indefinite size
@param[in] tag_handler how CBOR tags should be treated
@return whether object creation completed
@@ -1134,7 +1134,7 @@ class binary_reader
if (len != 0)
{
string_t key;
if (len != std::size_t(-1))
if (len != static_cast<std::size_t>(-1))
{
for (std::size_t i = 0; i < len; ++i)
{
@@ -2144,7 +2144,7 @@ class binary_reader
}
else
{
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(std::size_t(-1))))
if (JSON_HEDLEY_UNLIKELY(!sax->start_array(static_cast<std::size_t>(-1))))
{
return false;
}
@@ -2214,7 +2214,7 @@ class binary_reader
}
else
{
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(std::size_t(-1))))
if (JSON_HEDLEY_UNLIKELY(!sax->start_object(static_cast<std::size_t>(-1))))
{
return false;
}
@@ -2640,7 +2640,7 @@ class binary_reader
@return whether conversion completed
@note This function needs to respect the system's endianess, because
@note This function needs to respect the system's endianness, because
bytes in CBOR, MessagePack, and UBJSON are stored in network order
(big endian) and therefore need reordering on little endian systems.
*/
@@ -2761,7 +2761,7 @@ class binary_reader
std::string get_token_string() const
{
std::array<char, 3> cr{{}};
(std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current)); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
static_cast<void>((std::snprintf)(cr.data(), cr.size(), "%.2hhX", static_cast<unsigned char>(current))); // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
return std::string{cr.data()};
}
@@ -2817,8 +2817,8 @@ class binary_reader
/// the number of characters read
std::size_t chars_read = 0;
/// whether we can assume little endianess
const bool is_little_endian = little_endianess();
/// whether we can assume little endianness
const bool is_little_endian = little_endianness();
/// the SAX parser
json_sax_t* sax = nullptr;