🚨 fix warnings

This commit is contained in:
Niels Lohmann 2020-06-06 14:30:17 +02:00
parent 7444c7fa25
commit bf2e714e96
No known key found for this signature in database
GPG key ID: 7F3CEA63AE251B69
8 changed files with 163 additions and 142 deletions

View file

@ -54,6 +54,8 @@ class binary_reader
using string_t = typename BasicJsonType::string_t;
using binary_t = typename BasicJsonType::binary_t;
using json_sax_t = SAX;
using char_type = typename InputAdapterType::char_type;
using char_int_type = typename std::char_traits<char_type>::int_type;
public:
/*!
@ -122,7 +124,7 @@ class binary_reader
get();
}
if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char>::eof()))
if (JSON_HEDLEY_UNLIKELY(current != std::char_traits<char_type>::eof()))
{
return sax->parse_error(chars_read, get_token_string(),
parse_error::create(110, chars_read, exception_message(format, "expected end of input; last byte: 0x" + get_token_string(), "value")));
@ -180,7 +182,7 @@ class binary_reader
{
return true;
}
*out++ = static_cast<char>(current);
*out++ = static_cast<typename string_t::value_type>(current);
}
return true;
@ -206,7 +208,7 @@ class binary_reader
return sax->parse_error(chars_read, last_token, parse_error::create(112, chars_read, exception_message(input_format_t::bson, "string length must be at least 1, is " + std::to_string(len), "string")));
}
return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char>::eof();
return get_string(input_format_t::bson, len - static_cast<NumberType>(1), result) and get() != std::char_traits<char_type>::eof();
}
/*!
@ -245,7 +247,7 @@ class binary_reader
Unsupported BSON record type 0x...
@return whether a valid BSON-object/array was passed to the SAX parser
*/
bool parse_bson_element_internal(const int element_type,
bool parse_bson_element_internal(const char_int_type element_type,
const std::size_t element_type_parse_position)
{
switch (element_type)
@ -327,7 +329,7 @@ class binary_reader
{
string_t key;
while (int element_type = get())
while (auto element_type = get())
{
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::bson, "element list")))
{
@ -395,7 +397,7 @@ class binary_reader
switch (get_char ? get() : current)
{
// EOF
case std::char_traits<char>::eof():
case std::char_traits<char_type>::eof():
return unexpect_eof(input_format_t::cbor, "value");
// Integer 0x00..0x17 (0..23)
@ -690,12 +692,12 @@ class binary_reader
case 0xF9: // Half-Precision Float (two-byte IEEE 754)
{
const int byte1_raw = get();
const auto byte1_raw = get();
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
{
return false;
}
const int byte2_raw = get();
const auto byte2_raw = get();
if (JSON_HEDLEY_UNLIKELY(not unexpect_eof(input_format_t::cbor, "number")))
{
return false;
@ -1048,7 +1050,7 @@ class binary_reader
switch (get())
{
// EOF
case std::char_traits<char>::eof():
case std::char_traits<char_type>::eof():
return unexpect_eof(input_format_t::msgpack, "value");
// positive fixint
@ -1825,7 +1827,7 @@ class binary_reader
@return whether pair creation completed
*/
bool get_ubjson_size_type(std::pair<std::size_t, int>& result)
bool get_ubjson_size_type(std::pair<std::size_t, char_int_type>& result)
{
result.first = string_t::npos; // size
result.second = 0; // type
@ -1866,11 +1868,11 @@ class binary_reader
@param prefix the previously read or set type prefix
@return whether value creation completed
*/
bool get_ubjson_value(const int prefix)
bool get_ubjson_value(const char_int_type prefix)
{
switch (prefix)
{
case std::char_traits<char>::eof(): // EOF
case std::char_traits<char_type>::eof(): // EOF
return unexpect_eof(input_format_t::ubjson, "value");
case 'T': // true
@ -1935,7 +1937,7 @@ class binary_reader
auto last_token = get_token_string();
return sax->parse_error(chars_read, last_token, parse_error::create(113, chars_read, exception_message(input_format_t::ubjson, "byte after 'C' must be in range 0x00..0x7F; last byte: 0x" + last_token, "char")));
}
string_t s(1, static_cast<char>(current));
string_t s(1, static_cast<typename string_t::value_type>(current));
return sax->string(s);
}
@ -1964,7 +1966,7 @@ class binary_reader
*/
bool get_ubjson_array()
{
std::pair<std::size_t, int> size_and_type;
std::pair<std::size_t, char_int_type> size_and_type;
if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type)))
{
return false;
@ -2026,7 +2028,7 @@ class binary_reader
*/
bool get_ubjson_object()
{
std::pair<std::size_t, int> size_and_type;
std::pair<std::size_t, char_int_type> size_and_type;
if (JSON_HEDLEY_UNLIKELY(not get_ubjson_size_type(size_and_type)))
{
return false;
@ -2108,11 +2110,11 @@ class binary_reader
This function provides the interface to the used input adapter. It does
not throw in case the input reached EOF, but returns a -'ve valued
`std::char_traits<char>::eof()` in that case.
`std::char_traits<char_type>::eof()` in that case.
@return character read from the input
*/
int get()
char_int_type get()
{
++chars_read;
return current = ia.get_character();
@ -2121,7 +2123,7 @@ class binary_reader
/*!
@return character read from the input after ignoring all 'N' entries
*/
int get_ignore_noop()
char_int_type get_ignore_noop()
{
do
{
@ -2201,7 +2203,7 @@ class binary_reader
{
success = false;
}
return static_cast<char>(current);
return std::char_traits<char_type>::to_char_type(current);
});
return success;
}
@ -2246,7 +2248,7 @@ class binary_reader
JSON_HEDLEY_NON_NULL(3)
bool unexpect_eof(const input_format_t format, const char* context) const
{
if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char>::eof()))
if (JSON_HEDLEY_UNLIKELY(current == std::char_traits<char_type>::eof()))
{
return sax->parse_error(chars_read, "<end of file>",
parse_error::create(110, chars_read, exception_message(format, "unexpected end of input", context)));
@ -2306,7 +2308,7 @@ class binary_reader
InputAdapterType ia;
/// the current character
int current = std::char_traits<char>::eof();
char_int_type current = std::char_traits<char_type>::eof();
/// the number of characters read
std::size_t chars_read = 0;