A toolkit for working with phylogenetic data.
v0.24.0
JsonIterator< U > Class Template Reference

#include <genesis/utils/formats/json/document.hpp>

Inherits iterator< std::random_access_iterator_tag, U >.

Detailed Description

template<typename U>
class genesis::utils::JsonIterator< U >

Template for a random access iterator for the JsonDocument class.

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

The class satisfies the following concept requirements: RandomAccessIterator. The iterator that can be moved to point (forward and backward) to any element in constant time.

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. We use assertions to detect calls on uninitialized iterators.

This class is a heavily altered adaption of the excellent JSON for Modern C++ library by Niels Lohmann, see also Acknowledgements.

Definition at line 88 of file json/document.hpp.

Public Member Functions

 JsonIterator ()=default
 
 JsonIterator (pointer object)
 Constructor for a given JSON instance. More...
 
 JsonIterator (const JsonIterator &other) noexcept
 Copy constructor. More...
 
JsonDocument::ObjectType::key_type key () const
 return the key of an object iterator More...
 
bool operator!= (const JsonIterator &other) const
 comparison: not equal More...
 
reference operator* () const
 Return a reference to the value pointed to by the iterator. More...
 
JsonIterator operator+ (difference_type i)
 add to iterator More...
 
JsonIterator operator++ (int)
 Post-increment (it++). More...
 
JsonIteratoroperator++ ()
 Pre-increment (++it). More...
 
JsonIteratoroperator+= (difference_type i)
 add to iterator More...
 
JsonIterator operator- (difference_type i)
 subtract from iterator More...
 
difference_type operator- (const JsonIterator &other) const
 return difference More...
 
JsonIterator operator-- (int)
 Post-decrement (it–). More...
 
JsonIteratoroperator-- ()
 pre-decrement (–it) More...
 
JsonIteratoroperator-= (difference_type i)
 subtract from iterator More...
 
pointer operator-> () const
 Dereference the Iterator. More...
 
bool operator< (const JsonIterator &other) const
 comparison: smaller More...
 
bool operator<= (const JsonIterator &other) const
 comparison: less than or equal More...
 
JsonIteratoroperator= (JsonIterator other) noexcept(std::is_nothrow_move_constructible< pointer >::value and std::is_nothrow_move_assignable< pointer >::value and std::is_nothrow_move_constructible< InternalIterator >::value and std::is_nothrow_move_assignable< InternalIterator >::value)
 Copy assignment. More...
 
bool operator== (const JsonIterator &other) const
 comparison: equal More...
 
bool operator> (const JsonIterator &other) const
 comparison: greater than More...
 
bool operator>= (const JsonIterator &other) const
 comparison: greater than or equal More...
 
reference operator[] (difference_type n) const
 access to successor More...
 
reference value () const
 return the value of an iterator More...
 

Public Types

using difference_type = typename JsonDocument::difference_type
 
using iterator_category = std::bidirectional_iterator_tag
 
using pointer = typename std::conditional< std::is_const< U >::value, typename JsonDocument::const_pointer, typename JsonDocument::pointer >::type
 
using reference = typename std::conditional< std::is_const< U >::value, typename JsonDocument::const_reference, typename JsonDocument::reference >::type
 
using value_type = typename JsonDocument::value_type
 

Classes

struct  InternalIterator
 an iterator value More...
 
class  PrimitiveIterator
 an iterator for primitive JSON types More...
 

Friends

class JsonDocument
 

Constructor & Destructor Documentation

◆ JsonIterator() [1/3]

JsonIterator ( )
default

◆ JsonIterator() [2/3]

JsonIterator ( pointer  object)
inlineexplicit

Constructor for a given JSON instance.

Definition at line 239 of file iterator.hpp.

◆ JsonIterator() [3/3]

JsonIterator ( const JsonIterator< U > &  other)
inlinenoexcept

Copy constructor.

Definition at line 265 of file iterator.hpp.

Member Function Documentation

◆ key()

JsonDocument::ObjectType::key_type key ( ) const
inline

return the key of an object iterator

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

Definition at line 627 of file iterator.hpp.

◆ operator!=()

bool operator!= ( const JsonIterator< U > &  other) const
inline

comparison: not equal

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

Definition at line 451 of file iterator.hpp.

◆ operator*()

reference operator* ( ) const
inline

Return a reference to the value pointed to by the iterator.

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

Definition at line 294 of file iterator.hpp.

◆ operator+()

JsonIterator operator+ ( difference_type  i)
inline

add to iterator

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

Definition at line 547 of file iterator.hpp.

◆ operator++() [1/2]

JsonIterator operator++ ( int  )
inline

Post-increment (it++).

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

Definition at line 351 of file iterator.hpp.

◆ operator++() [2/2]

JsonIterator& operator++ ( )
inline

Pre-increment (++it).

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

Definition at line 362 of file iterator.hpp.

◆ operator+=()

JsonIterator& operator+= ( difference_type  i)
inline

add to iterator

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

Definition at line 513 of file iterator.hpp.

◆ operator-() [1/2]

JsonIterator operator- ( difference_type  i)
inline

subtract from iterator

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

Definition at line 558 of file iterator.hpp.

◆ operator-() [2/2]

difference_type operator- ( const JsonIterator< U > &  other) const
inline

return difference

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

Definition at line 569 of file iterator.hpp.

◆ operator--() [1/2]

JsonIterator operator-- ( int  )
inline

Post-decrement (it–).

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

Definition at line 388 of file iterator.hpp.

◆ operator--() [2/2]

JsonIterator& operator-- ( )
inline

pre-decrement (–it)

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

Definition at line 399 of file iterator.hpp.

◆ operator-=()

JsonIterator& operator-= ( difference_type  i)
inline

subtract from iterator

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

Definition at line 538 of file iterator.hpp.

◆ operator->()

pointer operator-> ( ) const
inline

Dereference the Iterator.

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

Definition at line 324 of file iterator.hpp.

◆ operator<()

bool operator< ( const JsonIterator< U > &  other) const
inline

comparison: smaller

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

Definition at line 460 of file iterator.hpp.

◆ operator<=()

bool operator<= ( const JsonIterator< U > &  other) const
inline

comparison: less than or equal

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

Definition at line 486 of file iterator.hpp.

◆ operator=()

JsonIterator& operator= ( JsonIterator< U >  other)
inlinenoexcept

Copy assignment.

Definition at line 273 of file iterator.hpp.

◆ operator==()

bool operator== ( const JsonIterator< U > &  other) const
inline

comparison: equal

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

Definition at line 425 of file iterator.hpp.

◆ operator>()

bool operator> ( const JsonIterator< U > &  other) const
inline

comparison: greater than

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

Definition at line 495 of file iterator.hpp.

◆ operator>=()

bool operator>= ( const JsonIterator< U > &  other) const
inline

comparison: greater than or equal

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

Definition at line 504 of file iterator.hpp.

◆ operator[]()

reference operator[] ( difference_type  n) const
inline

access to successor

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

Definition at line 592 of file iterator.hpp.

◆ value()

reference value ( ) const
inline

return the value of an iterator

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

Definition at line 642 of file iterator.hpp.

Friends And Related Function Documentation

◆ JsonDocument

friend class JsonDocument
friend

Definition at line 109 of file iterator.hpp.

Member Typedef Documentation

◆ difference_type

Definition at line 125 of file iterator.hpp.

◆ iterator_category

using iterator_category = std::bidirectional_iterator_tag

Definition at line 136 of file iterator.hpp.

◆ pointer

using pointer = typename std::conditional<std::is_const<U>::value, typename JsonDocument::const_pointer, typename JsonDocument::pointer >::type

Definition at line 130 of file iterator.hpp.

◆ reference

using reference = typename std::conditional<std::is_const<U>::value, typename JsonDocument::const_reference, typename JsonDocument::reference >::type

Definition at line 134 of file iterator.hpp.

◆ value_type

Definition at line 124 of file iterator.hpp.


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