Unverified Commit e5ef44c4 authored by Niels Lohmann's avatar Niels Lohmann Committed by GitHub

Merge pull request #2927 from fhuberts/fix-switch-enum

...@@ -99,7 +99,7 @@ set(CLANG_CXXFLAGS "-std=c++11 \ ...@@ -99,7 +99,7 @@ set(CLANG_CXXFLAGS "-std=c++11 \
-Wno-extra-semi-stmt \ -Wno-extra-semi-stmt \
-Wno-padded \ -Wno-padded \
-Wno-range-loop-analysis \ -Wno-range-loop-analysis \
-Wno-switch-enum -Wno-covered-switch-default \ -Wno-covered-switch-default \
-Wno-weak-vtables \ -Wno-weak-vtables \
") ")
...@@ -326,7 +326,7 @@ set(GCC_CXXFLAGS "-std=c++11 \ ...@@ -326,7 +326,7 @@ set(GCC_CXXFLAGS "-std=c++11 \
-Wswitch \ -Wswitch \
-Wswitch-bool \ -Wswitch-bool \
-Wswitch-default \ -Wswitch-default \
-Wno-switch-enum \ -Wswitch-enum \
-Wswitch-outside-range \ -Wswitch-outside-range \
-Wswitch-unreachable \ -Wswitch-unreachable \
-Wsync-nand \ -Wsync-nand \
......
...@@ -58,6 +58,13 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val) ...@@ -58,6 +58,13 @@ void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
break; break;
} }
case value_t::null:
case value_t::object:
case value_t::array:
case value_t::string:
case value_t::boolean:
case value_t::binary:
case value_t::discarded:
default: default:
JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
} }
...@@ -343,6 +350,12 @@ void from_json(const BasicJsonType& j, ArithmeticType& val) ...@@ -343,6 +350,12 @@ void from_json(const BasicJsonType& j, ArithmeticType& val)
break; break;
} }
case value_t::null:
case value_t::object:
case value_t::array:
case value_t::string:
case value_t::binary:
case value_t::discarded:
default: default:
JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j)); JSON_THROW(type_error::create(302, "type must be number, but is " + std::string(j.type_name()), j));
} }
......
...@@ -102,6 +102,14 @@ class exception : public std::exception ...@@ -102,6 +102,14 @@ class exception : public std::exception
break; break;
} }
case value_t::null: // LCOV_EXCL_LINE
case value_t::string: // LCOV_EXCL_LINE
case value_t::boolean: // LCOV_EXCL_LINE
case value_t::number_integer: // LCOV_EXCL_LINE
case value_t::number_unsigned: // LCOV_EXCL_LINE
case value_t::number_float: // LCOV_EXCL_LINE
case value_t::binary: // LCOV_EXCL_LINE
case value_t::discarded: // LCOV_EXCL_LINE
default: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE
break; // LCOV_EXCL_LINE break; // LCOV_EXCL_LINE
} }
......
...@@ -119,6 +119,7 @@ class binary_reader ...@@ -119,6 +119,7 @@ class binary_reader
result = parse_ubjson_internal(); result = parse_ubjson_internal();
break; break;
case input_format_t::json: // LCOV_EXCL_LINE
default: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
} }
...@@ -2236,6 +2237,20 @@ class binary_reader ...@@ -2236,6 +2237,20 @@ class binary_reader
return sax->number_unsigned(number_lexer.get_number_unsigned()); return sax->number_unsigned(number_lexer.get_number_unsigned());
case token_type::value_float: case token_type::value_float:
return sax->number_float(number_lexer.get_number_float(), std::move(number_string)); return sax->number_float(number_lexer.get_number_float(), std::move(number_string));
case token_type::uninitialized:
case token_type::literal_true:
case token_type::literal_false:
case token_type::literal_null:
case token_type::value_string:
case token_type::begin_array:
case token_type::begin_object:
case token_type::end_array:
case token_type::end_object:
case token_type::name_separator:
case token_type::value_separator:
case token_type::parse_error:
case token_type::end_of_input:
case token_type::literal_or_value:
default: default:
return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType())); return sax->parse_error(chars_read, number_string, parse_error::create(115, chars_read, exception_message(input_format_t::ubjson, "invalid number text: " + number_lexer.get_token_string(), "high-precision number"), BasicJsonType()));
} }
...@@ -2438,6 +2453,7 @@ class binary_reader ...@@ -2438,6 +2453,7 @@ class binary_reader
error_msg += "BSON"; error_msg += "BSON";
break; break;
case input_format_t::json: // LCOV_EXCL_LINE
default: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
} }
......
...@@ -334,6 +334,13 @@ class parser ...@@ -334,6 +334,13 @@ class parser
parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType())); parse_error::create(101, m_lexer.get_position(), exception_message(token_type::uninitialized, "value"), BasicJsonType()));
} }
case token_type::uninitialized:
case token_type::end_array:
case token_type::end_object:
case token_type::name_separator:
case token_type::value_separator:
case token_type::end_of_input:
case token_type::literal_or_value:
default: // the last token was unexpected default: // the last token was unexpected
{ {
return sax->parse_error(m_lexer.get_position(), return sax->parse_error(m_lexer.get_position(),
......
...@@ -104,6 +104,14 @@ class iter_impl ...@@ -104,6 +104,14 @@ class iter_impl
break; break;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
m_it.primitive_iterator = primitive_iterator_t(); m_it.primitive_iterator = primitive_iterator_t();
...@@ -200,6 +208,13 @@ class iter_impl ...@@ -200,6 +208,13 @@ class iter_impl
break; break;
} }
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
m_it.primitive_iterator.set_begin(); m_it.primitive_iterator.set_begin();
...@@ -230,6 +245,14 @@ class iter_impl ...@@ -230,6 +245,14 @@ class iter_impl
break; break;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
m_it.primitive_iterator.set_end(); m_it.primitive_iterator.set_end();
...@@ -264,6 +287,13 @@ class iter_impl ...@@ -264,6 +287,13 @@ class iter_impl
case value_t::null: case value_t::null:
JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin()))
...@@ -298,6 +328,14 @@ class iter_impl ...@@ -298,6 +328,14 @@ class iter_impl
return &*m_it.array_iterator; return &*m_it.array_iterator;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin())) if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.is_begin()))
...@@ -343,6 +381,14 @@ class iter_impl ...@@ -343,6 +381,14 @@ class iter_impl
break; break;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
++m_it.primitive_iterator; ++m_it.primitive_iterator;
...@@ -386,6 +432,14 @@ class iter_impl ...@@ -386,6 +432,14 @@ class iter_impl
break; break;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
--m_it.primitive_iterator; --m_it.primitive_iterator;
...@@ -419,6 +473,14 @@ class iter_impl ...@@ -419,6 +473,14 @@ class iter_impl
case value_t::array: case value_t::array:
return (m_it.array_iterator == other.m_it.array_iterator); return (m_it.array_iterator == other.m_it.array_iterator);
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
return (m_it.primitive_iterator == other.m_it.primitive_iterator); return (m_it.primitive_iterator == other.m_it.primitive_iterator);
} }
...@@ -456,6 +518,14 @@ class iter_impl ...@@ -456,6 +518,14 @@ class iter_impl
case value_t::array: case value_t::array:
return (m_it.array_iterator < other.m_it.array_iterator); return (m_it.array_iterator < other.m_it.array_iterator);
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
return (m_it.primitive_iterator < other.m_it.primitive_iterator); return (m_it.primitive_iterator < other.m_it.primitive_iterator);
} }
...@@ -507,6 +577,14 @@ class iter_impl ...@@ -507,6 +577,14 @@ class iter_impl
break; break;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
m_it.primitive_iterator += i; m_it.primitive_iterator += i;
...@@ -575,6 +653,14 @@ class iter_impl ...@@ -575,6 +653,14 @@ class iter_impl
case value_t::array: case value_t::array:
return m_it.array_iterator - other.m_it.array_iterator; return m_it.array_iterator - other.m_it.array_iterator;
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
return m_it.primitive_iterator - other.m_it.primitive_iterator; return m_it.primitive_iterator - other.m_it.primitive_iterator;
} }
...@@ -599,6 +685,13 @@ class iter_impl ...@@ -599,6 +685,13 @@ class iter_impl
case value_t::null: case value_t::null:
JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object)); JSON_THROW(invalid_iterator::create(214, "cannot get value", *m_object));
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n)) if (JSON_HEDLEY_LIKELY(m_it.primitive_iterator.get_value() == -n))
......
...@@ -97,6 +97,14 @@ template<typename IteratorType> class iteration_proxy_value ...@@ -97,6 +97,14 @@ template<typename IteratorType> class iteration_proxy_value
return anchor.key(); return anchor.key();
// use an empty key for all primitive types // use an empty key for all primitive types
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
return empty_str; return empty_str;
} }
......
...@@ -441,6 +441,13 @@ class json_pointer ...@@ -441,6 +441,13 @@ class json_pointer
an error situation, because primitive values may only occur as an error situation, because primitive values may only occur as
single value; that is, with an empty list of reference tokens. single value; that is, with an empty list of reference tokens.
*/ */
case detail::value_t::string:
case detail::value_t::boolean:
case detail::value_t::number_integer:
case detail::value_t::number_unsigned:
case detail::value_t::number_float:
case detail::value_t::binary:
case detail::value_t::discarded:
default: default:
JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j)); JSON_THROW(detail::type_error::create(313, "invalid value to unflatten", j));
} }
...@@ -513,6 +520,14 @@ class json_pointer ...@@ -513,6 +520,14 @@ class json_pointer
break; break;
} }
case detail::value_t::null:
case detail::value_t::string:
case detail::value_t::boolean:
case detail::value_t::number_integer:
case detail::value_t::number_unsigned:
case detail::value_t::number_float:
case detail::value_t::binary:
case detail::value_t::discarded:
default: default:
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
} }
...@@ -555,6 +570,14 @@ class json_pointer ...@@ -555,6 +570,14 @@ class json_pointer
break; break;
} }
case detail::value_t::null:
case detail::value_t::string:
case detail::value_t::boolean:
case detail::value_t::number_integer:
case detail::value_t::number_unsigned:
case detail::value_t::number_float:
case detail::value_t::binary:
case detail::value_t::discarded:
default: default:
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
} }
...@@ -602,6 +625,14 @@ class json_pointer ...@@ -602,6 +625,14 @@ class json_pointer
break; break;
} }
case detail::value_t::null:
case detail::value_t::string:
case detail::value_t::boolean:
case detail::value_t::number_integer:
case detail::value_t::number_unsigned:
case detail::value_t::number_float:
case detail::value_t::binary:
case detail::value_t::discarded:
default: default:
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
} }
...@@ -644,6 +675,14 @@ class json_pointer ...@@ -644,6 +675,14 @@ class json_pointer
break; break;
} }
case detail::value_t::null:
case detail::value_t::string:
case detail::value_t::boolean:
case detail::value_t::number_integer:
case detail::value_t::number_unsigned:
case detail::value_t::number_float:
case detail::value_t::binary:
case detail::value_t::discarded:
default: default:
JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr)); JSON_THROW(detail::out_of_range::create(404, "unresolved reference token '" + reference_token + "'", *ptr));
} }
...@@ -714,6 +753,14 @@ class json_pointer ...@@ -714,6 +753,14 @@ class json_pointer
break; break;
} }
case detail::value_t::null:
case detail::value_t::string:
case detail::value_t::boolean:
case detail::value_t::number_integer:
case detail::value_t::number_unsigned:
case detail::value_t::number_float:
case detail::value_t::binary:
case detail::value_t::discarded:
default: default:
{ {
// we do not expect primitive values if there is still a // we do not expect primitive values if there is still a
...@@ -847,6 +894,14 @@ class json_pointer ...@@ -847,6 +894,14 @@ class json_pointer
break; break;
} }
case detail::value_t::null:
case detail::value_t::string:
case detail::value_t::boolean:
case detail::value_t::number_integer:
case detail::value_t::number_unsigned:
case detail::value_t::number_float:
case detail::value_t::binary:
case detail::value_t::discarded:
default: default:
{ {
// add primitive value with its reference string // add primitive value with its reference string
......
...@@ -56,6 +56,15 @@ class binary_writer ...@@ -56,6 +56,15 @@ class binary_writer
break; break;
} }
case value_t::null:
case value_t::array:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j));; JSON_THROW(type_error::create(317, "to serialize to BSON, top-level type must be object, but is " + std::string(j.type_name()), j));;
...@@ -363,6 +372,7 @@ class binary_writer ...@@ -363,6 +372,7 @@ class binary_writer
break; break;
} }
case value_t::discarded:
default: default:
break; break;
} }
...@@ -684,6 +694,7 @@ class binary_writer ...@@ -684,6 +694,7 @@ class binary_writer
break; break;
} }
case value_t::discarded:
default: default:
break; break;
} }
...@@ -888,6 +899,7 @@ class binary_writer ...@@ -888,6 +899,7 @@ class binary_writer
break; break;
} }
case value_t::discarded:
default: default:
break; break;
} }
...@@ -1140,6 +1152,7 @@ class binary_writer ...@@ -1140,6 +1152,7 @@ class binary_writer
return header_size + 0ul; return header_size + 0ul;
// LCOV_EXCL_START // LCOV_EXCL_START
case value_t::discarded:
default: default:
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
return 0ul; return 0ul;
...@@ -1186,6 +1199,7 @@ class binary_writer ...@@ -1186,6 +1199,7 @@ class binary_writer
return write_bson_null(name); return write_bson_null(name);
// LCOV_EXCL_START // LCOV_EXCL_START
case value_t::discarded:
default: default:
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert)
return; return;
...@@ -1476,6 +1490,7 @@ class binary_writer ...@@ -1476,6 +1490,7 @@ class binary_writer
case value_t::object: case value_t::object:
return '{'; return '{';
case value_t::discarded:
default: // discarded values default: // discarded values
return 'N'; return 'N';
} }
......
...@@ -1059,6 +1059,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -1059,6 +1059,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::discarded:
default: default:
{ {
object = nullptr; // silence warning, see #821 object = nullptr; // silence warning, see #821
...@@ -1216,6 +1217,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -1216,6 +1217,12 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::discarded:
default: default:
{ {
break; break;
...@@ -1287,6 +1294,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -1287,6 +1294,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
break; break;
} }
...@@ -2051,6 +2066,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -2051,6 +2066,11 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::object:
case value_t::array:
case value_t::binary:
case value_t::discarded:
default: default:
break; break;
} }
...@@ -2107,6 +2127,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -2107,6 +2127,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::discarded:
default: default:
JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), *first.m_object)); JSON_THROW(invalid_iterator::create(206, "cannot construct with iterators from " + std::string(first.m_object->type_name()), *first.m_object));
} }
...@@ -2206,6 +2228,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -2206,6 +2228,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::discarded:
default: default:
break; break;
} }
...@@ -4230,6 +4254,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -4230,6 +4254,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::discarded:
default: default:
JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
} }
...@@ -4346,6 +4372,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -4346,6 +4372,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::discarded:
default: default:
JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this)); JSON_THROW(type_error::create(307, "cannot use erase() with " + std::string(type_name()), *this));
} }
...@@ -5101,6 +5129,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -5101,6 +5129,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return m_value.object->empty(); return m_value.object->empty();
} }
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
// all other types are nonempty // all other types are nonempty
...@@ -5174,6 +5209,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -5174,6 +5209,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return m_value.object->size(); return m_value.object->size();
} }
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
// all other types have size 1 // all other types have size 1
...@@ -5239,6 +5281,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -5239,6 +5281,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return m_value.object->max_size(); return m_value.object->max_size();
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
// all other types have max_size() == size() // all other types have max_size() == size()
...@@ -5346,6 +5396,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -5346,6 +5396,8 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::discarded:
default: default:
break; break;
} }
...@@ -6316,6 +6368,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -6316,6 +6368,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
case value_t::binary: case value_t::binary:
return *lhs.m_value.binary == *rhs.m_value.binary; return *lhs.m_value.binary == *rhs.m_value.binary;
case value_t::discarded:
default: default:
return false; return false;
} }
...@@ -6482,6 +6535,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -6482,6 +6535,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
case value_t::binary: case value_t::binary:
return (*lhs.m_value.binary) < (*rhs.m_value.binary); return (*lhs.m_value.binary) < (*rhs.m_value.binary);
case value_t::discarded:
default: default:
return false; return false;
} }
...@@ -7106,6 +7160,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -7106,6 +7160,9 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
return "binary"; return "binary";
case value_t::discarded: case value_t::discarded:
return "discarded"; return "discarded";
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
default: default:
return "number"; return "number";
} }
...@@ -8439,6 +8496,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -8439,6 +8496,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
} }
// if there exists a parent it cannot be primitive // if there exists a parent it cannot be primitive
case value_t::string: // LCOV_EXCL_LINE
case value_t::boolean: // LCOV_EXCL_LINE
case value_t::number_integer: // LCOV_EXCL_LINE
case value_t::number_unsigned: // LCOV_EXCL_LINE
case value_t::number_float: // LCOV_EXCL_LINE
case value_t::binary: // LCOV_EXCL_LINE
case value_t::discarded: // LCOV_EXCL_LINE
default: // LCOV_EXCL_LINE default: // LCOV_EXCL_LINE
JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE JSON_ASSERT(false); // NOLINT(cert-dcl03-c,hicpp-static-assert,misc-static-assert) LCOV_EXCL_LINE
} }
...@@ -8598,6 +8662,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -8598,6 +8662,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case patch_operations::invalid:
default: default:
{ {
// op must be "add", "remove", "replace", "move", "copy", or // op must be "add", "remove", "replace", "move", "copy", or
...@@ -8754,6 +8819,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec ...@@ -8754,6 +8819,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
break; break;
} }
case value_t::null:
case value_t::string:
case value_t::boolean:
case value_t::number_integer:
case value_t::number_unsigned:
case value_t::number_float:
case value_t::binary:
case value_t::discarded:
default: default:
{ {
// both primitive type: replace value // both primitive type: replace value
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment