Fast Methods for Cosmological Simulations
FastSim serves as a tool for quick N-body simulations in modified gravity.
nlohmann::detail::iter_impl< BasicJsonType > Class Template Reference

a template for a bidirectional iterator for the basic_json class More...

#include <json.hpp>

Collaboration diagram for nlohmann::detail::iter_impl< BasicJsonType >:

Public Types

using iterator_category = std::bidirectional_iterator_tag
 
using value_type = typename BasicJsonType::value_type
 the type of the values when the iterator is dereferenced More...
 
using difference_type = typename BasicJsonType::difference_type
 a type to represent differences between iterators More...
 
using pointer = typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer >::type
 defines a pointer to the type iterated over (value_type) More...
 
using reference = typename std::conditional< std::is_const< BasicJsonType >::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference >::type
 defines a reference to the type iterated over (value_type) More...
 

Public Member Functions

 iter_impl ()=default
 default constructor More...
 
 iter_impl (pointer object) noexcept
 constructor for a given JSON instance More...
 
 iter_impl (const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
 converting constructor More...
 
iter_imploperator= (const iter_impl< typename std::remove_const< BasicJsonType >::type > &other) noexcept
 converting assignment More...
 
reference operator* () const
 return a reference to the value pointed to by the iterator More...
 
pointer operator-> () const
 dereference the iterator More...
 
iter_impl const operator++ (int)
 post-increment (it++) More...
 
iter_imploperator++ ()
 pre-increment (++it) More...
 
iter_impl const operator-- (int)
 post-decrement (it–) More...
 
iter_imploperator-- ()
 pre-decrement (–it) More...
 
bool operator== (const iter_impl &other) const
 comparison: equal More...
 
bool operator!= (const iter_impl &other) const
 comparison: not equal More...
 
bool operator< (const iter_impl &other) const
 comparison: smaller More...
 
bool operator<= (const iter_impl &other) const
 comparison: less than or equal More...
 
bool operator> (const iter_impl &other) const
 comparison: greater than More...
 
bool operator>= (const iter_impl &other) const
 comparison: greater than or equal More...
 
iter_imploperator+= (difference_type i)
 add to iterator More...
 
iter_imploperator-= (difference_type i)
 subtract from iterator More...
 
iter_impl operator+ (difference_type i) const
 add to iterator More...
 
iter_impl operator- (difference_type i) const
 subtract from iterator More...
 
difference_type operator- (const iter_impl &other) const
 return difference More...
 
reference operator[] (difference_type n) const
 access to successor More...
 
const object_t::key_type & key () const
 return the key of an object iterator More...
 
reference value () const
 return the value of an iterator More...
 

Private Types

using object_t = typename BasicJsonType::object_t
 
using array_t = typename BasicJsonType::array_t
 

Private Member Functions

void set_begin () noexcept
 set the iterator to the first value More...
 
void set_end () noexcept
 set the iterator past the last value More...
 

Private Attributes

friend BasicJsonType
 
friend iteration_proxy< iter_impl >
 
pointer m_object = nullptr
 associated JSON instance More...
 
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
 the actual iterator of the associated instance More...
 

Friends

iter_impl operator+ (difference_type i, const iter_impl &it)
 addition of distance and iterator More...
 

Detailed Description

template<typename BasicJsonType>
class nlohmann::detail::iter_impl< BasicJsonType >

a template for a bidirectional iterator for the basic_json class

This class implements a both iterators (iterator and const_iterator) for the basic_json class.

Note
An iterator is called initialized when a pointer to a JSON value has been set (e.g., by a constructor or a copy assignment). If the iterator is default-constructed, it is uninitialized and most methods are undefined. The library uses assertions to detect calls on uninitialized iterators.**

The class satisfies the following concept requirements:

  • BidirectionalIterator: The iterator that can be moved can be moved in both directions (i.e. incremented and decremented).
Since
version 1.0.0, simplified in version 2.0.9, change to bidirectional iterators in version 3.0.0 (see https://github.com/nlohmann/json/issues/593)

Definition at line 5511 of file json.hpp.

Member Typedef Documentation

template<typename BasicJsonType>
using nlohmann::detail::iter_impl< BasicJsonType >::array_t = typename BasicJsonType::array_t
private

Definition at line 5519 of file json.hpp.

template<typename BasicJsonType>
using nlohmann::detail::iter_impl< BasicJsonType >::difference_type = typename BasicJsonType::difference_type

a type to represent differences between iterators

Definition at line 5536 of file json.hpp.

template<typename BasicJsonType>
using nlohmann::detail::iter_impl< BasicJsonType >::iterator_category = std::bidirectional_iterator_tag

The std::iterator class template (used as a base class to provide typedefs) is deprecated in C++17. The C++ Standard has never required user-defined iterators to derive from std::iterator. A user-defined iterator should provide publicly accessible typedefs named iterator_category, value_type, difference_type, pointer, and reference. Note that value_type is required to be non-const, even for constant iterators.

Definition at line 5531 of file json.hpp.

template<typename BasicJsonType>
using nlohmann::detail::iter_impl< BasicJsonType >::object_t = typename BasicJsonType::object_t
private

Definition at line 5518 of file json.hpp.

template<typename BasicJsonType>
using nlohmann::detail::iter_impl< BasicJsonType >::pointer = typename std::conditional<std::is_const<BasicJsonType>::value, typename BasicJsonType::const_pointer, typename BasicJsonType::pointer>::type

defines a pointer to the type iterated over (value_type)

Definition at line 5540 of file json.hpp.

template<typename BasicJsonType>
using nlohmann::detail::iter_impl< BasicJsonType >::reference = typename std::conditional<std::is_const<BasicJsonType>::value, typename BasicJsonType::const_reference, typename BasicJsonType::reference>::type

defines a reference to the type iterated over (value_type)

Definition at line 5545 of file json.hpp.

template<typename BasicJsonType>
using nlohmann::detail::iter_impl< BasicJsonType >::value_type = typename BasicJsonType::value_type

the type of the values when the iterator is dereferenced

Definition at line 5534 of file json.hpp.

Constructor & Destructor Documentation

template<typename BasicJsonType>
iter_impl< typename std::conditional< std::is_const< BasicJsonType >::value, typename std::remove_const< BasicJsonType >::type, const BasicJsonType >::type > ( )
default

default constructor

allow basic_json to access private members

Definition at line 5514 of file json.hpp.

template<typename BasicJsonType>
nlohmann::detail::iter_impl< BasicJsonType >::iter_impl ( pointer  object)
inlineexplicitnoexcept

constructor for a given JSON instance

Parameters
[in]objectpointer to a JSON object for this iterator
Precondition
object != nullptr
Postcondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5556 of file json.hpp.

References nlohmann::detail::array, and nlohmann::detail::object.

5556  : m_object(object)
5557  {
5558  assert(m_object != nullptr);
5559 
5560  switch (m_object->m_type)
5561  {
5562  case value_t::object:
5563  {
5564  m_it.object_iterator = typename object_t::iterator();
5565  break;
5566  }
5567 
5568  case value_t::array:
5569  {
5570  m_it.array_iterator = typename array_t::iterator();
5571  break;
5572  }
5573 
5574  default:
5575  {
5576  m_it.primitive_iterator = primitive_iterator_t();
5577  break;
5578  }
5579  }
5580  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
template<typename BasicJsonType>
nlohmann::detail::iter_impl< BasicJsonType >::iter_impl ( const iter_impl< typename std::remove_const< BasicJsonType >::type > &  other)
inlinenoexcept

converting constructor

Note
The conventional copy constructor and copy assignment are implicitly defined. Combined with the following converting constructor and assignment, they support: (1) copy from iterator to iterator, (2) copy from const iterator to const iterator, and (3) conversion from iterator to const iterator. However conversion from const iterator to iterator is not defined.
Parameters
[in]othernon-const iterator to copy from
Note
It is not checked whether other is initialized.

Definition at line 5596 of file json.hpp.

5597  : m_object(other.m_object), m_it(other.m_it) {}
pointer m_object
associated JSON instance
Definition: json.hpp:6078
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080

Member Function Documentation

template<typename BasicJsonType>
const object_t::key_type& nlohmann::detail::iter_impl< BasicJsonType >::key ( ) const
inline

return the key of an object iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 6055 of file json.hpp.

References nlohmann::detail::invalid_iterator::create(), JSON_LIKELY, and JSON_THROW.

6056  {
6057  assert(m_object != nullptr);
6058 
6059  if (JSON_LIKELY(m_object->is_object()))
6060  {
6061  return m_it.object_iterator->first;
6062  }
6063 
6064  JSON_THROW(invalid_iterator::create(207, "cannot use key() for non-object iterators"));
6065  }
pointer m_object
associated JSON instance
Definition: json.hpp:6078
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
#define JSON_THROW(exception)
Definition: json.hpp:162
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
#define JSON_LIKELY(x)
Definition: json.hpp:193
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
bool nlohmann::detail::iter_impl< BasicJsonType >::operator!= ( const iter_impl< BasicJsonType > &  other) const
inline

comparison: not equal

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5869 of file json.hpp.

5870  {
5871  return not operator==(other);
5872  }
bool operator==(const iter_impl &other) const
comparison: equal
Definition: json.hpp:5842
template<typename BasicJsonType>
reference nlohmann::detail::iter_impl< BasicJsonType >::operator* ( ) const
inline

return a reference to the value pointed to by the iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5685 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::invalid_iterator::create(), JSON_LIKELY, JSON_THROW, nlohmann::detail::null, and nlohmann::detail::object.

5686  {
5687  assert(m_object != nullptr);
5688 
5689  switch (m_object->m_type)
5690  {
5691  case value_t::object:
5692  {
5693  assert(m_it.object_iterator != m_object->m_value.object->end());
5694  return m_it.object_iterator->second;
5695  }
5696 
5697  case value_t::array:
5698  {
5699  assert(m_it.array_iterator != m_object->m_value.array->end());
5700  return *m_it.array_iterator;
5701  }
5702 
5703  case value_t::null:
5704  JSON_THROW(invalid_iterator::create(214, "cannot get value"));
5705 
5706  default:
5707  {
5709  {
5710  return *m_object;
5711  }
5712 
5713  JSON_THROW(invalid_iterator::create(214, "cannot get value"));
5714  }
5715  }
5716  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
#define JSON_THROW(exception)
Definition: json.hpp:162
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:5361
#define JSON_LIKELY(x)
Definition: json.hpp:193
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
iter_impl nlohmann::detail::iter_impl< BasicJsonType >::operator+ ( difference_type  i) const
inline

add to iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5970 of file json.hpp.

5971  {
5972  auto result = *this;
5973  result += i;
5974  return result;
5975  }
template<typename BasicJsonType>
iter_impl const nlohmann::detail::iter_impl< BasicJsonType >::operator++ ( int  )
inline

post-increment (it++)

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5756 of file json.hpp.

5757  {
5758  auto result = *this;
5759  ++(*this);
5760  return result;
5761  }
template<typename BasicJsonType>
iter_impl& nlohmann::detail::iter_impl< BasicJsonType >::operator++ ( )
inline

pre-increment (++it)

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5767 of file json.hpp.

References nlohmann::detail::array, and nlohmann::detail::object.

5768  {
5769  assert(m_object != nullptr);
5770 
5771  switch (m_object->m_type)
5772  {
5773  case value_t::object:
5774  {
5775  std::advance(m_it.object_iterator, 1);
5776  break;
5777  }
5778 
5779  case value_t::array:
5780  {
5781  std::advance(m_it.array_iterator, 1);
5782  break;
5783  }
5784 
5785  default:
5786  {
5788  break;
5789  }
5790  }
5791 
5792  return *this;
5793  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
template<typename BasicJsonType>
iter_impl& nlohmann::detail::iter_impl< BasicJsonType >::operator+= ( difference_type  i)
inline

add to iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5932 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::invalid_iterator::create(), JSON_THROW, and nlohmann::detail::object.

5933  {
5934  assert(m_object != nullptr);
5935 
5936  switch (m_object->m_type)
5937  {
5938  case value_t::object:
5939  JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
5940 
5941  case value_t::array:
5942  {
5943  std::advance(m_it.array_iterator, i);
5944  break;
5945  }
5946 
5947  default:
5948  {
5949  m_it.primitive_iterator += i;
5950  break;
5951  }
5952  }
5953 
5954  return *this;
5955  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
#define JSON_THROW(exception)
Definition: json.hpp:162
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
iter_impl nlohmann::detail::iter_impl< BasicJsonType >::operator- ( difference_type  i) const
inline

subtract from iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5992 of file json.hpp.

5993  {
5994  auto result = *this;
5995  result -= i;
5996  return result;
5997  }
template<typename BasicJsonType>
difference_type nlohmann::detail::iter_impl< BasicJsonType >::operator- ( const iter_impl< BasicJsonType > &  other) const
inline

return difference

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 6003 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::internal_iterator< BasicJsonType >::array_iterator, nlohmann::detail::invalid_iterator::create(), JSON_THROW, nlohmann::detail::iter_impl< BasicJsonType >::m_it, nlohmann::detail::object, and nlohmann::detail::internal_iterator< BasicJsonType >::primitive_iterator.

6004  {
6005  assert(m_object != nullptr);
6006 
6007  switch (m_object->m_type)
6008  {
6009  case value_t::object:
6010  JSON_THROW(invalid_iterator::create(209, "cannot use offsets with object iterators"));
6011 
6012  case value_t::array:
6013  return m_it.array_iterator - other.m_it.array_iterator;
6014 
6015  default:
6016  return m_it.primitive_iterator - other.m_it.primitive_iterator;
6017  }
6018  }
difference_type m_it
iterator as signed integer type
Definition: json.hpp:5340
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
#define JSON_THROW(exception)
Definition: json.hpp:162
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
iter_impl const nlohmann::detail::iter_impl< BasicJsonType >::operator-- ( int  )
inline

post-decrement (it–)

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5799 of file json.hpp.

5800  {
5801  auto result = *this;
5802  --(*this);
5803  return result;
5804  }
template<typename BasicJsonType>
iter_impl& nlohmann::detail::iter_impl< BasicJsonType >::operator-- ( )
inline

pre-decrement (–it)

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5810 of file json.hpp.

References nlohmann::detail::array, and nlohmann::detail::object.

5811  {
5812  assert(m_object != nullptr);
5813 
5814  switch (m_object->m_type)
5815  {
5816  case value_t::object:
5817  {
5818  std::advance(m_it.object_iterator, -1);
5819  break;
5820  }
5821 
5822  case value_t::array:
5823  {
5824  std::advance(m_it.array_iterator, -1);
5825  break;
5826  }
5827 
5828  default:
5829  {
5831  break;
5832  }
5833  }
5834 
5835  return *this;
5836  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
template<typename BasicJsonType>
iter_impl& nlohmann::detail::iter_impl< BasicJsonType >::operator-= ( difference_type  i)
inline

subtract from iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5961 of file json.hpp.

References Catch::operator+=().

5962  {
5963  return operator+=(-i);
5964  }
iter_impl & operator+=(difference_type i)
add to iterator
Definition: json.hpp:5932
template<typename BasicJsonType>
pointer nlohmann::detail::iter_impl< BasicJsonType >::operator-> ( ) const
inline

dereference the iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5722 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::invalid_iterator::create(), JSON_LIKELY, JSON_THROW, and nlohmann::detail::object.

5723  {
5724  assert(m_object != nullptr);
5725 
5726  switch (m_object->m_type)
5727  {
5728  case value_t::object:
5729  {
5730  assert(m_it.object_iterator != m_object->m_value.object->end());
5731  return &(m_it.object_iterator->second);
5732  }
5733 
5734  case value_t::array:
5735  {
5736  assert(m_it.array_iterator != m_object->m_value.array->end());
5737  return &*m_it.array_iterator;
5738  }
5739 
5740  default:
5741  {
5743  {
5744  return m_object;
5745  }
5746 
5747  JSON_THROW(invalid_iterator::create(214, "cannot get value"));
5748  }
5749  }
5750  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
#define JSON_THROW(exception)
Definition: json.hpp:162
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
constexpr bool is_begin() const noexcept
return whether the iterator can be dereferenced
Definition: json.hpp:5361
#define JSON_LIKELY(x)
Definition: json.hpp:193
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
bool nlohmann::detail::iter_impl< BasicJsonType >::operator< ( const iter_impl< BasicJsonType > &  other) const
inline

comparison: smaller

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5878 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::internal_iterator< BasicJsonType >::array_iterator, nlohmann::detail::invalid_iterator::create(), JSON_THROW, JSON_UNLIKELY, nlohmann::detail::iter_impl< BasicJsonType >::m_it, nlohmann::detail::iter_impl< BasicJsonType >::m_object, nlohmann::detail::object, and nlohmann::detail::internal_iterator< BasicJsonType >::primitive_iterator.

5879  {
5880  // if objects are not the same, the comparison is undefined
5881  if (JSON_UNLIKELY(m_object != other.m_object))
5882  {
5883  JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
5884  }
5885 
5886  assert(m_object != nullptr);
5887 
5888  switch (m_object->m_type)
5889  {
5890  case value_t::object:
5891  JSON_THROW(invalid_iterator::create(213, "cannot compare order of object iterators"));
5892 
5893  case value_t::array:
5894  return (m_it.array_iterator < other.m_it.array_iterator);
5895 
5896  default:
5897  return (m_it.primitive_iterator < other.m_it.primitive_iterator);
5898  }
5899  }
difference_type m_it
iterator as signed integer type
Definition: json.hpp:5340
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
#define JSON_THROW(exception)
Definition: json.hpp:162
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
bool nlohmann::detail::iter_impl< BasicJsonType >::operator<= ( const iter_impl< BasicJsonType > &  other) const
inline

comparison: less than or equal

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5905 of file json.hpp.

5906  {
5907  return not other.operator < (*this);
5908  }
template<typename BasicJsonType>
iter_impl& nlohmann::detail::iter_impl< BasicJsonType >::operator= ( const iter_impl< typename std::remove_const< BasicJsonType >::type > &  other)
inlinenoexcept

converting assignment

Parameters
[in,out]othernon-const iterator to copy from
Returns
const/non-const iterator
Note
It is not checked whether other is initialized.

Definition at line 5605 of file json.hpp.

References nlohmann::detail::iter_impl< BasicJsonType >::m_object.

5606  {
5607  m_object = other.m_object;
5608  m_it = other.m_it;
5609  return *this;
5610  }
pointer m_object
associated JSON instance
Definition: json.hpp:6078
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
template<typename BasicJsonType>
bool nlohmann::detail::iter_impl< BasicJsonType >::operator== ( const iter_impl< BasicJsonType > &  other) const
inline

comparison: equal

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5842 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::internal_iterator< BasicJsonType >::array_iterator, nlohmann::detail::invalid_iterator::create(), JSON_THROW, JSON_UNLIKELY, nlohmann::detail::iter_impl< BasicJsonType >::m_it, nlohmann::detail::iter_impl< BasicJsonType >::m_object, nlohmann::detail::object, nlohmann::detail::internal_iterator< BasicJsonType >::object_iterator, and nlohmann::detail::internal_iterator< BasicJsonType >::primitive_iterator.

5843  {
5844  // if objects are not the same, the comparison is undefined
5845  if (JSON_UNLIKELY(m_object != other.m_object))
5846  {
5847  JSON_THROW(invalid_iterator::create(212, "cannot compare iterators of different containers"));
5848  }
5849 
5850  assert(m_object != nullptr);
5851 
5852  switch (m_object->m_type)
5853  {
5854  case value_t::object:
5855  return (m_it.object_iterator == other.m_it.object_iterator);
5856 
5857  case value_t::array:
5858  return (m_it.array_iterator == other.m_it.array_iterator);
5859 
5860  default:
5861  return (m_it.primitive_iterator == other.m_it.primitive_iterator);
5862  }
5863  }
difference_type m_it
iterator as signed integer type
Definition: json.hpp:5340
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
#define JSON_UNLIKELY(x)
Definition: json.hpp:194
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
#define JSON_THROW(exception)
Definition: json.hpp:162
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
bool nlohmann::detail::iter_impl< BasicJsonType >::operator> ( const iter_impl< BasicJsonType > &  other) const
inline

comparison: greater than

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5914 of file json.hpp.

5915  {
5916  return not operator<=(other);
5917  }
bool operator<=(const iter_impl &other) const
comparison: less than or equal
Definition: json.hpp:5905
template<typename BasicJsonType>
bool nlohmann::detail::iter_impl< BasicJsonType >::operator>= ( const iter_impl< BasicJsonType > &  other) const
inline

comparison: greater than or equal

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5923 of file json.hpp.

References nlohmann::detail::operator<().

5924  {
5925  return not operator<(other);
5926  }
bool operator<(const iter_impl &other) const
comparison: smaller
Definition: json.hpp:5878
template<typename BasicJsonType>
reference nlohmann::detail::iter_impl< BasicJsonType >::operator[] ( difference_type  n) const
inline

access to successor

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 6024 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::invalid_iterator::create(), JSON_LIKELY, JSON_THROW, nlohmann::detail::null, and nlohmann::detail::object.

6025  {
6026  assert(m_object != nullptr);
6027 
6028  switch (m_object->m_type)
6029  {
6030  case value_t::object:
6031  JSON_THROW(invalid_iterator::create(208, "cannot use operator[] for object iterators"));
6032 
6033  case value_t::array:
6034  return *std::next(m_it.array_iterator, n);
6035 
6036  case value_t::null:
6037  JSON_THROW(invalid_iterator::create(214, "cannot get value"));
6038 
6039  default:
6040  {
6042  {
6043  return *m_object;
6044  }
6045 
6046  JSON_THROW(invalid_iterator::create(214, "cannot get value"));
6047  }
6048  }
6049  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
#define JSON_THROW(exception)
Definition: json.hpp:162
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
constexpr difference_type get_value() const noexcept
Definition: json.hpp:5343
object (unordered set of name/value pairs)
#define JSON_LIKELY(x)
Definition: json.hpp:193
static invalid_iterator create(int id_, const std::string &what_arg)
Definition: json.hpp:971
template<typename BasicJsonType>
void nlohmann::detail::iter_impl< BasicJsonType >::set_begin ( )
inlineprivatenoexcept

set the iterator to the first value

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5617 of file json.hpp.

References nlohmann::detail::array, nlohmann::detail::null, and nlohmann::detail::object.

Referenced by nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::begin(), and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::cbegin().

5618  {
5619  assert(m_object != nullptr);
5620 
5621  switch (m_object->m_type)
5622  {
5623  case value_t::object:
5624  {
5625  m_it.object_iterator = m_object->m_value.object->begin();
5626  break;
5627  }
5628 
5629  case value_t::array:
5630  {
5631  m_it.array_iterator = m_object->m_value.array->begin();
5632  break;
5633  }
5634 
5635  case value_t::null:
5636  {
5637  // set to end so begin()==end() is true: null is empty
5639  break;
5640  }
5641 
5642  default:
5643  {
5645  break;
5646  }
5647  }
5648  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:5355
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
void set_begin() noexcept
set iterator to a defined beginning
Definition: json.hpp:5349
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
template<typename BasicJsonType>
void nlohmann::detail::iter_impl< BasicJsonType >::set_end ( )
inlineprivatenoexcept

set the iterator past the last value

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5654 of file json.hpp.

References nlohmann::detail::array, and nlohmann::detail::object.

Referenced by nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::cend(), and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberUnsignedType, NumberFloatType, AllocatorType, JSONSerializer >::end().

5655  {
5656  assert(m_object != nullptr);
5657 
5658  switch (m_object->m_type)
5659  {
5660  case value_t::object:
5661  {
5662  m_it.object_iterator = m_object->m_value.object->end();
5663  break;
5664  }
5665 
5666  case value_t::array:
5667  {
5668  m_it.array_iterator = m_object->m_value.array->end();
5669  break;
5670  }
5671 
5672  default:
5673  {
5675  break;
5676  }
5677  }
5678  }
array (ordered collection of values)
pointer m_object
associated JSON instance
Definition: json.hpp:6078
void set_end() noexcept
set iterator to a defined past the end
Definition: json.hpp:5355
BasicJsonType::object_t::iterator object_iterator
iterator for JSON objects
Definition: json.hpp:5454
primitive_iterator_t primitive_iterator
generic iterator for all other types
Definition: json.hpp:5458
BasicJsonType::array_t::iterator array_iterator
iterator for JSON arrays
Definition: json.hpp:5456
internal_iterator< typename std::remove_const< BasicJsonType >::type > m_it
the actual iterator of the associated instance
Definition: json.hpp:6080
object (unordered set of name/value pairs)
template<typename BasicJsonType>
reference nlohmann::detail::iter_impl< BasicJsonType >::value ( ) const
inline

return the value of an iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 6071 of file json.hpp.

References operator*().

6072  {
6073  return operator*();
6074  }
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:5685

Friends And Related Function Documentation

template<typename BasicJsonType>
iter_impl operator+ ( difference_type  i,
const iter_impl< BasicJsonType > &  it 
)
friend

addition of distance and iterator

Precondition
The iterator is initialized; i.e. m_object != nullptr.

Definition at line 5981 of file json.hpp.

5982  {
5983  auto result = it;
5984  result += i;
5985  return result;
5986  }

Member Data Documentation

template<typename BasicJsonType>
friend nlohmann::detail::iter_impl< BasicJsonType >::BasicJsonType
private

Definition at line 5515 of file json.hpp.

template<typename BasicJsonType>
friend nlohmann::detail::iter_impl< BasicJsonType >::iteration_proxy< iter_impl >
private

Definition at line 5516 of file json.hpp.


The documentation for this class was generated from the following file: