matador::const_json_iterator< JSON_TYPE > Class Template Reference

An iterator for json array and objects. More...

#include <json.hpp>

Public Types

typedef JSON_TYPE json_type
 
typedef json_type::array_type array_type
 
typedef json_type::object_type object_type
 

Public Member Functions

 const_json_iterator (const json_type *ptr, bool as_begin)
 
 const_json_iterator (const const_json_iterator< JSON_TYPE > &x)
 
const_json_iteratoroperator= (const const_json_iterator< JSON_TYPE > &x)
 
const_json_iterator operator++ ()
 
const_json_iterator operator++ (int)
 
const_json_iterator operator-- ()
 
const_json_iterator operator-- (int)
 
const jsonoperator* () const
 
const jsonoperator-> () const
 
bool operator== (const const_json_iterator< JSON_TYPE > &x) const
 
bool operator!= (const const_json_iterator< JSON_TYPE > &x) const
 

Detailed Description

template<class JSON_TYPE>
class matador::const_json_iterator< JSON_TYPE >

An iterator for json array and objects.

The iterator handles elements of json arrays and json objects. If initialized with a non array or object the iterator uses the given json as the element neither as begin or end.

Member Typedef Documentation

◆ array_type

template<class JSON_TYPE >
typedef json_type::array_type matador::const_json_iterator< JSON_TYPE >::array_type

Shortcut for json array type

◆ json_type

template<class JSON_TYPE >
typedef JSON_TYPE matador::const_json_iterator< JSON_TYPE >::json_type

Shortcut for json

◆ object_type

template<class JSON_TYPE >
typedef json_type::object_type matador::const_json_iterator< JSON_TYPE >::object_type

Shortcut for json object type

Constructor & Destructor Documentation

◆ const_json_iterator() [1/2]

template<class JSON_TYPE >
matador::const_json_iterator< JSON_TYPE >::const_json_iterator ( const json_type ptr,
bool  as_begin 
)
inline

Creates a json_iterator for the given json object. In case the json object isn't of type_ object or array the given flag as_begin tells the c'tor if the jsn value is treated like begin or end element.

Parameters
ptrPointer to the json
as_beginTrue if non array/object should be treated as begin iterator

◆ const_json_iterator() [2/2]

template<class JSON_TYPE >
matador::const_json_iterator< JSON_TYPE >::const_json_iterator ( const const_json_iterator< JSON_TYPE > &  x)
inline

Copy construct a json_iterator from given iterator

Parameters
xThe iterator to copy from

Member Function Documentation

◆ operator!=()

template<class JSON_TYPE >
bool matador::const_json_iterator< JSON_TYPE >::operator!= ( const const_json_iterator< JSON_TYPE > &  x) const
inline

Not equal operator for json_iterator. Depending on the json type the values are compared.

Parameters
xThe json_iterator to compare
Returns
True if the values are the not same

◆ operator*()

template<class JSON_TYPE >
const json & matador::const_json_iterator< JSON_TYPE >::operator* ( ) const
inline

Indirection operator. Returns the reference to the json object represented by the iterator. If the json type is null a std::logic_error is thrown.

Returns
The reference of the json object

◆ operator++() [1/2]

template<class JSON_TYPE >
const_json_iterator matador::const_json_iterator< JSON_TYPE >::operator++ ( )
inline

Post increments (++i) the json_iterator step to next array element or next object element

Returns
The incremented iterator

◆ operator++() [2/2]

template<class JSON_TYPE >
const_json_iterator matador::const_json_iterator< JSON_TYPE >::operator++ ( int  )
inline

Pre increments (i++) the json_iterator step to next array element or next object element

Returns
The incremented iterator

◆ operator--() [1/2]

template<class JSON_TYPE >
const_json_iterator matador::const_json_iterator< JSON_TYPE >::operator-- ( )
inline

Post decrements (–i) the json_iterator step to previous array element or next object element

Returns
The decremented iterator

◆ operator--() [2/2]

template<class JSON_TYPE >
const_json_iterator matador::const_json_iterator< JSON_TYPE >::operator-- ( int  )
inline

Pre decrements (i–) the json_iterator step to previous array element or next object element

Returns
The decremented iterator

◆ operator->()

template<class JSON_TYPE >
const json * matador::const_json_iterator< JSON_TYPE >::operator-> ( ) const
inline

Address of operator. Returns the pointer to the json object represented by the iterator. If the json type is null a std::logic_error is thrown.

Returns
The pointer of the json object

◆ operator=()

template<class JSON_TYPE >
const_json_iterator & matador::const_json_iterator< JSON_TYPE >::operator= ( const const_json_iterator< JSON_TYPE > &  x)
inline

Copy assigns a json_iterator from given iterator

Parameters
xThe iterator to copy assign from

◆ operator==()

template<class JSON_TYPE >
bool matador::const_json_iterator< JSON_TYPE >::operator== ( const const_json_iterator< JSON_TYPE > &  x) const
inline

Equal operator for json_iterator. Depending on the json type the values are compared.

Parameters
xThe json_iterator to compare
Returns
True if the values are the same

The documentation for this class was generated from the following file:
  • matador/json/json.hpp