mirror of
https://github.com/nlohmann/json.git
synced 2025-07-09 11:01:47 +03:00
some bug fixing
This commit is contained in:
@ -1604,11 +1604,65 @@ class basic_json
|
||||
json_value m_value = {};
|
||||
|
||||
|
||||
public:
|
||||
private:
|
||||
///////////////
|
||||
// iterators //
|
||||
///////////////
|
||||
|
||||
/// values of a generic iterator type of non-container JSON values
|
||||
enum class generic_iterator_value
|
||||
{
|
||||
/// the iterator was not initialized
|
||||
uninitialized,
|
||||
/// the iterator points to the only value
|
||||
begin,
|
||||
/// the iterator points past the only value
|
||||
end,
|
||||
/// the iterator points to an invalid value
|
||||
invalid
|
||||
};
|
||||
|
||||
/// an iterator value
|
||||
union internal_iterator
|
||||
{
|
||||
/// iterator for JSON objects
|
||||
typename object_t::iterator object_iterator;
|
||||
/// iterator for JSON arrays
|
||||
typename array_t::iterator array_iterator;
|
||||
/// generic iteraotr for all other value types
|
||||
generic_iterator_value generic_iterator;
|
||||
|
||||
/// default constructor
|
||||
internal_iterator() : generic_iterator(generic_iterator_value::uninitialized) {}
|
||||
/// constructor for object iterators
|
||||
internal_iterator(typename object_t::iterator v) : object_iterator(v) {}
|
||||
/// constructor for array iterators
|
||||
internal_iterator(typename array_t::iterator v) : array_iterator(v) {}
|
||||
/// constructor for generic iterators
|
||||
internal_iterator(generic_iterator_value v) : generic_iterator(v) {}
|
||||
};
|
||||
|
||||
/// a const iterator value
|
||||
union internal_const_iterator
|
||||
{
|
||||
/// iterator for JSON objects
|
||||
typename object_t::const_iterator object_iterator;
|
||||
/// iterator for JSON arrays
|
||||
typename array_t::const_iterator array_iterator;
|
||||
/// generic iteraotr for all other value types
|
||||
generic_iterator_value generic_iterator;
|
||||
|
||||
/// default constructor
|
||||
internal_const_iterator() : generic_iterator(generic_iterator_value::uninitialized) {}
|
||||
/// constructor for object iterators
|
||||
internal_const_iterator(typename object_t::iterator v) : object_iterator(v) {}
|
||||
/// constructor for array iterators
|
||||
internal_const_iterator(typename array_t::iterator v) : array_iterator(v) {}
|
||||
/// constructor for generic iterators
|
||||
internal_const_iterator(generic_iterator_value v) : generic_iterator(v) {}
|
||||
};
|
||||
|
||||
public:
|
||||
/// a bidirectional iterator for the basic_json class
|
||||
class iterator : public std::iterator<std::bidirectional_iterator_tag, basic_json>
|
||||
{
|
||||
@ -1624,39 +1678,6 @@ class basic_json
|
||||
/// the category of the iterator
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
|
||||
/// values of a generic iterator type of non-container JSON values
|
||||
enum class generic_iterator_value
|
||||
{
|
||||
/// the iterator was not initialized
|
||||
uninitialized,
|
||||
/// the iterator points to the only value
|
||||
begin,
|
||||
/// the iterator points past the only value
|
||||
end,
|
||||
/// the iterator points to an invalid value
|
||||
invalid
|
||||
};
|
||||
|
||||
/// an iterator value
|
||||
union internal_iterator
|
||||
{
|
||||
/// iterator for JSON objects
|
||||
typename object_t::iterator object_iterator;
|
||||
/// iterator for JSON arrays
|
||||
typename array_t::iterator array_iterator;
|
||||
/// generic iteraotr for all other value types
|
||||
generic_iterator_value generic_iterator;
|
||||
|
||||
/// default constructor
|
||||
internal_iterator() : generic_iterator(generic_iterator_value::uninitialized) {}
|
||||
/// constructor for object iterators
|
||||
internal_iterator(typename object_t::iterator v) : object_iterator(v) {}
|
||||
/// constructor for array iterators
|
||||
internal_iterator(typename array_t::iterator v) : array_iterator(v) {}
|
||||
/// constructor for generic iterators
|
||||
internal_iterator(generic_iterator_value v) : generic_iterator(v) {}
|
||||
};
|
||||
|
||||
/// constructor for a given JSON instance
|
||||
inline iterator(pointer object) : m_object(object)
|
||||
{
|
||||
@ -2015,39 +2036,6 @@ class basic_json
|
||||
/// the category of the iterator
|
||||
using iterator_category = std::bidirectional_iterator_tag;
|
||||
|
||||
/// values of a generic iterator type of non-container JSON values
|
||||
enum class generic_iterator_value
|
||||
{
|
||||
/// the iterator was not initialized
|
||||
uninitialized,
|
||||
/// the iterator points to the only value
|
||||
begin,
|
||||
/// the iterator points past the only value
|
||||
end,
|
||||
/// the iterator points to an invalid value
|
||||
invalid
|
||||
};
|
||||
|
||||
/// an iterator value
|
||||
union internal_const_iterator
|
||||
{
|
||||
/// iterator for JSON objects
|
||||
typename object_t::const_iterator object_iterator;
|
||||
/// iterator for JSON arrays
|
||||
typename array_t::const_iterator array_iterator;
|
||||
/// generic iteraotr for all other value types
|
||||
generic_iterator_value generic_iterator;
|
||||
|
||||
/// default constructor
|
||||
internal_const_iterator() : generic_iterator(generic_iterator_value::uninitialized) {}
|
||||
/// constructor for object iterators
|
||||
internal_const_iterator(typename object_t::iterator v) : object_iterator(v) {}
|
||||
/// constructor for array iterators
|
||||
internal_const_iterator(typename array_t::iterator v) : array_iterator(v) {}
|
||||
/// constructor for generic iterators
|
||||
internal_const_iterator(generic_iterator_value v) : generic_iterator(v) {}
|
||||
};
|
||||
|
||||
/// constructor for a given JSON instance
|
||||
inline const_iterator(pointer object) : m_object(object)
|
||||
{
|
||||
@ -2072,8 +2060,29 @@ class basic_json
|
||||
}
|
||||
|
||||
/// copy constructor given a nonconst iterator
|
||||
inline const_iterator(const iterator& other) : m_object(other.m_object), m_it(other.m_it)
|
||||
{}
|
||||
inline const_iterator(const iterator& other) : m_object(other.m_object)
|
||||
{
|
||||
switch (m_object->m_type)
|
||||
{
|
||||
case (basic_json::value_t::object):
|
||||
{
|
||||
m_it.object_iterator = other.m_it.object_iterator;
|
||||
break;
|
||||
}
|
||||
|
||||
case (basic_json::value_t::array):
|
||||
{
|
||||
m_it.array_iterator = other.m_it.array_iterator;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
{
|
||||
m_it.generic_iterator = other.m_it.generic_iterator;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// copy assignment
|
||||
inline const_iterator operator=(const const_iterator& other) noexcept
|
||||
|
Reference in New Issue
Block a user