libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::detail::JsonReverseIterator< JsonIterator > Class Template Reference

#include <json_reverse_iterator.hpp>

Inheritance diagram for fly::detail::JsonReverseIterator< JsonIterator >:
Collaboration diagram for fly::detail::JsonReverseIterator< JsonIterator >:

Public Types

using value_type = typename JsonIterator::value_type
 
using difference_type = typename JsonIterator::difference_type
 
using reference = typename JsonIterator::reference
 
using const_reference = const reference
 
using pointer = typename JsonIterator::pointer
 

Public Member Functions

 JsonReverseIterator () noexcept
 
 JsonReverseIterator (const JsonIterator &it) noexcept
 
 JsonReverseIterator (const reverse_iterator &it) noexcept
 
reference operator* () const
 
pointer operator-> () const
 
reference operator[] (difference_type offset) const
 
JsonReverseIterator operator++ (int)
 
JsonReverseIteratoroperator++ ()
 
JsonReverseIterator operator-- (int)
 
JsonReverseIteratoroperator-- ()
 
JsonReverseIteratoroperator+= (difference_type offset)
 
JsonReverseIteratoroperator-= (difference_type offset)
 
JsonReverseIterator operator+ (difference_type offset) const
 
JsonReverseIterator operator- (difference_type offset) const
 
difference_type operator- (const JsonReverseIterator &other) const
 
const json_object_type::key_type & key () const
 
reference value () const
 

Detailed Description

template<typename JsonIterator>
class fly::detail::JsonReverseIterator< JsonIterator >

Class to provide reverse iterator access to a Json instance. Primarily serves as a wrapper around std::reverse_iterator<JsonIterator>.

This class is afforded the same undefined behavior protections as JsonIterator.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
November 4, 2020

Member Typedef Documentation

◆ value_type

template<typename JsonIterator >
using fly::detail::JsonReverseIterator< JsonIterator >::value_type = typename JsonIterator::value_type

Aliases for canonical STL reverse iterator member types.

Constructor & Destructor Documentation

◆ JsonReverseIterator() [1/3]

template<typename JsonIterator >
fly::detail::JsonReverseIterator< JsonIterator >::JsonReverseIterator
noexcept

Default constructor. Initializes the iterator to an empty value.

◆ JsonReverseIterator() [2/3]

template<typename JsonIterator >
fly::detail::JsonReverseIterator< JsonIterator >::JsonReverseIterator ( const JsonIterator it)
explicitnoexcept

Constructor to initialize the reverse iterator with an existing forward iterator.

Parameters
itThe forward iterator to intialize with.

◆ JsonReverseIterator() [3/3]

template<typename JsonIterator >
fly::detail::JsonReverseIterator< JsonIterator >::JsonReverseIterator ( const reverse_iterator &  it)
explicitnoexcept

Constructor to initialize the reverse iterator with an existing reverse iterator.

Parameters
itThe reverse iterator to intialize with.

Member Function Documentation

◆ key()

template<typename JsonIterator >
const json_object_type::key_type & fly::detail::JsonReverseIterator< JsonIterator >::key

Retrieve a reference to the key of the Json instance pointed to by this iterator. Only valid for Json object types.

Returns
A reference to the Json object's key.
Exceptions
JsonIteratorExceptionIf the Json instance is not an object.
NullJsonExceptionIf the iterator is empty or past-the-end.

◆ operator*()

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator*

Retrieve a reference to the Json instance pointed to by this iterator.

Returns
A reference to the Json instance.
Exceptions
NullJsonExceptionIf the iterator is empty or past-the-end.

◆ operator+()

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator+ ( difference_type  offset) const

Addition operator. Retrieve an iterator pointed at the Json instance some offset earlier or later in the sequence. Invalid for Json object types.

Parameters
offsetThe offset to retrieve.
Returns
An iterator pointed at the Json instance.
Exceptions
JsonIteratorExceptionIf the Json instance is an object.
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the iterator at the offset escapes the Json instance's valid range.

◆ operator++() [1/2]

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator++

Pre-increment operator. Sets the instance pointed to by this iterator to the next instance in the sequence.

Returns
A reference to this iterator instance.
Exceptions
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the next iterator escapes the Json instance's valid range.

◆ operator++() [2/2]

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator++ ( int  dummy)

Post-increment operator. Sets the instance pointed to by this iterator to the next instance in the sequence.

Returns
A copy of the iterator before the increment.
Exceptions
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the next iterator escapes the Json instance's valid range.

◆ operator+=()

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator+= ( difference_type  offset)

Addition operator. Sets the Json instance pointed to by this iterator to some offset earlier or later in the sequence. Invalid for Json object types.

Parameters
offsetThe offset by which to increment the iterator.
Returns
A reference to this iterator instance.
Exceptions
JsonIteratorExceptionIf the Json instance is an object.
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the iterator at the offset escapes the Json instance's valid range.

◆ operator-() [1/2]

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator- ( const JsonReverseIterator< JsonIterator > &  other) const

Difference operator. Compute the distance between this iterator and another. Invalid for Json object types.

Parameters
otherThe iterator instance to compare.
Returns
The distance between the two iterators.
Exceptions
JsonIteratorExceptionIf the Json instance is an object.
NullJsonExceptionIf either iterator is empty.

◆ operator-() [2/2]

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator- ( difference_type  offset) const

Subtraction operator. Retrieve an iterator pointed at the Json instance some offset earlier or later in the sequence. Invalid for Json object types.

Parameters
offsetThe offset to retrieve.
Returns
An iterator pointed at the Json instance.
Exceptions
JsonIteratorExceptionIf the Json instance is an object.
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the iterator at the offset escapes the Json instance's valid range.

◆ operator--() [1/2]

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator--

Pre-decrement operator. Sets the instance pointed to by this iterator to the previous instance in the sequence.

Returns
A reference to this iterator instance.
Exceptions
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the previous iterator escapes the Json instance's valid range.

◆ operator--() [2/2]

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator-- ( int  dummy)

Post-decrement operator. Sets the instance pointed to by this iterator to the previous instance in the sequence.

Returns
A copy of the iterator before the decrement.
Exceptions
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the previous iterator escapes the Json instance's valid range.

◆ operator-=()

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator-= ( difference_type  offset)

Subtraction operator. Sets the Json instance pointed to by this iterator to some offset earlier or later in the sequence. Invalid for Json object types.

Parameters
offsetThe offset by which to decrement the iterator.
Returns
A reference to this iterator instance.
Exceptions
JsonIteratorExceptionIf the Json instance is an object.
NullJsonExceptionIf the iterator is empty.
OutOfRangeJsonExceptionIf the iterator at the offset escapes the Json instance's valid range.

◆ operator->()

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator->

Retrieve a pointer to the Json instance pointed to by this iterator.

Returns
A pointer to the Json instance.
Exceptions
NullJsonExceptionIf the iterator is empty or past-the-end.

◆ operator[]()

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::operator[] ( difference_type  offset) const

Retrieve a reference to the Json instance at some offset earlier or later than the instance pointed to by this iterator. Invoking operator[0] is equivalent to invoking operator*. Invalid for Json object types.

Parameters
offsetThe offset to retrieve.
Returns
A reference to the Json instance.
Exceptions
JsonIteratorExceptionIf the Json instance is an object.
NullJsonExceptionIf the iterator at the offset is empty or past-the-end.
OutOfRangeJsonExceptionIf the iterator at the offset escapes the Json instance's valid range.

◆ value()

template<typename JsonIterator >
auto fly::detail::JsonReverseIterator< JsonIterator >::value

Retrieve a reference to the Json instance pointed to by this iterator.

Returns
A reference to the Json instance.
Exceptions
NullJsonExceptionIf the iterator is empty or past-the-end.

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