Merge pull request #2211 from nlohmann/fix_warnings
Fix Clang-Tidy warnings
This commit is contained in:
commit
c5ee222982
10 changed files with 248 additions and 269 deletions
27
.clang-tidy
27
.clang-tidy
|
@ -1,23 +1,20 @@
|
||||||
Checks: '-*,
|
Checks: '*,
|
||||||
bugprone-*,
|
-cppcoreguidelines-avoid-goto,
|
||||||
cert-*,
|
-cppcoreguidelines-avoid-magic-numbers,
|
||||||
clang-analyzer-*,
|
-cppcoreguidelines-macro-usage,
|
||||||
google-*,
|
-fuchsia-default-arguments-calls,
|
||||||
-google-runtime-references,
|
-fuchsia-default-arguments-declarations,
|
||||||
|
-fuchsia-overloaded-operator,
|
||||||
-google-explicit-constructor,
|
-google-explicit-constructor,
|
||||||
hicpp-*,
|
-google-runtime-references,
|
||||||
|
-hicpp-avoid-goto,
|
||||||
|
-hicpp-explicit-conversions,
|
||||||
-hicpp-no-array-decay,
|
-hicpp-no-array-decay,
|
||||||
-hicpp-uppercase-literal-suffix,
|
-hicpp-uppercase-literal-suffix,
|
||||||
-hicpp-explicit-conversions,
|
|
||||||
misc-*,
|
|
||||||
-misc-non-private-member-variables-in-classes,
|
|
||||||
llvm-*,
|
|
||||||
-llvm-header-guard,
|
-llvm-header-guard,
|
||||||
modernize-*,
|
-llvm-include-order,
|
||||||
|
-misc-non-private-member-variables-in-classes,
|
||||||
-modernize-use-trailing-return-type,
|
-modernize-use-trailing-return-type,
|
||||||
performance-*,
|
|
||||||
portability-*,
|
|
||||||
readability-*,
|
|
||||||
-readability-magic-numbers,
|
-readability-magic-numbers,
|
||||||
-readability-uppercase-literal-suffix'
|
-readability-uppercase-literal-suffix'
|
||||||
|
|
||||||
|
|
|
@ -145,7 +145,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
bool parse_bson_internal()
|
bool parse_bson_internal()
|
||||||
{
|
{
|
||||||
std::int32_t document_size;
|
std::int32_t document_size{};
|
||||||
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1))))
|
if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1))))
|
||||||
|
@ -184,8 +184,6 @@ class binary_reader
|
||||||
}
|
}
|
||||||
*out++ = static_cast<typename string_t::value_type>(current);
|
*out++ = static_cast<typename string_t::value_type>(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -230,7 +228,7 @@ class binary_reader
|
||||||
}
|
}
|
||||||
|
|
||||||
// All BSON binary values have a subtype
|
// All BSON binary values have a subtype
|
||||||
std::uint8_t subtype;
|
std::uint8_t subtype{};
|
||||||
get_number<std::uint8_t>(input_format_t::bson, subtype);
|
get_number<std::uint8_t>(input_format_t::bson, subtype);
|
||||||
result.set_subtype(subtype);
|
result.set_subtype(subtype);
|
||||||
|
|
||||||
|
@ -254,13 +252,13 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 0x01: // double
|
case 0x01: // double
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number<double, true>(input_format_t::bson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number<double, true>(input_format_t::bson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x02: // string
|
case 0x02: // string
|
||||||
{
|
{
|
||||||
std::int32_t len;
|
std::int32_t len{};
|
||||||
string_t value;
|
string_t value;
|
||||||
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value);
|
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value);
|
||||||
}
|
}
|
||||||
|
@ -277,7 +275,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0x05: // binary
|
case 0x05: // binary
|
||||||
{
|
{
|
||||||
std::int32_t len;
|
std::int32_t len{};
|
||||||
binary_t value;
|
binary_t value;
|
||||||
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value);
|
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value);
|
||||||
}
|
}
|
||||||
|
@ -294,13 +292,13 @@ class binary_reader
|
||||||
|
|
||||||
case 0x10: // int32
|
case 0x10: // int32
|
||||||
{
|
{
|
||||||
std::int32_t value;
|
std::int32_t value{};
|
||||||
return get_number<std::int32_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
return get_number<std::int32_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x12: // int64
|
case 0x12: // int64
|
||||||
{
|
{
|
||||||
std::int64_t value;
|
std::int64_t value{};
|
||||||
return get_number<std::int64_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
return get_number<std::int64_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -365,7 +363,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
bool parse_bson_array()
|
bool parse_bson_array()
|
||||||
{
|
{
|
||||||
std::int32_t document_size;
|
std::int32_t document_size{};
|
||||||
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1))))
|
if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1))))
|
||||||
|
@ -429,25 +427,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x18: // Unsigned integer (one-byte uint8_t follows)
|
case 0x18: // Unsigned integer (one-byte uint8_t follows)
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x19: // Unsigned integer (two-byte uint16_t follows)
|
case 0x19: // Unsigned integer (two-byte uint16_t follows)
|
||||||
{
|
{
|
||||||
std::uint16_t number;
|
std::uint16_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x1A: // Unsigned integer (four-byte uint32_t follows)
|
case 0x1A: // Unsigned integer (four-byte uint32_t follows)
|
||||||
{
|
{
|
||||||
std::uint32_t number;
|
std::uint32_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
|
case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
|
||||||
{
|
{
|
||||||
std::uint64_t number;
|
std::uint64_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,25 +478,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x38: // Negative integer (one-byte uint8_t follows)
|
case 0x38: // Negative integer (one-byte uint8_t follows)
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
|
case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
|
||||||
{
|
{
|
||||||
std::uint16_t number;
|
std::uint16_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
|
case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
|
||||||
{
|
{
|
||||||
std::uint32_t number;
|
std::uint32_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
|
case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
|
||||||
{
|
{
|
||||||
std::uint64_t number;
|
std::uint64_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1)
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1)
|
||||||
- static_cast<number_integer_t>(number));
|
- static_cast<number_integer_t>(number));
|
||||||
}
|
}
|
||||||
|
@ -602,25 +600,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x98: // array (one-byte uint8_t for n follows)
|
case 0x98: // array (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x99: // array (two-byte uint16_t for n follow)
|
case 0x99: // array (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x9A: // array (four-byte uint32_t for n follow)
|
case 0x9A: // array (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x9B: // array (eight-byte uint64_t for n follow)
|
case 0x9B: // array (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,25 +654,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0xB8: // map (one-byte uint8_t for n follows)
|
case 0xB8: // map (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xB9: // map (two-byte uint16_t for n follow)
|
case 0xB9: // map (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xBA: // map (four-byte uint32_t for n follow)
|
case 0xBA: // map (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xBB: // map (eight-byte uint64_t for n follow)
|
case 0xBB: // map (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,13 +738,13 @@ class binary_reader
|
||||||
|
|
||||||
case 0xFA: // Single-Precision Float (four-byte IEEE 754)
|
case 0xFA: // Single-Precision Float (four-byte IEEE 754)
|
||||||
{
|
{
|
||||||
float number;
|
float number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
|
case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -809,25 +807,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
|
case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
|
case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
|
case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
|
case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -904,28 +902,28 @@ class binary_reader
|
||||||
|
|
||||||
case 0x58: // Binary data (one-byte uint8_t for n follows)
|
case 0x58: // Binary data (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x59: // Binary data (two-byte uint16_t for n follow)
|
case 0x59: // Binary data (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x5A: // Binary data (four-byte uint32_t for n follow)
|
case 0x5A: // Binary data (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x5B: // Binary data (eight-byte uint64_t for n follow)
|
case 0x5B: // Binary data (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
@ -1290,85 +1288,85 @@ class binary_reader
|
||||||
|
|
||||||
case 0xCA: // float 32
|
case 0xCA: // float 32
|
||||||
{
|
{
|
||||||
float number;
|
float number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCB: // float 64
|
case 0xCB: // float 64
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCC: // uint 8
|
case 0xCC: // uint 8
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCD: // uint 16
|
case 0xCD: // uint 16
|
||||||
{
|
{
|
||||||
std::uint16_t number;
|
std::uint16_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCE: // uint 32
|
case 0xCE: // uint 32
|
||||||
{
|
{
|
||||||
std::uint32_t number;
|
std::uint32_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCF: // uint 64
|
case 0xCF: // uint 64
|
||||||
{
|
{
|
||||||
std::uint64_t number;
|
std::uint64_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD0: // int 8
|
case 0xD0: // int 8
|
||||||
{
|
{
|
||||||
std::int8_t number;
|
std::int8_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD1: // int 16
|
case 0xD1: // int 16
|
||||||
{
|
{
|
||||||
std::int16_t number;
|
std::int16_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD2: // int 32
|
case 0xD2: // int 32
|
||||||
{
|
{
|
||||||
std::int32_t number;
|
std::int32_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD3: // int 64
|
case 0xD3: // int 64
|
||||||
{
|
{
|
||||||
std::int64_t number;
|
std::int64_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDC: // array 16
|
case 0xDC: // array 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDD: // array 32
|
case 0xDD: // array 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDE: // map 16
|
case 0xDE: // map 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDF: // map 32
|
case 0xDF: // map 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1473,19 +1471,19 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD9: // str 8
|
case 0xD9: // str 8
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDA: // str 16
|
case 0xDA: // str 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDB: // str 32
|
case 0xDB: // str 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1520,29 +1518,29 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 0xC4: // bin 8
|
case 0xC4: // bin 8
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_binary(input_format_t::msgpack, len, result);
|
get_binary(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC5: // bin 16
|
case 0xC5: // bin 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_binary(input_format_t::msgpack, len, result);
|
get_binary(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC6: // bin 32
|
case 0xC6: // bin 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_binary(input_format_t::msgpack, len, result);
|
get_binary(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC7: // ext 8
|
case 0xC7: // ext 8
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_number(input_format_t::msgpack, subtype) and
|
get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, len, result) and
|
get_binary(input_format_t::msgpack, len, result) and
|
||||||
|
@ -1551,8 +1549,8 @@ class binary_reader
|
||||||
|
|
||||||
case 0xC8: // ext 16
|
case 0xC8: // ext 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_number(input_format_t::msgpack, subtype) and
|
get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, len, result) and
|
get_binary(input_format_t::msgpack, len, result) and
|
||||||
|
@ -1561,8 +1559,8 @@ class binary_reader
|
||||||
|
|
||||||
case 0xC9: // ext 32
|
case 0xC9: // ext 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_number(input_format_t::msgpack, subtype) and
|
get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, len, result) and
|
get_binary(input_format_t::msgpack, len, result) and
|
||||||
|
@ -1571,7 +1569,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD4: // fixext 1
|
case 0xD4: // fixext 1
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 1, result) and
|
get_binary(input_format_t::msgpack, 1, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -1579,7 +1577,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD5: // fixext 2
|
case 0xD5: // fixext 2
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 2, result) and
|
get_binary(input_format_t::msgpack, 2, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -1587,7 +1585,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD6: // fixext 4
|
case 0xD6: // fixext 4
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 4, result) and
|
get_binary(input_format_t::msgpack, 4, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -1595,7 +1593,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD7: // fixext 8
|
case 0xD7: // fixext 8
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 8, result) and
|
get_binary(input_format_t::msgpack, 8, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -1603,7 +1601,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD8: // fixext 16
|
case 0xD8: // fixext 16
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 16, result) and
|
get_binary(input_format_t::msgpack, 16, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -1712,31 +1710,31 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
std::int8_t len;
|
std::int8_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
std::int16_t len;
|
std::int16_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
std::int32_t len;
|
std::int32_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
std::int64_t len;
|
std::int64_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1756,7 +1754,7 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1767,7 +1765,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
std::int8_t number;
|
std::int8_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1778,7 +1776,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
std::int16_t number;
|
std::int16_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1789,7 +1787,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
std::int32_t number;
|
std::int32_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1800,7 +1798,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
std::int64_t number;
|
std::int64_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -1885,43 +1883,43 @@ class binary_reader
|
||||||
|
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
std::int8_t number;
|
std::int8_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
std::int16_t number;
|
std::int16_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
std::int32_t number;
|
std::int32_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
std::int64_t number;
|
std::int64_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
{
|
{
|
||||||
float number;
|
float number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ class input_stream_adapter
|
||||||
{
|
{
|
||||||
// clear stream flags; we use underlying streambuf I/O, do not
|
// clear stream flags; we use underlying streambuf I/O, do not
|
||||||
// maintain ifstream flags, except eof
|
// maintain ifstream flags, except eof
|
||||||
if (is)
|
if (is != nullptr)
|
||||||
{
|
{
|
||||||
is->clear(is->rdstate() & std::ios::eofbit);
|
is->clear(is->rdstate() & std::ios::eofbit);
|
||||||
}
|
}
|
||||||
|
@ -411,7 +411,7 @@ template < typename CharT,
|
||||||
contiguous_bytes_input_adapter input_adapter(CharT b)
|
contiguous_bytes_input_adapter input_adapter(CharT b)
|
||||||
{
|
{
|
||||||
auto length = std::strlen(reinterpret_cast<const char*>(b));
|
auto length = std::strlen(reinterpret_cast<const char*>(b));
|
||||||
auto ptr = reinterpret_cast<const char*>(b);
|
const auto* ptr = reinterpret_cast<const char*>(b);
|
||||||
return input_adapter(ptr, ptr + length);
|
return input_adapter(ptr, ptr + length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -269,16 +269,16 @@ class json_sax_dom_parser
|
||||||
switch ((ex.id / 100) % 100)
|
switch ((ex.id / 100) % 100)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::parse_error*>(&ex));
|
||||||
case 4:
|
case 4:
|
||||||
JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::out_of_range*>(&ex));
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
case 2:
|
case 2:
|
||||||
JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::invalid_iterator*>(&ex));
|
||||||
case 3:
|
case 3:
|
||||||
JSON_THROW(*static_cast<const detail::type_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::type_error*>(&ex));
|
||||||
case 5:
|
case 5:
|
||||||
JSON_THROW(*static_cast<const detail::other_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::other_error*>(&ex));
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
@ -523,16 +523,16 @@ class json_sax_dom_callback_parser
|
||||||
switch ((ex.id / 100) % 100)
|
switch ((ex.id / 100) % 100)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::parse_error*>(&ex));
|
||||||
case 4:
|
case 4:
|
||||||
JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::out_of_range*>(&ex));
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
case 2:
|
case 2:
|
||||||
JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::invalid_iterator*>(&ex));
|
||||||
case 3:
|
case 3:
|
||||||
JSON_THROW(*static_cast<const detail::type_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::type_error*>(&ex));
|
||||||
case 5:
|
case 5:
|
||||||
JSON_THROW(*static_cast<const detail::other_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::other_error*>(&ex));
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
|
|
@ -131,7 +131,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||||
JSON_HEDLEY_PURE
|
JSON_HEDLEY_PURE
|
||||||
static char get_decimal_point() noexcept
|
static char get_decimal_point() noexcept
|
||||||
{
|
{
|
||||||
const auto loc = localeconv();
|
const auto* loc = localeconv();
|
||||||
assert(loc != nullptr);
|
assert(loc != nullptr);
|
||||||
return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
|
return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,8 +18,6 @@ template<typename BasicJsonType> struct internal_iterator
|
||||||
typename BasicJsonType::object_t::iterator object_iterator {};
|
typename BasicJsonType::object_t::iterator object_iterator {};
|
||||||
/// iterator for JSON arrays
|
/// iterator for JSON arrays
|
||||||
typename BasicJsonType::array_t::iterator array_iterator {};
|
typename BasicJsonType::array_t::iterator array_iterator {};
|
||||||
/// iterator for JSON binary arrays
|
|
||||||
typename BasicJsonType::binary_t::container_type::iterator binary_iterator {};
|
|
||||||
/// generic iterator for all other types
|
/// generic iterator for all other types
|
||||||
primitive_iterator_t primitive_iterator {};
|
primitive_iterator_t primitive_iterator {};
|
||||||
};
|
};
|
||||||
|
|
|
@ -16,23 +16,30 @@ class json_ref
|
||||||
using value_type = BasicJsonType;
|
using value_type = BasicJsonType;
|
||||||
|
|
||||||
json_ref(value_type&& value)
|
json_ref(value_type&& value)
|
||||||
: owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true)
|
: owned_value(std::move(value))
|
||||||
|
, value_ref(&owned_value)
|
||||||
|
, is_rvalue(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
json_ref(const value_type& value)
|
json_ref(const value_type& value)
|
||||||
: value_ref(const_cast<value_type*>(&value)), is_rvalue(false)
|
: value_ref(const_cast<value_type*>(&value))
|
||||||
|
, is_rvalue(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
json_ref(std::initializer_list<json_ref> init)
|
json_ref(std::initializer_list<json_ref> init)
|
||||||
: owned_value(init), value_ref(&owned_value), is_rvalue(true)
|
: owned_value(init)
|
||||||
|
, value_ref(&owned_value)
|
||||||
|
, is_rvalue(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class... Args,
|
class... Args,
|
||||||
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
|
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
|
||||||
json_ref(Args && ... args)
|
json_ref(Args && ... args)
|
||||||
: owned_value(std::forward<Args>(args)...), value_ref(&owned_value),
|
: owned_value(std::forward<Args>(args)...)
|
||||||
is_rvalue(true) {}
|
, value_ref(&owned_value)
|
||||||
|
, is_rvalue(true)
|
||||||
|
{}
|
||||||
|
|
||||||
// class should be movable only
|
// class should be movable only
|
||||||
json_ref(json_ref&&) = default;
|
json_ref(json_ref&&) = default;
|
||||||
|
@ -63,7 +70,7 @@ class json_ref
|
||||||
private:
|
private:
|
||||||
mutable value_type owned_value = nullptr;
|
mutable value_type owned_value = nullptr;
|
||||||
value_type* value_ref = nullptr;
|
value_type* value_ref = nullptr;
|
||||||
const bool is_rvalue;
|
const bool is_rvalue = true;
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace nlohmann
|
} // namespace nlohmann
|
||||||
|
|
|
@ -573,7 +573,7 @@ class binary_writer
|
||||||
const auto N = j.m_value.binary->size();
|
const auto N = j.m_value.binary->size();
|
||||||
if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type;
|
std::uint8_t output_type{};
|
||||||
bool fixed = true;
|
bool fixed = true;
|
||||||
if (use_ext)
|
if (use_ext)
|
||||||
{
|
{
|
||||||
|
@ -615,30 +615,18 @@ class binary_writer
|
||||||
}
|
}
|
||||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type;
|
std::uint8_t output_type = use_ext
|
||||||
if (use_ext)
|
? 0xC8 // ext 16
|
||||||
{
|
: 0xC5; // bin 16
|
||||||
output_type = 0xC8; // ext 16
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
output_type = 0xC5; // bin 16
|
|
||||||
}
|
|
||||||
|
|
||||||
oa->write_character(to_char_type(output_type));
|
oa->write_character(to_char_type(output_type));
|
||||||
write_number(static_cast<std::uint16_t>(N));
|
write_number(static_cast<std::uint16_t>(N));
|
||||||
}
|
}
|
||||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type;
|
std::uint8_t output_type = use_ext
|
||||||
if (use_ext)
|
? 0xC9 // ext 32
|
||||||
{
|
: 0xC6; // bin 32
|
||||||
output_type = 0xC9; // ext 32
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
output_type = 0xC6; // bin 32
|
|
||||||
}
|
|
||||||
|
|
||||||
oa->write_character(to_char_type(output_type));
|
oa->write_character(to_char_type(output_type));
|
||||||
write_number(static_cast<std::uint32_t>(N));
|
write_number(static_cast<std::uint32_t>(N));
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include <cstdint> // uint8_t
|
#include <cstdint> // uint8_t
|
||||||
#include <cstdio> // snprintf
|
#include <cstdio> // snprintf
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
#include <string> // string
|
#include <string> // string, char_traits
|
||||||
#include <type_traits> // is_same
|
#include <type_traits> // is_same
|
||||||
#include <utility> // move
|
#include <utility> // move
|
||||||
|
|
||||||
|
@ -59,8 +59,8 @@ class serializer
|
||||||
error_handler_t error_handler_ = error_handler_t::strict)
|
error_handler_t error_handler_ = error_handler_t::strict)
|
||||||
: o(std::move(s))
|
: o(std::move(s))
|
||||||
, loc(std::localeconv())
|
, loc(std::localeconv())
|
||||||
, thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep))
|
, thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
|
||||||
, decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point))
|
, decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->decimal_point)))
|
||||||
, indent_char(ichar)
|
, indent_char(ichar)
|
||||||
, indent_string(512, indent_char)
|
, indent_string(512, indent_char)
|
||||||
, error_handler(error_handler_)
|
, error_handler(error_handler_)
|
||||||
|
|
|
@ -4504,7 +4504,7 @@ class input_stream_adapter
|
||||||
{
|
{
|
||||||
// clear stream flags; we use underlying streambuf I/O, do not
|
// clear stream flags; we use underlying streambuf I/O, do not
|
||||||
// maintain ifstream flags, except eof
|
// maintain ifstream flags, except eof
|
||||||
if (is)
|
if (is != nullptr)
|
||||||
{
|
{
|
||||||
is->clear(is->rdstate() & std::ios::eofbit);
|
is->clear(is->rdstate() & std::ios::eofbit);
|
||||||
}
|
}
|
||||||
|
@ -4839,7 +4839,7 @@ template < typename CharT,
|
||||||
contiguous_bytes_input_adapter input_adapter(CharT b)
|
contiguous_bytes_input_adapter input_adapter(CharT b)
|
||||||
{
|
{
|
||||||
auto length = std::strlen(reinterpret_cast<const char*>(b));
|
auto length = std::strlen(reinterpret_cast<const char*>(b));
|
||||||
auto ptr = reinterpret_cast<const char*>(b);
|
const auto* ptr = reinterpret_cast<const char*>(b);
|
||||||
return input_adapter(ptr, ptr + length);
|
return input_adapter(ptr, ptr + length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5156,16 +5156,16 @@ class json_sax_dom_parser
|
||||||
switch ((ex.id / 100) % 100)
|
switch ((ex.id / 100) % 100)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::parse_error*>(&ex));
|
||||||
case 4:
|
case 4:
|
||||||
JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::out_of_range*>(&ex));
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
case 2:
|
case 2:
|
||||||
JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::invalid_iterator*>(&ex));
|
||||||
case 3:
|
case 3:
|
||||||
JSON_THROW(*static_cast<const detail::type_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::type_error*>(&ex));
|
||||||
case 5:
|
case 5:
|
||||||
JSON_THROW(*static_cast<const detail::other_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::other_error*>(&ex));
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
@ -5410,16 +5410,16 @@ class json_sax_dom_callback_parser
|
||||||
switch ((ex.id / 100) % 100)
|
switch ((ex.id / 100) % 100)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
JSON_THROW(*static_cast<const detail::parse_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::parse_error*>(&ex));
|
||||||
case 4:
|
case 4:
|
||||||
JSON_THROW(*static_cast<const detail::out_of_range*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::out_of_range*>(&ex));
|
||||||
// LCOV_EXCL_START
|
// LCOV_EXCL_START
|
||||||
case 2:
|
case 2:
|
||||||
JSON_THROW(*static_cast<const detail::invalid_iterator*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::invalid_iterator*>(&ex));
|
||||||
case 3:
|
case 3:
|
||||||
JSON_THROW(*static_cast<const detail::type_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::type_error*>(&ex));
|
||||||
case 5:
|
case 5:
|
||||||
JSON_THROW(*static_cast<const detail::other_error*>(&ex));
|
JSON_THROW(*dynamic_cast<const detail::other_error*>(&ex));
|
||||||
default:
|
default:
|
||||||
assert(false);
|
assert(false);
|
||||||
// LCOV_EXCL_STOP
|
// LCOV_EXCL_STOP
|
||||||
|
@ -5888,7 +5888,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
bool parse_bson_internal()
|
bool parse_bson_internal()
|
||||||
{
|
{
|
||||||
std::int32_t document_size;
|
std::int32_t document_size{};
|
||||||
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1))))
|
if (JSON_HEDLEY_UNLIKELY(not sax->start_object(std::size_t(-1))))
|
||||||
|
@ -5927,8 +5927,6 @@ class binary_reader
|
||||||
}
|
}
|
||||||
*out++ = static_cast<typename string_t::value_type>(current);
|
*out++ = static_cast<typename string_t::value_type>(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -5973,7 +5971,7 @@ class binary_reader
|
||||||
}
|
}
|
||||||
|
|
||||||
// All BSON binary values have a subtype
|
// All BSON binary values have a subtype
|
||||||
std::uint8_t subtype;
|
std::uint8_t subtype{};
|
||||||
get_number<std::uint8_t>(input_format_t::bson, subtype);
|
get_number<std::uint8_t>(input_format_t::bson, subtype);
|
||||||
result.set_subtype(subtype);
|
result.set_subtype(subtype);
|
||||||
|
|
||||||
|
@ -5997,13 +5995,13 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 0x01: // double
|
case 0x01: // double
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number<double, true>(input_format_t::bson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number<double, true>(input_format_t::bson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x02: // string
|
case 0x02: // string
|
||||||
{
|
{
|
||||||
std::int32_t len;
|
std::int32_t len{};
|
||||||
string_t value;
|
string_t value;
|
||||||
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value);
|
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_string(len, value) and sax->string(value);
|
||||||
}
|
}
|
||||||
|
@ -6020,7 +6018,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0x05: // binary
|
case 0x05: // binary
|
||||||
{
|
{
|
||||||
std::int32_t len;
|
std::int32_t len{};
|
||||||
binary_t value;
|
binary_t value;
|
||||||
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value);
|
return get_number<std::int32_t, true>(input_format_t::bson, len) and get_bson_binary(len, value) and sax->binary(value);
|
||||||
}
|
}
|
||||||
|
@ -6037,13 +6035,13 @@ class binary_reader
|
||||||
|
|
||||||
case 0x10: // int32
|
case 0x10: // int32
|
||||||
{
|
{
|
||||||
std::int32_t value;
|
std::int32_t value{};
|
||||||
return get_number<std::int32_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
return get_number<std::int32_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x12: // int64
|
case 0x12: // int64
|
||||||
{
|
{
|
||||||
std::int64_t value;
|
std::int64_t value{};
|
||||||
return get_number<std::int64_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
return get_number<std::int64_t, true>(input_format_t::bson, value) and sax->number_integer(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6108,7 +6106,7 @@ class binary_reader
|
||||||
*/
|
*/
|
||||||
bool parse_bson_array()
|
bool parse_bson_array()
|
||||||
{
|
{
|
||||||
std::int32_t document_size;
|
std::int32_t document_size{};
|
||||||
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
get_number<std::int32_t, true>(input_format_t::bson, document_size);
|
||||||
|
|
||||||
if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1))))
|
if (JSON_HEDLEY_UNLIKELY(not sax->start_array(std::size_t(-1))))
|
||||||
|
@ -6172,25 +6170,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x18: // Unsigned integer (one-byte uint8_t follows)
|
case 0x18: // Unsigned integer (one-byte uint8_t follows)
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x19: // Unsigned integer (two-byte uint16_t follows)
|
case 0x19: // Unsigned integer (two-byte uint16_t follows)
|
||||||
{
|
{
|
||||||
std::uint16_t number;
|
std::uint16_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x1A: // Unsigned integer (four-byte uint32_t follows)
|
case 0x1A: // Unsigned integer (four-byte uint32_t follows)
|
||||||
{
|
{
|
||||||
std::uint32_t number;
|
std::uint32_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
|
case 0x1B: // Unsigned integer (eight-byte uint64_t follows)
|
||||||
{
|
{
|
||||||
std::uint64_t number;
|
std::uint64_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::cbor, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6223,25 +6221,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x38: // Negative integer (one-byte uint8_t follows)
|
case 0x38: // Negative integer (one-byte uint8_t follows)
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
|
case 0x39: // Negative integer -1-n (two-byte uint16_t follows)
|
||||||
{
|
{
|
||||||
std::uint16_t number;
|
std::uint16_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
|
case 0x3A: // Negative integer -1-n (four-byte uint32_t follows)
|
||||||
{
|
{
|
||||||
std::uint32_t number;
|
std::uint32_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1) - number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
|
case 0x3B: // Negative integer -1-n (eight-byte uint64_t follows)
|
||||||
{
|
{
|
||||||
std::uint64_t number;
|
std::uint64_t number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1)
|
return get_number(input_format_t::cbor, number) and sax->number_integer(static_cast<number_integer_t>(-1)
|
||||||
- static_cast<number_integer_t>(number));
|
- static_cast<number_integer_t>(number));
|
||||||
}
|
}
|
||||||
|
@ -6345,25 +6343,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x98: // array (one-byte uint8_t for n follows)
|
case 0x98: // array (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x99: // array (two-byte uint16_t for n follow)
|
case 0x99: // array (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x9A: // array (four-byte uint32_t for n follow)
|
case 0x9A: // array (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x9B: // array (eight-byte uint64_t for n follow)
|
case 0x9B: // array (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6399,25 +6397,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0xB8: // map (one-byte uint8_t for n follows)
|
case 0xB8: // map (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xB9: // map (two-byte uint16_t for n follow)
|
case 0xB9: // map (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xBA: // map (four-byte uint32_t for n follow)
|
case 0xBA: // map (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xBB: // map (eight-byte uint64_t for n follow)
|
case 0xBB: // map (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::cbor, len) and get_cbor_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6483,13 +6481,13 @@ class binary_reader
|
||||||
|
|
||||||
case 0xFA: // Single-Precision Float (four-byte IEEE 754)
|
case 0xFA: // Single-Precision Float (four-byte IEEE 754)
|
||||||
{
|
{
|
||||||
float number;
|
float number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
|
case 0xFB: // Double-Precision Float (eight-byte IEEE 754)
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::cbor, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6552,25 +6550,25 @@ class binary_reader
|
||||||
|
|
||||||
case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
|
case 0x78: // UTF-8 string (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
|
case 0x79: // UTF-8 string (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
|
case 0x7A: // UTF-8 string (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
|
case 0x7B: // UTF-8 string (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
return get_number(input_format_t::cbor, len) and get_string(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6647,28 +6645,28 @@ class binary_reader
|
||||||
|
|
||||||
case 0x58: // Binary data (one-byte uint8_t for n follows)
|
case 0x58: // Binary data (one-byte uint8_t for n follows)
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x59: // Binary data (two-byte uint16_t for n follow)
|
case 0x59: // Binary data (two-byte uint16_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x5A: // Binary data (four-byte uint32_t for n follow)
|
case 0x5A: // Binary data (four-byte uint32_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0x5B: // Binary data (eight-byte uint64_t for n follow)
|
case 0x5B: // Binary data (eight-byte uint64_t for n follow)
|
||||||
{
|
{
|
||||||
std::uint64_t len;
|
std::uint64_t len{};
|
||||||
return get_number(input_format_t::cbor, len) and
|
return get_number(input_format_t::cbor, len) and
|
||||||
get_binary(input_format_t::cbor, len, result);
|
get_binary(input_format_t::cbor, len, result);
|
||||||
}
|
}
|
||||||
|
@ -7033,85 +7031,85 @@ class binary_reader
|
||||||
|
|
||||||
case 0xCA: // float 32
|
case 0xCA: // float 32
|
||||||
{
|
{
|
||||||
float number;
|
float number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCB: // float 64
|
case 0xCB: // float 64
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::msgpack, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCC: // uint 8
|
case 0xCC: // uint 8
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCD: // uint 16
|
case 0xCD: // uint 16
|
||||||
{
|
{
|
||||||
std::uint16_t number;
|
std::uint16_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCE: // uint 32
|
case 0xCE: // uint 32
|
||||||
{
|
{
|
||||||
std::uint32_t number;
|
std::uint32_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xCF: // uint 64
|
case 0xCF: // uint 64
|
||||||
{
|
{
|
||||||
std::uint64_t number;
|
std::uint64_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD0: // int 8
|
case 0xD0: // int 8
|
||||||
{
|
{
|
||||||
std::int8_t number;
|
std::int8_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD1: // int 16
|
case 0xD1: // int 16
|
||||||
{
|
{
|
||||||
std::int16_t number;
|
std::int16_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD2: // int 32
|
case 0xD2: // int 32
|
||||||
{
|
{
|
||||||
std::int32_t number;
|
std::int32_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xD3: // int 64
|
case 0xD3: // int 64
|
||||||
{
|
{
|
||||||
std::int64_t number;
|
std::int64_t number{};
|
||||||
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
return get_number(input_format_t::msgpack, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDC: // array 16
|
case 0xDC: // array 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDD: // array 32
|
case 0xDD: // array 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_array(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDE: // map 16
|
case 0xDE: // map 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDF: // map 32
|
case 0xDF: // map 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
return get_number(input_format_t::msgpack, len) and get_msgpack_object(static_cast<std::size_t>(len));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7216,19 +7214,19 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD9: // str 8
|
case 0xD9: // str 8
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDA: // str 16
|
case 0xDA: // str 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xDB: // str 32
|
case 0xDB: // str 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
return get_number(input_format_t::msgpack, len) and get_string(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7263,29 +7261,29 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 0xC4: // bin 8
|
case 0xC4: // bin 8
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_binary(input_format_t::msgpack, len, result);
|
get_binary(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC5: // bin 16
|
case 0xC5: // bin 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_binary(input_format_t::msgpack, len, result);
|
get_binary(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC6: // bin 32
|
case 0xC6: // bin 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_binary(input_format_t::msgpack, len, result);
|
get_binary(input_format_t::msgpack, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xC7: // ext 8
|
case 0xC7: // ext 8
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_number(input_format_t::msgpack, subtype) and
|
get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, len, result) and
|
get_binary(input_format_t::msgpack, len, result) and
|
||||||
|
@ -7294,8 +7292,8 @@ class binary_reader
|
||||||
|
|
||||||
case 0xC8: // ext 16
|
case 0xC8: // ext 16
|
||||||
{
|
{
|
||||||
std::uint16_t len;
|
std::uint16_t len{};
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_number(input_format_t::msgpack, subtype) and
|
get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, len, result) and
|
get_binary(input_format_t::msgpack, len, result) and
|
||||||
|
@ -7304,8 +7302,8 @@ class binary_reader
|
||||||
|
|
||||||
case 0xC9: // ext 32
|
case 0xC9: // ext 32
|
||||||
{
|
{
|
||||||
std::uint32_t len;
|
std::uint32_t len{};
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, len) and
|
return get_number(input_format_t::msgpack, len) and
|
||||||
get_number(input_format_t::msgpack, subtype) and
|
get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, len, result) and
|
get_binary(input_format_t::msgpack, len, result) and
|
||||||
|
@ -7314,7 +7312,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD4: // fixext 1
|
case 0xD4: // fixext 1
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 1, result) and
|
get_binary(input_format_t::msgpack, 1, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -7322,7 +7320,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD5: // fixext 2
|
case 0xD5: // fixext 2
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 2, result) and
|
get_binary(input_format_t::msgpack, 2, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -7330,7 +7328,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD6: // fixext 4
|
case 0xD6: // fixext 4
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 4, result) and
|
get_binary(input_format_t::msgpack, 4, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -7338,7 +7336,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD7: // fixext 8
|
case 0xD7: // fixext 8
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 8, result) and
|
get_binary(input_format_t::msgpack, 8, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -7346,7 +7344,7 @@ class binary_reader
|
||||||
|
|
||||||
case 0xD8: // fixext 16
|
case 0xD8: // fixext 16
|
||||||
{
|
{
|
||||||
std::int8_t subtype;
|
std::int8_t subtype{};
|
||||||
return get_number(input_format_t::msgpack, subtype) and
|
return get_number(input_format_t::msgpack, subtype) and
|
||||||
get_binary(input_format_t::msgpack, 16, result) and
|
get_binary(input_format_t::msgpack, 16, result) and
|
||||||
assign_and_return_true(subtype);
|
assign_and_return_true(subtype);
|
||||||
|
@ -7455,31 +7453,31 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
std::uint8_t len;
|
std::uint8_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
std::int8_t len;
|
std::int8_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
std::int16_t len;
|
std::int16_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
std::int32_t len;
|
std::int32_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
std::int64_t len;
|
std::int64_t len{};
|
||||||
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
return get_number(input_format_t::ubjson, len) and get_string(input_format_t::ubjson, len, result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7499,7 +7497,7 @@ class binary_reader
|
||||||
{
|
{
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -7510,7 +7508,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
std::int8_t number;
|
std::int8_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -7521,7 +7519,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
std::int16_t number;
|
std::int16_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -7532,7 +7530,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
std::int32_t number;
|
std::int32_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -7543,7 +7541,7 @@ class binary_reader
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
std::int64_t number;
|
std::int64_t number{};
|
||||||
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
if (JSON_HEDLEY_UNLIKELY(not get_number(input_format_t::ubjson, number)))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
|
@ -7628,43 +7626,43 @@ class binary_reader
|
||||||
|
|
||||||
case 'U':
|
case 'U':
|
||||||
{
|
{
|
||||||
std::uint8_t number;
|
std::uint8_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_unsigned(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'i':
|
case 'i':
|
||||||
{
|
{
|
||||||
std::int8_t number;
|
std::int8_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'I':
|
case 'I':
|
||||||
{
|
{
|
||||||
std::int16_t number;
|
std::int16_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
{
|
{
|
||||||
std::int32_t number;
|
std::int32_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'L':
|
case 'L':
|
||||||
{
|
{
|
||||||
std::int64_t number;
|
std::int64_t number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
return get_number(input_format_t::ubjson, number) and sax->number_integer(number);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'd':
|
case 'd':
|
||||||
{
|
{
|
||||||
float number;
|
float number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'D':
|
case 'D':
|
||||||
{
|
{
|
||||||
double number;
|
double number{};
|
||||||
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
return get_number(input_format_t::ubjson, number) and sax->number_float(static_cast<number_float_t>(number), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8204,7 +8202,7 @@ class lexer : public lexer_base<BasicJsonType>
|
||||||
JSON_HEDLEY_PURE
|
JSON_HEDLEY_PURE
|
||||||
static char get_decimal_point() noexcept
|
static char get_decimal_point() noexcept
|
||||||
{
|
{
|
||||||
const auto loc = localeconv();
|
const auto* loc = localeconv();
|
||||||
assert(loc != nullptr);
|
assert(loc != nullptr);
|
||||||
return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
|
return (loc->decimal_point == nullptr) ? '.' : *(loc->decimal_point);
|
||||||
}
|
}
|
||||||
|
@ -10251,8 +10249,6 @@ template<typename BasicJsonType> struct internal_iterator
|
||||||
typename BasicJsonType::object_t::iterator object_iterator {};
|
typename BasicJsonType::object_t::iterator object_iterator {};
|
||||||
/// iterator for JSON arrays
|
/// iterator for JSON arrays
|
||||||
typename BasicJsonType::array_t::iterator array_iterator {};
|
typename BasicJsonType::array_t::iterator array_iterator {};
|
||||||
/// iterator for JSON binary arrays
|
|
||||||
typename BasicJsonType::binary_t::container_type::iterator binary_iterator {};
|
|
||||||
/// generic iterator for all other types
|
/// generic iterator for all other types
|
||||||
primitive_iterator_t primitive_iterator {};
|
primitive_iterator_t primitive_iterator {};
|
||||||
};
|
};
|
||||||
|
@ -12039,23 +12035,30 @@ class json_ref
|
||||||
using value_type = BasicJsonType;
|
using value_type = BasicJsonType;
|
||||||
|
|
||||||
json_ref(value_type&& value)
|
json_ref(value_type&& value)
|
||||||
: owned_value(std::move(value)), value_ref(&owned_value), is_rvalue(true)
|
: owned_value(std::move(value))
|
||||||
|
, value_ref(&owned_value)
|
||||||
|
, is_rvalue(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
json_ref(const value_type& value)
|
json_ref(const value_type& value)
|
||||||
: value_ref(const_cast<value_type*>(&value)), is_rvalue(false)
|
: value_ref(const_cast<value_type*>(&value))
|
||||||
|
, is_rvalue(false)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
json_ref(std::initializer_list<json_ref> init)
|
json_ref(std::initializer_list<json_ref> init)
|
||||||
: owned_value(init), value_ref(&owned_value), is_rvalue(true)
|
: owned_value(init)
|
||||||
|
, value_ref(&owned_value)
|
||||||
|
, is_rvalue(true)
|
||||||
{}
|
{}
|
||||||
|
|
||||||
template <
|
template <
|
||||||
class... Args,
|
class... Args,
|
||||||
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
|
enable_if_t<std::is_constructible<value_type, Args...>::value, int> = 0 >
|
||||||
json_ref(Args && ... args)
|
json_ref(Args && ... args)
|
||||||
: owned_value(std::forward<Args>(args)...), value_ref(&owned_value),
|
: owned_value(std::forward<Args>(args)...)
|
||||||
is_rvalue(true) {}
|
, value_ref(&owned_value)
|
||||||
|
, is_rvalue(true)
|
||||||
|
{}
|
||||||
|
|
||||||
// class should be movable only
|
// class should be movable only
|
||||||
json_ref(json_ref&&) = default;
|
json_ref(json_ref&&) = default;
|
||||||
|
@ -12086,7 +12089,7 @@ class json_ref
|
||||||
private:
|
private:
|
||||||
mutable value_type owned_value = nullptr;
|
mutable value_type owned_value = nullptr;
|
||||||
value_type* value_ref = nullptr;
|
value_type* value_ref = nullptr;
|
||||||
const bool is_rvalue;
|
const bool is_rvalue = true;
|
||||||
};
|
};
|
||||||
} // namespace detail
|
} // namespace detail
|
||||||
} // namespace nlohmann
|
} // namespace nlohmann
|
||||||
|
@ -12800,7 +12803,7 @@ class binary_writer
|
||||||
const auto N = j.m_value.binary->size();
|
const auto N = j.m_value.binary->size();
|
||||||
if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type;
|
std::uint8_t output_type{};
|
||||||
bool fixed = true;
|
bool fixed = true;
|
||||||
if (use_ext)
|
if (use_ext)
|
||||||
{
|
{
|
||||||
|
@ -12842,30 +12845,18 @@ class binary_writer
|
||||||
}
|
}
|
||||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type;
|
std::uint8_t output_type = use_ext
|
||||||
if (use_ext)
|
? 0xC8 // ext 16
|
||||||
{
|
: 0xC5; // bin 16
|
||||||
output_type = 0xC8; // ext 16
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
output_type = 0xC5; // bin 16
|
|
||||||
}
|
|
||||||
|
|
||||||
oa->write_character(to_char_type(output_type));
|
oa->write_character(to_char_type(output_type));
|
||||||
write_number(static_cast<std::uint16_t>(N));
|
write_number(static_cast<std::uint16_t>(N));
|
||||||
}
|
}
|
||||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||||
{
|
{
|
||||||
std::uint8_t output_type;
|
std::uint8_t output_type = use_ext
|
||||||
if (use_ext)
|
? 0xC9 // ext 32
|
||||||
{
|
: 0xC6; // bin 32
|
||||||
output_type = 0xC9; // ext 32
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
output_type = 0xC6; // bin 32
|
|
||||||
}
|
|
||||||
|
|
||||||
oa->write_character(to_char_type(output_type));
|
oa->write_character(to_char_type(output_type));
|
||||||
write_number(static_cast<std::uint32_t>(N));
|
write_number(static_cast<std::uint32_t>(N));
|
||||||
|
@ -13819,7 +13810,7 @@ class binary_writer
|
||||||
#include <cstdint> // uint8_t
|
#include <cstdint> // uint8_t
|
||||||
#include <cstdio> // snprintf
|
#include <cstdio> // snprintf
|
||||||
#include <limits> // numeric_limits
|
#include <limits> // numeric_limits
|
||||||
#include <string> // string
|
#include <string> // string, char_traits
|
||||||
#include <type_traits> // is_same
|
#include <type_traits> // is_same
|
||||||
#include <utility> // move
|
#include <utility> // move
|
||||||
|
|
||||||
|
@ -14986,8 +14977,8 @@ class serializer
|
||||||
error_handler_t error_handler_ = error_handler_t::strict)
|
error_handler_t error_handler_ = error_handler_t::strict)
|
||||||
: o(std::move(s))
|
: o(std::move(s))
|
||||||
, loc(std::localeconv())
|
, loc(std::localeconv())
|
||||||
, thousands_sep(loc->thousands_sep == nullptr ? '\0' : * (loc->thousands_sep))
|
, thousands_sep(loc->thousands_sep == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->thousands_sep)))
|
||||||
, decimal_point(loc->decimal_point == nullptr ? '\0' : * (loc->decimal_point))
|
, decimal_point(loc->decimal_point == nullptr ? '\0' : std::char_traits<char>::to_char_type(* (loc->decimal_point)))
|
||||||
, indent_char(ichar)
|
, indent_char(ichar)
|
||||||
, indent_string(512, indent_char)
|
, indent_string(512, indent_char)
|
||||||
, error_handler(error_handler_)
|
, error_handler(error_handler_)
|
||||||
|
|
Loading…
Reference in a new issue