Commit 2c1b3e51 by Niels

+ small cleanup

parent 3985226f
...@@ -155,9 +155,9 @@ JSON::JSON(list_init_t a) noexcept ...@@ -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 ...@@ -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) ...@@ -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 ...@@ -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 ...@@ -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. ...@@ -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;
} }
} }
} }
......
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