🚨 fixed more warnings
This commit is contained in:
parent
02b3494711
commit
34f8b4f711
8 changed files with 818 additions and 810 deletions
|
@ -88,27 +88,27 @@ class binary_writer
|
|||
// code from the value_t::number_unsigned case here.
|
||||
if (j.m_value.number_integer <= 0x17)
|
||||
{
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_integer <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x18));
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_integer <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x19));
|
||||
write_number(static_cast<uint16_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_integer <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (j.m_value.number_integer <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x1A));
|
||||
write_number(static_cast<uint32_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
|
||||
}
|
||||
else
|
||||
{
|
||||
oa->write_character(to_char_type(0x1B));
|
||||
write_number(static_cast<uint64_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -118,27 +118,27 @@ class binary_writer
|
|||
const auto positive_number = -1 - j.m_value.number_integer;
|
||||
if (j.m_value.number_integer >= -24)
|
||||
{
|
||||
write_number(static_cast<uint8_t>(0x20 + positive_number));
|
||||
write_number(static_cast<std::uint8_t>(0x20 + positive_number));
|
||||
}
|
||||
else if (positive_number <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (positive_number <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x38));
|
||||
write_number(static_cast<uint8_t>(positive_number));
|
||||
write_number(static_cast<std::uint8_t>(positive_number));
|
||||
}
|
||||
else if (positive_number <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (positive_number <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x39));
|
||||
write_number(static_cast<uint16_t>(positive_number));
|
||||
write_number(static_cast<std::uint16_t>(positive_number));
|
||||
}
|
||||
else if (positive_number <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (positive_number <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x3A));
|
||||
write_number(static_cast<uint32_t>(positive_number));
|
||||
write_number(static_cast<std::uint32_t>(positive_number));
|
||||
}
|
||||
else
|
||||
{
|
||||
oa->write_character(to_char_type(0x3B));
|
||||
write_number(static_cast<uint64_t>(positive_number));
|
||||
write_number(static_cast<std::uint64_t>(positive_number));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -148,27 +148,27 @@ class binary_writer
|
|||
{
|
||||
if (j.m_value.number_unsigned <= 0x17)
|
||||
{
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_unsigned));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x18));
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_unsigned));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_unsigned));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x19));
|
||||
write_number(static_cast<uint16_t>(j.m_value.number_unsigned));
|
||||
write_number(static_cast<std::uint16_t>(j.m_value.number_unsigned));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x1A));
|
||||
write_number(static_cast<uint32_t>(j.m_value.number_unsigned));
|
||||
write_number(static_cast<std::uint32_t>(j.m_value.number_unsigned));
|
||||
}
|
||||
else
|
||||
{
|
||||
oa->write_character(to_char_type(0x1B));
|
||||
write_number(static_cast<uint64_t>(j.m_value.number_unsigned));
|
||||
write_number(static_cast<std::uint64_t>(j.m_value.number_unsigned));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -186,28 +186,28 @@ class binary_writer
|
|||
const auto N = j.m_value.string->size();
|
||||
if (N <= 0x17)
|
||||
{
|
||||
write_number(static_cast<uint8_t>(0x60 + N));
|
||||
write_number(static_cast<std::uint8_t>(0x60 + N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x78));
|
||||
write_number(static_cast<uint8_t>(N));
|
||||
write_number(static_cast<std::uint8_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x79));
|
||||
write_number(static_cast<uint16_t>(N));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x7A));
|
||||
write_number(static_cast<uint32_t>(N));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
else if (N <= (std::numeric_limits<uint64_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x7B));
|
||||
write_number(static_cast<uint64_t>(N));
|
||||
write_number(static_cast<std::uint64_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
|
@ -224,28 +224,28 @@ class binary_writer
|
|||
const auto N = j.m_value.array->size();
|
||||
if (N <= 0x17)
|
||||
{
|
||||
write_number(static_cast<uint8_t>(0x80 + N));
|
||||
write_number(static_cast<std::uint8_t>(0x80 + N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x98));
|
||||
write_number(static_cast<uint8_t>(N));
|
||||
write_number(static_cast<std::uint8_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x99));
|
||||
write_number(static_cast<uint16_t>(N));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x9A));
|
||||
write_number(static_cast<uint32_t>(N));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
else if (N <= (std::numeric_limits<uint64_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0x9B));
|
||||
write_number(static_cast<uint64_t>(N));
|
||||
write_number(static_cast<std::uint64_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
|
@ -263,28 +263,28 @@ class binary_writer
|
|||
const auto N = j.m_value.object->size();
|
||||
if (N <= 0x17)
|
||||
{
|
||||
write_number(static_cast<uint8_t>(0xA0 + N));
|
||||
write_number(static_cast<std::uint8_t>(0xA0 + N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0xB8));
|
||||
write_number(static_cast<uint8_t>(N));
|
||||
write_number(static_cast<std::uint8_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0xB9));
|
||||
write_number(static_cast<uint16_t>(N));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0xBA));
|
||||
write_number(static_cast<uint32_t>(N));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
else if (N <= (std::numeric_limits<uint64_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
oa->write_character(to_char_type(0xBB));
|
||||
write_number(static_cast<uint64_t>(N));
|
||||
write_number(static_cast<std::uint64_t>(N));
|
||||
}
|
||||
// LCOV_EXCL_STOP
|
||||
|
||||
|
@ -333,31 +333,31 @@ class binary_writer
|
|||
if (j.m_value.number_unsigned < 128)
|
||||
{
|
||||
// positive fixnum
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
// uint 8
|
||||
oa->write_character(to_char_type(0xCC));
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
// uint 16
|
||||
oa->write_character(to_char_type(0xCD));
|
||||
write_number(static_cast<uint16_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
// uint 32
|
||||
oa->write_character(to_char_type(0xCE));
|
||||
write_number(static_cast<uint32_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint64_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
// uint 64
|
||||
oa->write_character(to_char_type(0xCF));
|
||||
write_number(static_cast<uint64_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -365,35 +365,35 @@ class binary_writer
|
|||
if (j.m_value.number_integer >= -32)
|
||||
{
|
||||
// negative fixnum
|
||||
write_number(static_cast<int8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::int8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<int8_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<int8_t>::max)())
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int8_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
|
||||
{
|
||||
// int 8
|
||||
oa->write_character(to_char_type(0xD0));
|
||||
write_number(static_cast<int8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::int8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<int16_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<int16_t>::max)())
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int16_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
|
||||
{
|
||||
// int 16
|
||||
oa->write_character(to_char_type(0xD1));
|
||||
write_number(static_cast<int16_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::int16_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<int32_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<int32_t>::max)())
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int32_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
// int 32
|
||||
oa->write_character(to_char_type(0xD2));
|
||||
write_number(static_cast<int32_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::int32_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<int64_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<int64_t>::max)())
|
||||
else if (j.m_value.number_integer >= (std::numeric_limits<std::int64_t>::min)() and
|
||||
j.m_value.number_integer <= (std::numeric_limits<std::int64_t>::max)())
|
||||
{
|
||||
// int 64
|
||||
oa->write_character(to_char_type(0xD3));
|
||||
write_number(static_cast<int64_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::int64_t>(j.m_value.number_integer));
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -404,31 +404,31 @@ class binary_writer
|
|||
if (j.m_value.number_unsigned < 128)
|
||||
{
|
||||
// positive fixnum
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
// uint 8
|
||||
oa->write_character(to_char_type(0xCC));
|
||||
write_number(static_cast<uint8_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint8_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
// uint 16
|
||||
oa->write_character(to_char_type(0xCD));
|
||||
write_number(static_cast<uint16_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint16_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
// uint 32
|
||||
oa->write_character(to_char_type(0xCE));
|
||||
write_number(static_cast<uint32_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint32_t>(j.m_value.number_integer));
|
||||
}
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<uint64_t>::max)())
|
||||
else if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint64_t>::max)())
|
||||
{
|
||||
// uint 64
|
||||
oa->write_character(to_char_type(0xCF));
|
||||
write_number(static_cast<uint64_t>(j.m_value.number_integer));
|
||||
write_number(static_cast<std::uint64_t>(j.m_value.number_integer));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -447,25 +447,25 @@ class binary_writer
|
|||
if (N <= 31)
|
||||
{
|
||||
// fixstr
|
||||
write_number(static_cast<uint8_t>(0xA0 | N));
|
||||
write_number(static_cast<std::uint8_t>(0xA0 | N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
// str 8
|
||||
oa->write_character(to_char_type(0xD9));
|
||||
write_number(static_cast<uint8_t>(N));
|
||||
write_number(static_cast<std::uint8_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
// str 16
|
||||
oa->write_character(to_char_type(0xDA));
|
||||
write_number(static_cast<uint16_t>(N));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
// str 32
|
||||
oa->write_character(to_char_type(0xDB));
|
||||
write_number(static_cast<uint32_t>(N));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
|
||||
// step 2: write the string
|
||||
|
@ -482,19 +482,19 @@ class binary_writer
|
|||
if (N <= 15)
|
||||
{
|
||||
// fixarray
|
||||
write_number(static_cast<uint8_t>(0x90 | N));
|
||||
write_number(static_cast<std::uint8_t>(0x90 | N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
// array 16
|
||||
oa->write_character(to_char_type(0xDC));
|
||||
write_number(static_cast<uint16_t>(N));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
// array 32
|
||||
oa->write_character(to_char_type(0xDD));
|
||||
write_number(static_cast<uint32_t>(N));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
|
||||
// step 2: write each element
|
||||
|
@ -512,19 +512,19 @@ class binary_writer
|
|||
if (N <= 15)
|
||||
{
|
||||
// fixmap
|
||||
write_number(static_cast<uint8_t>(0x80 | (N & 0xF)));
|
||||
write_number(static_cast<std::uint8_t>(0x80 | (N & 0xF)));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint16_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint16_t>::max)())
|
||||
{
|
||||
// map 16
|
||||
oa->write_character(to_char_type(0xDE));
|
||||
write_number(static_cast<uint16_t>(N));
|
||||
write_number(static_cast<std::uint16_t>(N));
|
||||
}
|
||||
else if (N <= (std::numeric_limits<uint32_t>::max)())
|
||||
else if (N <= (std::numeric_limits<std::uint32_t>::max)())
|
||||
{
|
||||
// map 32
|
||||
oa->write_character(to_char_type(0xDF));
|
||||
write_number(static_cast<uint32_t>(N));
|
||||
write_number(static_cast<std::uint32_t>(N));
|
||||
}
|
||||
|
||||
// step 2: write each element
|
||||
|
@ -790,14 +790,9 @@ class binary_writer
|
|||
*/
|
||||
static std::size_t calc_bson_integer_size(const std::int64_t value)
|
||||
{
|
||||
if ((std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
return sizeof(std::int32_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
return sizeof(std::int64_t);
|
||||
}
|
||||
return (std::numeric_limits<std::int32_t>::min)() <= value and value <= (std::numeric_limits<std::int32_t>::max)()
|
||||
? sizeof(std::int32_t)
|
||||
: sizeof(std::int64_t);
|
||||
}
|
||||
|
||||
/*!
|
||||
|
@ -1065,45 +1060,45 @@ class binary_writer
|
|||
void write_number_with_ubjson_prefix(const NumberType n,
|
||||
const bool add_prefix)
|
||||
{
|
||||
if (n <= static_cast<uint64_t>((std::numeric_limits<int8_t>::max)()))
|
||||
if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int8_t>::max)()))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('i')); // int8
|
||||
}
|
||||
write_number(static_cast<uint8_t>(n));
|
||||
write_number(static_cast<std::uint8_t>(n));
|
||||
}
|
||||
else if (n <= (std::numeric_limits<uint8_t>::max)())
|
||||
else if (n <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('U')); // uint8
|
||||
}
|
||||
write_number(static_cast<uint8_t>(n));
|
||||
write_number(static_cast<std::uint8_t>(n));
|
||||
}
|
||||
else if (n <= static_cast<uint64_t>((std::numeric_limits<int16_t>::max)()))
|
||||
else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int16_t>::max)()))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('I')); // int16
|
||||
}
|
||||
write_number(static_cast<int16_t>(n));
|
||||
write_number(static_cast<std::int16_t>(n));
|
||||
}
|
||||
else if (n <= static_cast<uint64_t>((std::numeric_limits<int32_t>::max)()))
|
||||
else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int32_t>::max)()))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('l')); // int32
|
||||
}
|
||||
write_number(static_cast<int32_t>(n));
|
||||
write_number(static_cast<std::int32_t>(n));
|
||||
}
|
||||
else if (n <= static_cast<uint64_t>((std::numeric_limits<int64_t>::max)()))
|
||||
else if (n <= static_cast<std::uint64_t>((std::numeric_limits<std::int64_t>::max)()))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('L')); // int64
|
||||
}
|
||||
write_number(static_cast<int64_t>(n));
|
||||
write_number(static_cast<std::int64_t>(n));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1118,45 +1113,45 @@ class binary_writer
|
|||
void write_number_with_ubjson_prefix(const NumberType n,
|
||||
const bool add_prefix)
|
||||
{
|
||||
if ((std::numeric_limits<int8_t>::min)() <= n and n <= (std::numeric_limits<int8_t>::max)())
|
||||
if ((std::numeric_limits<std::int8_t>::min)() <= n and n <= (std::numeric_limits<std::int8_t>::max)())
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('i')); // int8
|
||||
}
|
||||
write_number(static_cast<int8_t>(n));
|
||||
write_number(static_cast<std::int8_t>(n));
|
||||
}
|
||||
else if (static_cast<int64_t>((std::numeric_limits<uint8_t>::min)()) <= n and n <= static_cast<int64_t>((std::numeric_limits<uint8_t>::max)()))
|
||||
else if (static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::min)()) <= n and n <= static_cast<std::int64_t>((std::numeric_limits<std::uint8_t>::max)()))
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('U')); // uint8
|
||||
}
|
||||
write_number(static_cast<uint8_t>(n));
|
||||
write_number(static_cast<std::uint8_t>(n));
|
||||
}
|
||||
else if ((std::numeric_limits<int16_t>::min)() <= n and n <= (std::numeric_limits<int16_t>::max)())
|
||||
else if ((std::numeric_limits<std::int16_t>::min)() <= n and n <= (std::numeric_limits<std::int16_t>::max)())
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('I')); // int16
|
||||
}
|
||||
write_number(static_cast<int16_t>(n));
|
||||
write_number(static_cast<std::int16_t>(n));
|
||||
}
|
||||
else if ((std::numeric_limits<int32_t>::min)() <= n and n <= (std::numeric_limits<int32_t>::max)())
|
||||
else if ((std::numeric_limits<std::int32_t>::min)() <= n and n <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('l')); // int32
|
||||
}
|
||||
write_number(static_cast<int32_t>(n));
|
||||
write_number(static_cast<std::int32_t>(n));
|
||||
}
|
||||
else if ((std::numeric_limits<int64_t>::min)() <= n and n <= (std::numeric_limits<int64_t>::max)())
|
||||
else if ((std::numeric_limits<std::int64_t>::min)() <= n and n <= (std::numeric_limits<std::int64_t>::max)())
|
||||
{
|
||||
if (add_prefix)
|
||||
{
|
||||
oa->write_character(to_char_type('L')); // int64
|
||||
}
|
||||
write_number(static_cast<int64_t>(n));
|
||||
write_number(static_cast<std::int64_t>(n));
|
||||
}
|
||||
// LCOV_EXCL_START
|
||||
else
|
||||
|
@ -1187,19 +1182,19 @@ class binary_writer
|
|||
|
||||
case value_t::number_integer:
|
||||
{
|
||||
if ((std::numeric_limits<int8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<int8_t>::max)())
|
||||
if ((std::numeric_limits<std::int8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int8_t>::max)())
|
||||
{
|
||||
return 'i';
|
||||
}
|
||||
if ((std::numeric_limits<uint8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<uint8_t>::max)())
|
||||
if ((std::numeric_limits<std::uint8_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
return 'U';
|
||||
}
|
||||
if ((std::numeric_limits<int16_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<int16_t>::max)())
|
||||
if ((std::numeric_limits<std::int16_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int16_t>::max)())
|
||||
{
|
||||
return 'I';
|
||||
}
|
||||
if ((std::numeric_limits<int32_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<int32_t>::max)())
|
||||
if ((std::numeric_limits<std::int32_t>::min)() <= j.m_value.number_integer and j.m_value.number_integer <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
return 'l';
|
||||
}
|
||||
|
@ -1209,19 +1204,19 @@ class binary_writer
|
|||
|
||||
case value_t::number_unsigned:
|
||||
{
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<int8_t>::max)())
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<std::int8_t>::max)())
|
||||
{
|
||||
return 'i';
|
||||
}
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<uint8_t>::max)())
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<std::uint8_t>::max)())
|
||||
{
|
||||
return 'U';
|
||||
}
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<int16_t>::max)())
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<std::int16_t>::max)())
|
||||
{
|
||||
return 'I';
|
||||
}
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<int32_t>::max)())
|
||||
if (j.m_value.number_unsigned <= (std::numeric_limits<std::int32_t>::max)())
|
||||
{
|
||||
return 'l';
|
||||
}
|
||||
|
|
|
@ -45,8 +45,8 @@ class serializer
|
|||
using number_float_t = typename BasicJsonType::number_float_t;
|
||||
using number_integer_t = typename BasicJsonType::number_integer_t;
|
||||
using number_unsigned_t = typename BasicJsonType::number_unsigned_t;
|
||||
static constexpr uint8_t UTF8_ACCEPT = 0;
|
||||
static constexpr uint8_t UTF8_REJECT = 1;
|
||||
static constexpr std::uint8_t UTF8_ACCEPT = 0;
|
||||
static constexpr std::uint8_t UTF8_REJECT = 1;
|
||||
|
||||
public:
|
||||
/*!
|
||||
|
@ -298,8 +298,8 @@ class serializer
|
|||
*/
|
||||
void dump_escaped(const string_t& s, const bool ensure_ascii)
|
||||
{
|
||||
uint32_t codepoint;
|
||||
uint8_t state = UTF8_ACCEPT;
|
||||
std::uint32_t codepoint;
|
||||
std::uint8_t state = UTF8_ACCEPT;
|
||||
std::size_t bytes = 0; // number of bytes written to string_buffer
|
||||
|
||||
// number of bytes written at the point of the last valid byte
|
||||
|
@ -374,14 +374,14 @@ class serializer
|
|||
if (codepoint <= 0xFFFF)
|
||||
{
|
||||
(std::snprintf)(string_buffer.data() + bytes, 7, "\\u%04x",
|
||||
static_cast<uint16_t>(codepoint));
|
||||
static_cast<std::uint16_t>(codepoint));
|
||||
bytes += 6;
|
||||
}
|
||||
else
|
||||
{
|
||||
(std::snprintf)(string_buffer.data() + bytes, 13, "\\u%04x\\u%04x",
|
||||
static_cast<uint16_t>(0xD7C0 + (codepoint >> 10)),
|
||||
static_cast<uint16_t>(0xDC00 + (codepoint & 0x3FF)));
|
||||
static_cast<std::uint16_t>(0xD7C0u + (codepoint >> 10u)),
|
||||
static_cast<std::uint16_t>(0xDC00u + (codepoint & 0x3FFu)));
|
||||
bytes += 12;
|
||||
}
|
||||
}
|
||||
|
@ -508,7 +508,7 @@ class serializer
|
|||
case error_handler_t::strict:
|
||||
{
|
||||
std::string sn(3, '\0');
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<uint8_t>(s.back()));
|
||||
(std::snprintf)(&sn[0], sn.size(), "%.2X", static_cast<std::uint8_t>(s.back()));
|
||||
JSON_THROW(type_error::create(316, "incomplete UTF-8 string; last byte: 0x" + sn));
|
||||
}
|
||||
|
||||
|
@ -590,16 +590,16 @@ class serializer
|
|||
static constexpr std::array<std::array<char, 2>, 100> digits_to_99
|
||||
{
|
||||
{
|
||||
{'0', '0'}, {'0', '1'}, {'0', '2'}, {'0', '3'}, {'0', '4'}, {'0', '5'}, {'0', '6'}, {'0', '7'}, {'0', '8'}, {'0', '9'},
|
||||
{'1', '0'}, {'1', '1'}, {'1', '2'}, {'1', '3'}, {'1', '4'}, {'1', '5'}, {'1', '6'}, {'1', '7'}, {'1', '8'}, {'1', '9'},
|
||||
{'2', '0'}, {'2', '1'}, {'2', '2'}, {'2', '3'}, {'2', '4'}, {'2', '5'}, {'2', '6'}, {'2', '7'}, {'2', '8'}, {'2', '9'},
|
||||
{'3', '0'}, {'3', '1'}, {'3', '2'}, {'3', '3'}, {'3', '4'}, {'3', '5'}, {'3', '6'}, {'3', '7'}, {'3', '8'}, {'3', '9'},
|
||||
{'4', '0'}, {'4', '1'}, {'4', '2'}, {'4', '3'}, {'4', '4'}, {'4', '5'}, {'4', '6'}, {'4', '7'}, {'4', '8'}, {'4', '9'},
|
||||
{'5', '0'}, {'5', '1'}, {'5', '2'}, {'5', '3'}, {'5', '4'}, {'5', '5'}, {'5', '6'}, {'5', '7'}, {'5', '8'}, {'5', '9'},
|
||||
{'6', '0'}, {'6', '1'}, {'6', '2'}, {'6', '3'}, {'6', '4'}, {'6', '5'}, {'6', '6'}, {'6', '7'}, {'6', '8'}, {'6', '9'},
|
||||
{'7', '0'}, {'7', '1'}, {'7', '2'}, {'7', '3'}, {'7', '4'}, {'7', '5'}, {'7', '6'}, {'7', '7'}, {'7', '8'}, {'7', '9'},
|
||||
{'8', '0'}, {'8', '1'}, {'8', '2'}, {'8', '3'}, {'8', '4'}, {'8', '5'}, {'8', '6'}, {'8', '7'}, {'8', '8'}, {'8', '9'},
|
||||
{'9', '0'}, {'9', '1'}, {'9', '2'}, {'9', '3'}, {'9', '4'}, {'9', '5'}, {'9', '6'}, {'9', '7'}, {'9', '8'}, {'9', '9'},
|
||||
{{'0', '0'}}, {{'0', '1'}}, {{'0', '2'}}, {{'0', '3'}}, {{'0', '4'}}, {{'0', '5'}}, {{'0', '6'}}, {{'0', '7'}}, {{'0', '8'}}, {{'0', '9'}},
|
||||
{{'1', '0'}}, {{'1', '1'}}, {{'1', '2'}}, {{'1', '3'}}, {{'1', '4'}}, {{'1', '5'}}, {{'1', '6'}}, {{'1', '7'}}, {{'1', '8'}}, {{'1', '9'}},
|
||||
{{'2', '0'}}, {{'2', '1'}}, {{'2', '2'}}, {{'2', '3'}}, {{'2', '4'}}, {{'2', '5'}}, {{'2', '6'}}, {{'2', '7'}}, {{'2', '8'}}, {{'2', '9'}},
|
||||
{{'3', '0'}}, {{'3', '1'}}, {{'3', '2'}}, {{'3', '3'}}, {{'3', '4'}}, {{'3', '5'}}, {{'3', '6'}}, {{'3', '7'}}, {{'3', '8'}}, {{'3', '9'}},
|
||||
{{'4', '0'}}, {{'4', '1'}}, {{'4', '2'}}, {{'4', '3'}}, {{'4', '4'}}, {{'4', '5'}}, {{'4', '6'}}, {{'4', '7'}}, {{'4', '8'}}, {{'4', '9'}},
|
||||
{{'5', '0'}}, {{'5', '1'}}, {{'5', '2'}}, {{'5', '3'}}, {{'5', '4'}}, {{'5', '5'}}, {{'5', '6'}}, {{'5', '7'}}, {{'5', '8'}}, {{'5', '9'}},
|
||||
{{'6', '0'}}, {{'6', '1'}}, {{'6', '2'}}, {{'6', '3'}}, {{'6', '4'}}, {{'6', '5'}}, {{'6', '6'}}, {{'6', '7'}}, {{'6', '8'}}, {{'6', '9'}},
|
||||
{{'7', '0'}}, {{'7', '1'}}, {{'7', '2'}}, {{'7', '3'}}, {{'7', '4'}}, {{'7', '5'}}, {{'7', '6'}}, {{'7', '7'}}, {{'7', '8'}}, {{'7', '9'}},
|
||||
{{'8', '0'}}, {{'8', '1'}}, {{'8', '2'}}, {{'8', '3'}}, {{'8', '4'}}, {{'8', '5'}}, {{'8', '6'}}, {{'8', '7'}}, {{'8', '8'}}, {{'8', '9'}},
|
||||
{{'9', '0'}}, {{'9', '1'}}, {{'9', '2'}}, {{'9', '3'}}, {{'9', '4'}}, {{'9', '5'}}, {{'9', '6'}}, {{'9', '7'}}, {{'9', '8'}}, {{'9', '9'}},
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -770,9 +770,9 @@ class serializer
|
|||
@copyright Copyright (c) 2008-2009 Bjoern Hoehrmann <bjoern@hoehrmann.de>
|
||||
@sa http://bjoern.hoehrmann.de/utf-8/decoder/dfa/
|
||||
*/
|
||||
static uint8_t decode(uint8_t& state, uint32_t& codep, const uint8_t byte) noexcept
|
||||
static std::uint8_t decode(std::uint8_t& state, std::uint32_t& codep, const std::uint8_t byte) noexcept
|
||||
{
|
||||
static const std::array<uint8_t, 400> utf8d =
|
||||
static const std::array<std::uint8_t, 400> utf8d =
|
||||
{
|
||||
{
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 00..1F
|
||||
|
@ -792,11 +792,11 @@ class serializer
|
|||
}
|
||||
};
|
||||
|
||||
const uint8_t type = utf8d[byte];
|
||||
const std::uint8_t type = utf8d[byte];
|
||||
|
||||
codep = (state != UTF8_ACCEPT)
|
||||
? (byte & 0x3fu) | (codep << 6)
|
||||
: static_cast<uint32_t>(0xff >> type) & (byte);
|
||||
? (byte & 0x3fu) | (codep << 6u)
|
||||
: (0xFFu >> type) & (byte);
|
||||
|
||||
state = utf8d[256u + state * 16u + type];
|
||||
return state;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue