1
0
mirror of https://github.com/nlohmann/json synced 2024-11-10 06:20:06 +00:00

clean up (for #154)

This commit is contained in:
Niels 2015-12-14 16:58:49 +01:00
parent 258f04c561
commit 5bc1b65676
3 changed files with 1 additions and 299 deletions

View File

@ -17,7 +17,7 @@ clean:
########################################################################## ##########################################################################
# additional flags # additional flags
FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wswitch-enum -Wswitch-default -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal
# build unit tests # build unit tests
json_unit: test/unit.cpp src/json.hpp test/catch.hpp json_unit: test/unit.cpp src/json.hpp test/catch.hpp

View File

@ -686,8 +686,6 @@ class basic_json
break; break;
} }
case value_t::null:
case value_t::discarded:
default: default:
{ {
break; break;
@ -1494,10 +1492,6 @@ class basic_json
break; break;
} }
case value_t::array:
case value_t::discarded:
case value_t::null:
case value_t::object:
default: default:
{ {
break; break;
@ -1542,8 +1536,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name()); throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
@ -1614,8 +1606,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
break; break;
@ -1719,11 +1709,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
default: default:
{ {
// all other types need no specific destructor // all other types need no specific destructor
@ -2169,12 +2154,6 @@ class basic_json
return static_cast<T>(m_value.number_float); return static_cast<T>(m_value.number_float);
} }
case value_t::array:
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::object:
case value_t::string:
default: default:
{ {
throw std::domain_error("type must be number, but is " + type_name()); throw std::domain_error("type must be number, but is " + type_name());
@ -2874,8 +2853,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
throw std::domain_error("cannot use erase() with " + type_name()); throw std::domain_error("cannot use erase() with " + type_name());
@ -2971,8 +2948,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
throw std::domain_error("cannot use erase with " + type_name()); throw std::domain_error("cannot use erase with " + type_name());
@ -3380,11 +3355,6 @@ class basic_json
return m_value.object->empty(); return m_value.object->empty();
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
// all other types are nonempty // all other types are nonempty
@ -3439,11 +3409,6 @@ class basic_json
return m_value.object->size(); return m_value.object->size();
} }
case value_t::boolean:
case value_t::discarded:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
// all other types have size 1 // all other types have size 1
@ -3496,12 +3461,6 @@ class basic_json
return m_value.object->max_size(); return m_value.object->max_size();
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
// all other types have max_size() == size() // all other types have max_size() == size()
@ -3583,8 +3542,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
break; break;
@ -4099,8 +4056,6 @@ class basic_json
return lhs.m_value.number_integer == rhs.m_value.number_integer; return lhs.m_value.number_integer == rhs.m_value.number_integer;
case value_t::number_float: case value_t::number_float:
return approx(lhs.m_value.number_float, rhs.m_value.number_float); return approx(lhs.m_value.number_float, rhs.m_value.number_float);
case value_t::discarded:
return false;
default: default:
return false; return false;
} }
@ -4242,8 +4197,6 @@ class basic_json
return lhs.m_value.number_integer < rhs.m_value.number_integer; return lhs.m_value.number_integer < rhs.m_value.number_integer;
case value_t::number_float: case value_t::number_float:
return lhs.m_value.number_float < rhs.m_value.number_float; return lhs.m_value.number_float < rhs.m_value.number_float;
case value_t::discarded:
return false;
default: default:
return false; return false;
} }
@ -4527,8 +4480,6 @@ class basic_json
return "discarded"; return "discarded";
} }
case value_t::number_float:
case value_t::number_integer:
default: default:
{ {
return "number"; return "number";
@ -4839,11 +4790,6 @@ class basic_json
o << "null"; o << "null";
return; return;
} }
default:
{
return;
}
} }
} }
@ -4991,12 +4937,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator = primitive_iterator_t(); m_it.primitive_iterator = primitive_iterator_t();
@ -5022,12 +4962,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
m_it.primitive_iterator = other.m_it.primitive_iterator; m_it.primitive_iterator = other.m_it.primitive_iterator;
@ -5079,11 +5013,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator.set_begin(); m_it.primitive_iterator.set_begin();
@ -5109,12 +5038,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator.set_end(); m_it.primitive_iterator.set_end();
@ -5144,11 +5067,6 @@ class basic_json
throw std::out_of_range("cannot get value"); throw std::out_of_range("cannot get value");
} }
case value_t::boolean:
case value_t::discarded:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
if (m_it.primitive_iterator.is_begin()) if (m_it.primitive_iterator.is_begin())
@ -5178,12 +5096,6 @@ class basic_json
return &*m_it.array_iterator; return &*m_it.array_iterator;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
if (m_it.primitive_iterator.is_begin()) if (m_it.primitive_iterator.is_begin())
@ -5224,12 +5136,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
++m_it.primitive_iterator; ++m_it.primitive_iterator;
@ -5266,12 +5172,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
--m_it.primitive_iterator; --m_it.primitive_iterator;
@ -5303,12 +5203,6 @@ class basic_json
return (m_it.array_iterator == other.m_it.array_iterator); return (m_it.array_iterator == other.m_it.array_iterator);
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
return (m_it.primitive_iterator == other.m_it.primitive_iterator); return (m_it.primitive_iterator == other.m_it.primitive_iterator);
@ -5343,12 +5237,6 @@ class basic_json
return (m_it.array_iterator < other.m_it.array_iterator); return (m_it.array_iterator < other.m_it.array_iterator);
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
return (m_it.primitive_iterator < other.m_it.primitive_iterator); return (m_it.primitive_iterator < other.m_it.primitive_iterator);
@ -5390,12 +5278,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator += i; m_it.primitive_iterator += i;
@ -5443,12 +5325,6 @@ class basic_json
return m_it.array_iterator - other.m_it.array_iterator; return m_it.array_iterator - other.m_it.array_iterator;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
return m_it.primitive_iterator - other.m_it.primitive_iterator; return m_it.primitive_iterator - other.m_it.primitive_iterator;
@ -5476,11 +5352,6 @@ class basic_json
throw std::out_of_range("cannot get value"); throw std::out_of_range("cannot get value");
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
if (m_it.primitive_iterator == -n) if (m_it.primitive_iterator == -n)
@ -5827,12 +5698,6 @@ class basic_json
} }
/// use an empty key for all primitive types /// use an empty key for all primitive types
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
return ""; return "";
@ -6035,8 +5900,6 @@ class basic_json
return "<end of input>"; return "<end of input>";
case token_type::parse_error: case token_type::parse_error:
return "<parse error>"; return "<parse error>";
default:
return "";
} }
} }
@ -6987,11 +6850,6 @@ basic_json_parser_64:
} }
break; break;
} }
default:
{
break;
}
} }
} }
else else
@ -7288,13 +7146,6 @@ basic_json_parser_64:
break; break;
} }
case lexer::token_type::end_array:
case lexer::token_type::end_object:
case lexer::token_type::end_of_input:
case lexer::token_type::name_separator:
case lexer::token_type::parse_error:
case lexer::token_type::uninitialized:
case lexer::token_type::value_separator:
default: default:
{ {
// the last token was unexpected // the last token was unexpected

View File

@ -686,8 +686,6 @@ class basic_json
break; break;
} }
case value_t::null:
case value_t::discarded:
default: default:
{ {
break; break;
@ -1494,10 +1492,6 @@ class basic_json
break; break;
} }
case value_t::array:
case value_t::discarded:
case value_t::null:
case value_t::object:
default: default:
{ {
break; break;
@ -1542,8 +1536,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name()); throw std::domain_error("cannot use construct with iterators from " + first.m_object->type_name());
@ -1614,8 +1606,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
break; break;
@ -1719,11 +1709,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
default: default:
{ {
// all other types need no specific destructor // all other types need no specific destructor
@ -2169,12 +2154,6 @@ class basic_json
return static_cast<T>(m_value.number_float); return static_cast<T>(m_value.number_float);
} }
case value_t::array:
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::object:
case value_t::string:
default: default:
{ {
throw std::domain_error("type must be number, but is " + type_name()); throw std::domain_error("type must be number, but is " + type_name());
@ -2874,8 +2853,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
throw std::domain_error("cannot use erase() with " + type_name()); throw std::domain_error("cannot use erase() with " + type_name());
@ -2971,8 +2948,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
throw std::domain_error("cannot use erase with " + type_name()); throw std::domain_error("cannot use erase with " + type_name());
@ -3380,11 +3355,6 @@ class basic_json
return m_value.object->empty(); return m_value.object->empty();
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
// all other types are nonempty // all other types are nonempty
@ -3439,11 +3409,6 @@ class basic_json
return m_value.object->size(); return m_value.object->size();
} }
case value_t::boolean:
case value_t::discarded:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
// all other types have size 1 // all other types have size 1
@ -3496,12 +3461,6 @@ class basic_json
return m_value.object->max_size(); return m_value.object->max_size();
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
// all other types have max_size() == size() // all other types have max_size() == size()
@ -3583,8 +3542,6 @@ class basic_json
break; break;
} }
case value_t::discarded:
case value_t::null:
default: default:
{ {
break; break;
@ -4099,8 +4056,6 @@ class basic_json
return lhs.m_value.number_integer == rhs.m_value.number_integer; return lhs.m_value.number_integer == rhs.m_value.number_integer;
case value_t::number_float: case value_t::number_float:
return approx(lhs.m_value.number_float, rhs.m_value.number_float); return approx(lhs.m_value.number_float, rhs.m_value.number_float);
case value_t::discarded:
return false;
default: default:
return false; return false;
} }
@ -4242,8 +4197,6 @@ class basic_json
return lhs.m_value.number_integer < rhs.m_value.number_integer; return lhs.m_value.number_integer < rhs.m_value.number_integer;
case value_t::number_float: case value_t::number_float:
return lhs.m_value.number_float < rhs.m_value.number_float; return lhs.m_value.number_float < rhs.m_value.number_float;
case value_t::discarded:
return false;
default: default:
return false; return false;
} }
@ -4527,8 +4480,6 @@ class basic_json
return "discarded"; return "discarded";
} }
case value_t::number_float:
case value_t::number_integer:
default: default:
{ {
return "number"; return "number";
@ -4839,11 +4790,6 @@ class basic_json
o << "null"; o << "null";
return; return;
} }
default:
{
return;
}
} }
} }
@ -4991,12 +4937,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator = primitive_iterator_t(); m_it.primitive_iterator = primitive_iterator_t();
@ -5022,12 +4962,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
m_it.primitive_iterator = other.m_it.primitive_iterator; m_it.primitive_iterator = other.m_it.primitive_iterator;
@ -5079,11 +5013,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator.set_begin(); m_it.primitive_iterator.set_begin();
@ -5109,12 +5038,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator.set_end(); m_it.primitive_iterator.set_end();
@ -5144,11 +5067,6 @@ class basic_json
throw std::out_of_range("cannot get value"); throw std::out_of_range("cannot get value");
} }
case value_t::boolean:
case value_t::discarded:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
if (m_it.primitive_iterator.is_begin()) if (m_it.primitive_iterator.is_begin())
@ -5178,12 +5096,6 @@ class basic_json
return &*m_it.array_iterator; return &*m_it.array_iterator;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
if (m_it.primitive_iterator.is_begin()) if (m_it.primitive_iterator.is_begin())
@ -5224,12 +5136,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
++m_it.primitive_iterator; ++m_it.primitive_iterator;
@ -5266,12 +5172,6 @@ class basic_json
break; break;
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
--m_it.primitive_iterator; --m_it.primitive_iterator;
@ -5303,12 +5203,6 @@ class basic_json
return (m_it.array_iterator == other.m_it.array_iterator); return (m_it.array_iterator == other.m_it.array_iterator);
} }
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
return (m_it.primitive_iterator == other.m_it.primitive_iterator); return (m_it.primitive_iterator == other.m_it.primitive_iterator);
@ -5343,12 +5237,6 @@ class basic_json
return (m_it.array_iterator < other.m_it.array_iterator); return (m_it.array_iterator < other.m_it.array_iterator);
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
return (m_it.primitive_iterator < other.m_it.primitive_iterator); return (m_it.primitive_iterator < other.m_it.primitive_iterator);
@ -5390,12 +5278,6 @@ class basic_json
break; break;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
m_it.primitive_iterator += i; m_it.primitive_iterator += i;
@ -5443,12 +5325,6 @@ class basic_json
return m_it.array_iterator - other.m_it.array_iterator; return m_it.array_iterator - other.m_it.array_iterator;
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::null:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
return m_it.primitive_iterator - other.m_it.primitive_iterator; return m_it.primitive_iterator - other.m_it.primitive_iterator;
@ -5476,11 +5352,6 @@ class basic_json
throw std::out_of_range("cannot get value"); throw std::out_of_range("cannot get value");
} }
case basic_json::value_t::boolean:
case basic_json::value_t::discarded:
case basic_json::value_t::number_float:
case basic_json::value_t::number_integer:
case basic_json::value_t::string:
default: default:
{ {
if (m_it.primitive_iterator == -n) if (m_it.primitive_iterator == -n)
@ -5827,12 +5698,6 @@ class basic_json
} }
/// use an empty key for all primitive types /// use an empty key for all primitive types
case value_t::boolean:
case value_t::discarded:
case value_t::null:
case value_t::number_float:
case value_t::number_integer:
case value_t::string:
default: default:
{ {
return ""; return "";
@ -6035,8 +5900,6 @@ class basic_json
return "<end of input>"; return "<end of input>";
case token_type::parse_error: case token_type::parse_error:
return "<parse error>"; return "<parse error>";
default:
return "";
} }
} }
@ -6266,11 +6129,6 @@ class basic_json
} }
break; break;
} }
default:
{
break;
}
} }
} }
else else
@ -6567,13 +6425,6 @@ class basic_json
break; break;
} }
case lexer::token_type::end_array:
case lexer::token_type::end_object:
case lexer::token_type::end_of_input:
case lexer::token_type::name_separator:
case lexer::token_type::parse_error:
case lexer::token_type::uninitialized:
case lexer::token_type::value_separator:
default: default:
{ {
// the last token was unexpected // the last token was unexpected