27template<
typename IteratorType>
class iteration_proxy;
28template<
typename IteratorType>
class iteration_proxy_value;
46template<
typename BasicJsonType>
57 using object_t =
typename BasicJsonType::object_t;
58 using array_t =
typename BasicJsonType::array_t;
61 "iter_impl only accepts (const) basic_json");
63 static_assert(std::is_base_of<std::bidirectional_iterator_tag, std::bidirectional_iterator_tag>::value
64 && std::is_base_of<std::bidirectional_iterator_tag, typename std::iterator_traits<typename array_t::iterator>::iterator_category>
::value,
65 "basic_json iterator assumes array and object type iterators satisfy the LegacyBidirectionalIterator named requirement.");
80 using pointer =
typename std::conditional<std::is_const<BasicJsonType>::value,
81 typename BasicJsonType::const_pointer,
82 typename BasicJsonType::pointer>
::type;
85 typename std::conditional<std::is_const<BasicJsonType>::value,
86 typename BasicJsonType::const_reference,
87 typename BasicJsonType::reference>
::type;
104 switch (m_object->m_data.m_type)
108 m_it.object_iterator =
typename object_t::iterator();
114 m_it.array_iterator =
typename array_t::iterator();
151 : m_object(other.m_object),
m_it(other.m_it)
164 m_object = other.m_object;
176 : m_object(other.m_object),
m_it(other.m_it)
187 m_object = other.m_object;
197 void set_begin() noexcept
201 switch (m_object->m_data.m_type)
205 m_it.object_iterator = m_object->m_data.m_value.object->begin();
211 m_it.array_iterator = m_object->m_data.m_value.array->begin();
218 m_it.primitive_iterator.set_end();
231 m_it.primitive_iterator.set_begin();
245 switch (m_object->m_data.m_type)
249 m_it.object_iterator = m_object->m_data.m_value.object->end();
255 m_it.array_iterator = m_object->m_data.m_value.array->end();
269 m_it.primitive_iterator.set_end();
284 switch (m_object->m_data.m_type)
288 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
289 return m_it.object_iterator->second;
294 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
295 return *
m_it.array_iterator;
328 switch (m_object->m_data.m_type)
332 JSON_ASSERT(
m_it.object_iterator != m_object->m_data.m_value.object->end());
333 return &(
m_it.object_iterator->second);
338 JSON_ASSERT(
m_it.array_iterator != m_object->m_data.m_value.array->end());
339 return &*
m_it.array_iterator;
381 switch (m_object->m_data.m_type)
385 std::advance(
m_it.object_iterator, 1);
391 std::advance(
m_it.array_iterator, 1);
405 ++
m_it.primitive_iterator;
432 switch (m_object->m_data.m_type)
436 std::advance(
m_it.object_iterator, -1);
442 std::advance(
m_it.array_iterator, -1);
456 --
m_it.primitive_iterator;
468 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
479 switch (m_object->m_data.m_type)
482 return (
m_it.object_iterator == other.m_it.object_iterator);
485 return (
m_it.array_iterator == other.m_it.array_iterator);
496 return (
m_it.primitive_iterator == other.m_it.primitive_iterator);
504 template <
typename IterImpl, detail::enable_if_t < (std::is_same<IterImpl, iter_impl>::value || std::is_same<IterImpl, other_iter_impl>::value), std::
nullptr_t > =
nullptr >
524 switch (m_object->m_data.m_type)
530 return (
m_it.array_iterator < other.m_it.array_iterator);
541 return (
m_it.primitive_iterator < other.m_it.primitive_iterator);
551 return !other.operator < (*this);
580 switch (m_object->m_data.m_type)
587 std::advance(
m_it.array_iterator, i);
601 m_it.primitive_iterator += i;
659 switch (m_object->m_data.m_type)
665 return m_it.array_iterator - other.m_it.array_iterator;
676 return m_it.primitive_iterator - other.m_it.primitive_iterator;
688 switch (m_object->m_data.m_type)
694 return *std::next(
m_it.array_iterator, n);
722 const typename object_t::key_type&
key()
const
728 return m_it.object_iterator->first;
#define WPI_JSON_NAMESPACE_END
Definition abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition abi_macros.h:53
static invalid_iterator create(int id_, const std::string &what_arg, BasicJsonContext context)
Definition exceptions.h:193
a template for a bidirectional iterator for the basic_json class This class implements a both iterato...
Definition iter_impl.h:48
iter_impl operator+(difference_type i) const
add to iterator
Definition iter_impl.h:622
iter_impl & operator=(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting assignment
Definition iter_impl.h:185
bool operator>=(const iter_impl &other) const
comparison: greater than or equal
Definition iter_impl.h:567
iter_impl(const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
converting constructor
Definition iter_impl.h:175
bool operator<(const iter_impl &other) const
comparison: smaller
Definition iter_impl.h:514
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition iter_impl.h:549
iter_impl & operator-=(difference_type i)
subtract from iterator
Definition iter_impl.h:613
iter_impl & operator--()
pre-decrement (–it)
Definition iter_impl.h:428
const object_t::key_type & key() const
return the key of an object iterator
Definition iter_impl.h:722
bool operator==(const IterImpl &other) const
comparison: equal
Definition iter_impl.h:469
iter_impl operator++(int) &
post-increment (it++)
Definition iter_impl.h:366
iter_impl & operator+=(difference_type i)
add to iterator
Definition iter_impl.h:576
reference operator[](difference_type n) const
access to successor
Definition iter_impl.h:684
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type pointer
defines a pointer to the type iterated over (value_type)
Definition iter_impl.h:80
typename BasicJsonType::difference_type difference_type
a type to represent differences between iterators
Definition iter_impl.h:78
pointer operator->() const
dereference the iterator
Definition iter_impl.h:324
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition iter_impl.h:747
difference_type operator-(const iter_impl &other) const
return difference
Definition iter_impl.h:655
iter_impl(iter_impl &&) noexcept=default
std::bidirectional_iterator_tag iterator_category
The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17.
Definition iter_impl.h:73
friend iter_impl operator+(difference_type i, const iter_impl &it)
addition of distance and iterator
Definition iter_impl.h:633
reference value() const
return the value of an iterator
Definition iter_impl.h:738
bool operator>(const iter_impl &other) const
comparison: greater than
Definition iter_impl.h:558
iter_impl & operator++()
pre-increment (++it)
Definition iter_impl.h:377
typename BasicJsonType::value_type value_type
the type of the values when the iterator is dereferenced
Definition iter_impl.h:76
reference operator*() const
return a reference to the value pointed to by the iterator
Definition iter_impl.h:280
iter_impl operator-(difference_type i) const
subtract from iterator
Definition iter_impl.h:644
typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type reference
defines a reference to the type iterated over (value_type)
Definition iter_impl.h:84
iter_impl & operator=(const iter_impl< const BasicJsonType > &other) noexcept
converting assignment
Definition iter_impl.h:160
bool operator!=(const IterImpl &other) const
comparison: not equal
Definition iter_impl.h:505
iter_impl operator--(int) &
post-decrement (it–)
Definition iter_impl.h:417
iter_impl(const iter_impl< const BasicJsonType > &other) noexcept
const copy constructor
Definition iter_impl.h:150
void set_end() noexcept
set the iterator past the last value
Definition iter_impl.h:241
Definition iteration_proxy.h:37
proxy class for the items() function
Definition iteration_proxy.h:158
Definition primitive_iterator.h:30
#define JSON_HEDLEY_LIKELY(expr)
Definition hedley.h:1395
#define JSON_HEDLEY_UNLIKELY(expr)
Definition hedley.h:1396
#define JSON_PRIVATE_UNLESS_TESTED
Definition macro_scope.h:207
#define JSON_ASSERT(x)
Definition macro_scope.h:200
#define JSON_THROW(exception)
Definition macro_scope.h:171
detail namespace with internal helper functions
Definition input_adapters.h:32
@ number_integer
number value (signed integer)
@ discarded
discarded by the parser callback function
@ binary
binary array (ordered collection of bytes)
@ object
object (unordered set of name/value pairs)
@ number_float
number value (floating-point)
@ number_unsigned
number value (unsigned integer)
@ array
array (ordered collection of values)
type
Definition base.h:937
an iterator value
Definition internal_iterator.h:25
Definition type_traits.h:50