Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle all enum cases in switch #890

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion src/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3251,6 +3251,20 @@ class parser
break; // LCOV_EXCL_LINE
}

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; we expected a value
Expand Down Expand Up @@ -6299,6 +6313,11 @@ class serializer
o->write_characters("null", 4);
return;
}

default:
{
return;
}
}
}

Expand Down Expand Up @@ -6564,7 +6583,7 @@ class serializer
// check that the additional bytes are present
assert(i + bytes < s.size());

// to use \uxxxx escaping, we first need to calculate
// to use \uxxxx escaping, we first need to calculate
// the codepoint from the UTF-8 bytes
int codepoint = 0;

Expand Down Expand Up @@ -8114,6 +8133,8 @@ class basic_json
break;
}

case value_t::discarded:

default:
{
object = nullptr; // silence warning, see #821
Expand Down Expand Up @@ -8190,6 +8211,18 @@ class basic_json
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:
{
break;
Expand Down