+ small cleanup

This commit is contained in:
Niels 2014-12-29 00:02:13 +01:00
parent 3985226f76
commit 2c1b3e5108

View file

@ -155,9 +155,9 @@ JSON::JSON(list_init_t a) noexcept
// is a string // is a string
for (const auto& element : a) for (const auto& element : a)
{ {
if (element.type() != value_type::array or if (element._type != value_type::array or
element.size() != 2 or element.size() != 2 or
element[0].type() != value_type::string) element[0]._type != value_type::string)
{ {
// the initializer list describes an array // the initializer list describes an array
@ -173,7 +173,8 @@ JSON::JSON(list_init_t a) noexcept
for (const JSON& element : a) for (const JSON& element : a)
{ {
const std::string k = element[0]; const std::string k = element[0];
_value.object->emplace(std::make_pair(std::move(k), std::move(element[1]))); _value.object->emplace(std::make_pair(std::move(k),
std::move(element[1])));
} }
} }
@ -746,9 +747,9 @@ void JSON::push_back(list_init_t a)
// is a string // is a string
for (const auto& element : a) for (const auto& element : a)
{ {
if (element.type() != value_type::array or if (element._type != value_type::array or
element.size() != 2 or element.size() != 2 or
element[0].type() != value_type::string) element[0]._type != value_type::string)
{ {
// the initializer list describes an array // the initializer list describes an array
is_array = true; is_array = true;
@ -1345,21 +1346,14 @@ JSON::const_iterator JSON::cend() const noexcept
JSON::iterator::iterator(JSON* j) : _object(j) JSON::iterator::iterator(JSON* j) : _object(j)
{ {
if (_object != nullptr) if (_object != nullptr)
switch (_object->_type)
{ {
case (value_type::array): if (_object->_type == value_type::array)
{ {
_vi = new array_t::iterator(_object->_value.array->begin()); _vi = new array_t::iterator(_object->_value.array->begin());
break;
} }
case (value_type::object): if (_object->_type == value_type::object)
{ {
_oi = new object_t::iterator(_object->_value.object->begin()); _oi = new object_t::iterator(_object->_value.object->begin());
break;
}
default:
{
break;
} }
} }
} }
@ -1545,21 +1539,14 @@ JSON& JSON::iterator::value() const
JSON::const_iterator::const_iterator(const JSON* j) : _object(j) JSON::const_iterator::const_iterator(const JSON* j) : _object(j)
{ {
if (_object != nullptr) if (_object != nullptr)
switch (_object->_type)
{ {
case (value_type::array): if (_object->_type == value_type::array)
{ {
_vi = new array_t::const_iterator(_object->_value.array->begin()); _vi = new array_t::const_iterator(_object->_value.array->begin());
break;
} }
case (value_type::object): if (_object->_type == value_type::object)
{ {
_oi = new object_t::const_iterator(_object->_value.object->begin()); _oi = new object_t::const_iterator(_object->_value.object->begin());
break;
}
default:
{
break;
} }
} }
} }
@ -1582,21 +1569,14 @@ JSON::const_iterator::const_iterator(const JSON::const_iterator& o) : _object(o.
JSON::const_iterator::const_iterator(const JSON::iterator& o) : _object(o._object) JSON::const_iterator::const_iterator(const JSON::iterator& o) : _object(o._object)
{ {
if (_object != nullptr) if (_object != nullptr)
switch (_object->_type)
{ {
case (value_type::array): if (_object->_type == value_type::array)
{ {
_vi = new array_t::const_iterator(*(o._vi)); _vi = new array_t::const_iterator(*(o._vi));
break;
} }
case (value_type::object): if (_object->_type == value_type::object)
{ {
_oi = new object_t::const_iterator(*(o._oi)); _oi = new object_t::const_iterator(*(o._oi));
break;
}
default:
{
break;
} }
} }
} }