JSON for Modern C++  3.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator Class Reference

a const random access iterator for the basic_json class

#include <json.hpp>

Inheritance diagram for nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator:
Collaboration diagram for nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator:

Public Types

using value_type = basic_json::value_type
 the type of the values when the iterator is dereferenced More...
 
using difference_type = basic_json::difference_type
 a type to represent differences between iterators More...
 
using pointer = basic_json::const_pointer
 defines a pointer to the type iterated over (value_type) More...
 
using reference = basic_json::const_reference
 defines a reference to the type iterated over (value_type) More...
 
using iterator_category = std::bidirectional_iterator_tag
 the category of the iterator More...
 

Public Member Functions

 const_iterator ()=default
 default constructor More...
 
 const_iterator (pointer object) noexcept
 constructor for a given JSON instance More...
 
 const_iterator (const iterator &other) noexcept
 copy constructor given a nonconst iterator More...
 
 const_iterator (const const_iterator &other) noexcept
 copy constructor More...
 
const_iteratoroperator= (const_iterator other) noexcept(std::is_nothrow_move_constructible< pointer >::value andstd::is_nothrow_move_assignable< pointer >::value andstd::is_nothrow_move_constructible< internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator >>::valueandstd::is_nothrow_move_assignable< internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator >>::value)
 copy assignment More...
 
reference operator* () const
 return a reference to the value pointed to by the iterator More...
 
pointer operator-> () const
 dereference the iterator More...
 
const_iterator operator++ (int)
 post-increment (it++) More...
 
const_iteratoroperator++ ()
 pre-increment (++it) More...
 
const_iterator operator-- (int)
 post-decrement (it–) More...
 
const_iteratoroperator-- ()
 pre-decrement (–it) More...
 
bool operator== (const const_iterator &other) const
 comparison: equal More...
 
bool operator!= (const const_iterator &other) const
 comparison: not equal More...
 
bool operator< (const const_iterator &other) const
 comparison: smaller More...
 
bool operator<= (const const_iterator &other) const
 comparison: less than or equal More...
 
bool operator> (const const_iterator &other) const
 comparison: greater than More...
 
bool operator>= (const const_iterator &other) const
 comparison: greater than or equal More...
 
const_iteratoroperator+= (difference_type i)
 add to iterator More...
 
const_iteratoroperator-= (difference_type i)
 subtract from iterator More...
 
const_iterator operator+ (difference_type i)
 add to iterator More...
 
const_iterator operator- (difference_type i)
 subtract from iterator More...
 
difference_type operator- (const const_iterator &other) const
 return difference More...
 
reference operator[] (difference_type n) const
 access to successor More...
 
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 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

pointer m_object = nullptr
 associated JSON instance More...
 
internal_iterator< typename
array_t::const_iterator,
typename
object_t::const_iterator > 
m_it
 the actual iterator of the associated instance More...
 

Friends

class basic_json
 

Detailed Description

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
class nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator

Definition at line 2745 of file json.hpp.

Member Typedef Documentation

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::difference_type = basic_json::difference_type

Definition at line 2754 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::iterator_category = std::bidirectional_iterator_tag

Definition at line 2760 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::pointer = basic_json::const_pointer

Definition at line 2756 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::reference = basic_json::const_reference

Definition at line 2758 of file json.hpp.

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
using nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::value_type = basic_json::value_type

Definition at line 2752 of file json.hpp.

Constructor & Destructor Documentation

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::const_iterator ( )
inlinedefault
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::const_iterator ( pointer  object)
inlinenoexcept

Definition at line 2766 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

2766  : m_object(object)
2767  {
2768  switch (m_object->m_type)
2769  {
2771  {
2772  m_it.object_iterator = typename object_t::const_iterator();
2773  break;
2774  }
2776  {
2777  m_it.array_iterator = typename array_t::const_iterator();
2778  break;
2779  }
2780  default:
2781  {
2782  m_it.generic_iterator = -1;
2783  break;
2784  }
2785  }
2786  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::const_iterator ( const iterator other)
inlinenoexcept

Definition at line 2789 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

2789  : m_object(other.m_object)
2790  {
2791  switch (m_object->m_type)
2792  {
2794  {
2795  m_it.object_iterator = other.m_it.object_iterator;
2796  break;
2797  }
2798 
2800  {
2801  m_it.array_iterator = other.m_it.array_iterator;
2802  break;
2803  }
2804 
2805  default:
2806  {
2807  m_it.generic_iterator = other.m_it.generic_iterator;
2808  break;
2809  }
2810  }
2811  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::const_iterator ( const const_iterator other)
inlinenoexcept

Definition at line 2814 of file json.hpp.

2815  : m_object(other.m_object), m_it(other.m_it)
2816  {}
pointer m_object
associated JSON instance
Definition: json.hpp:3276
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278

Member Function Documentation

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
object_t::key_type nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::key ( ) const
inline

Definition at line 3252 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3253  {
3254  switch (m_object->m_type)
3255  {
3257  {
3258  return m_it.object_iterator->first;
3259  }
3260 
3261  default:
3262  {
3263  throw std::domain_error("cannot use key() for non-object iterators");
3264  }
3265  }
3266  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator!= ( const const_iterator other) const
inline

Definition at line 3095 of file json.hpp.

3096  {
3097  return not operator==(other);
3098  }
bool operator==(const const_iterator &other) const
comparison: equal
Definition: json.hpp:3067
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator* ( ) const
inline

Definition at line 2892 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::null, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

2893  {
2894  switch (m_object->m_type)
2895  {
2897  {
2898  return m_it.object_iterator->second;
2899  }
2900 
2902  {
2903  return *m_it.array_iterator;
2904  }
2905 
2907  {
2908  throw std::out_of_range("cannot get value");
2909  }
2910 
2911  default:
2912  {
2913  if (m_it.generic_iterator == 0)
2914  {
2915  return *m_object;
2916  }
2917  else
2918  {
2919  throw std::out_of_range("cannot get value");
2920  }
2921  }
2922  }
2923  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator+ ( difference_type  i)
inline

Definition at line 3180 of file json.hpp.

3181  {
3182  auto result = *this;
3183  result += i;
3184  return result;
3185  }
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator++ ( int  )
inline

Definition at line 2955 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

2956  {
2957  auto result = *this;
2958 
2959  switch (m_object->m_type)
2960  {
2962  {
2963  m_it.object_iterator++;
2964  break;
2965  }
2966 
2968  {
2969  m_it.array_iterator++;
2970  break;
2971  }
2972 
2973  default:
2974  {
2975  m_it.generic_iterator++;
2976  break;
2977  }
2978  }
2979 
2980  return result;
2981  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator& nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator++ ( )
inline

Definition at line 2984 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

2985  {
2986  switch (m_object->m_type)
2987  {
2989  {
2990  ++m_it.object_iterator;
2991  break;
2992  }
2993 
2995  {
2996  ++m_it.array_iterator;
2997  break;
2998  }
2999 
3000  default:
3001  {
3002  ++m_it.generic_iterator;
3003  break;
3004  }
3005  }
3006 
3007  return *this;
3008  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator& nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator+= ( difference_type  i)
inline

Definition at line 3147 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3148  {
3149  switch (m_object->m_type)
3150  {
3152  {
3153  throw std::domain_error("cannot use operator+= for object iterators");
3154  break;
3155  }
3156 
3158  {
3159  m_it.array_iterator += i;
3160  break;
3161  }
3162 
3163  default:
3164  {
3165  m_it.generic_iterator += i;
3166  break;
3167  }
3168  }
3169 
3170  return *this;
3171  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator- ( difference_type  i)
inline

Definition at line 3188 of file json.hpp.

3189  {
3190  auto result = *this;
3191  result -= i;
3192  return result;
3193  }
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
difference_type nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator- ( const const_iterator other) const
inline

Definition at line 3196 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::m_it, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3197  {
3198  switch (m_object->m_type)
3199  {
3201  {
3202  throw std::domain_error("cannot use operator- for object iterators");
3203  }
3204 
3206  {
3207  return m_it.array_iterator - other.m_it.array_iterator;
3208  }
3209 
3210  default:
3211  {
3212  return m_it.generic_iterator - other.m_it.generic_iterator;
3213  }
3214  }
3215  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator-- ( int  )
inline

Definition at line 3011 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3012  {
3013  auto result = *this;
3014 
3015  switch (m_object->m_type)
3016  {
3018  {
3019  m_it.object_iterator--;
3020  break;
3021  }
3022 
3024  {
3025  m_it.array_iterator--;
3026  break;
3027  }
3028 
3029  default:
3030  {
3031  m_it.generic_iterator--;
3032  break;
3033  }
3034  }
3035 
3036  return result;
3037  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator& nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator-- ( )
inline

Definition at line 3040 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3041  {
3042  switch (m_object->m_type)
3043  {
3045  {
3046  --m_it.object_iterator;
3047  break;
3048  }
3049 
3051  {
3052  --m_it.array_iterator;
3053  break;
3054  }
3055 
3056  default:
3057  {
3058  --m_it.generic_iterator;
3059  break;
3060  }
3061  }
3062 
3063  return *this;
3064  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator& nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator-= ( difference_type  i)
inline

Definition at line 3174 of file json.hpp.

3175  {
3176  return operator+=(-i);
3177  }
const_iterator & operator+=(difference_type i)
add to iterator
Definition: json.hpp:3147
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
pointer nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator-> ( ) const
inline

Definition at line 2926 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

2927  {
2928  switch (m_object->m_type)
2929  {
2931  {
2932  return &(m_it.object_iterator->second);
2933  }
2934 
2936  {
2937  return &*m_it.array_iterator;
2938  }
2939 
2940  default:
2941  {
2942  if (m_it.generic_iterator == 0)
2943  {
2944  return m_object;
2945  }
2946  else
2947  {
2948  throw std::out_of_range("cannot get value");
2949  }
2950  }
2951  }
2952  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator< ( const const_iterator other) const
inline

Definition at line 3101 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::m_it, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::m_object, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3102  {
3103  // if objects are not the same, the comparison is undefined
3104  if (m_object != other.m_object)
3105  {
3106  throw std::domain_error("cannot compare iterators of different containers");
3107  }
3108 
3109  switch (m_object->m_type)
3110  {
3112  {
3113  throw std::domain_error("cannot use operator< for object iterators");
3114  }
3115 
3117  {
3118  return (m_it.array_iterator < other.m_it.array_iterator);
3119  }
3120 
3121  default:
3122  {
3123  return (m_it.generic_iterator < other.m_it.generic_iterator);
3124  }
3125  }
3126  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator<= ( const const_iterator other) const
inline

Definition at line 3129 of file json.hpp.

3130  {
3131  return not other.operator < (*this);
3132  }
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
const_iterator& nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator= ( const_iterator  other)
inlinenoexcept

Definition at line 2819 of file json.hpp.

References std::swap().

2826  {
2827  std::swap(m_object, other.m_object);
2828  std::swap(m_it, other.m_it);
2829  return *this;
2830  }
pointer m_object
associated JSON instance
Definition: json.hpp:3276
void swap(nlohmann::json &j1, nlohmann::json &j2) noexcept(is_nothrow_move_constructible< nlohmann::json >::value andis_nothrow_move_assignable< nlohmann::json >::value)
exchanges the values of two JSON objects
Definition: json.hpp:4695
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278

Here is the call graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator== ( const const_iterator other) const
inline

Definition at line 3067 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::m_it, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::m_object, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3068  {
3069  // if objects are not the same, the comparison is undefined
3070  if (m_object != other.m_object)
3071  {
3072  throw std::domain_error("cannot compare iterators of different containers");
3073  }
3074 
3075  switch (m_object->m_type)
3076  {
3078  {
3079  return (m_it.object_iterator == other.m_it.object_iterator);
3080  }
3081 
3083  {
3084  return (m_it.array_iterator == other.m_it.array_iterator);
3085  }
3086 
3087  default:
3088  {
3089  return (m_it.generic_iterator == other.m_it.generic_iterator);
3090  }
3091  }
3092  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator> ( const const_iterator other) const
inline

Definition at line 3135 of file json.hpp.

3136  {
3137  return not operator<=(other);
3138  }
bool operator<=(const const_iterator &other) const
comparison: less than or equal
Definition: json.hpp:3129
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
bool nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator>= ( const const_iterator other) const
inline

Definition at line 3141 of file json.hpp.

3142  {
3143  return not operator<(other);
3144  }
bool operator<(const const_iterator &other) const
comparison: smaller
Definition: json.hpp:3101
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::operator[] ( difference_type  n) const
inline

Definition at line 3218 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::null, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

3219  {
3220  switch (m_object->m_type)
3221  {
3223  {
3224  throw std::domain_error("cannot use operator[] for object iterators");
3225  }
3226 
3228  {
3229  return *(m_it.array_iterator + n);
3230  }
3231 
3233  {
3234  throw std::out_of_range("cannot get value");
3235  }
3236 
3237  default:
3238  {
3239  if (m_it.generic_iterator == -n)
3240  {
3241  return *m_object;
3242  }
3243  else
3244  {
3245  throw std::out_of_range("cannot get value");
3246  }
3247  }
3248  }
3249  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::set_begin ( )
inlineprivatenoexcept

Definition at line 2834 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::null, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

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

2835  {
2836  switch (m_object->m_type)
2837  {
2839  {
2840  m_it.object_iterator = m_object->m_value.object->cbegin();
2841  break;
2842  }
2843 
2845  {
2846  m_it.array_iterator = m_object->m_value.array->cbegin();
2847  break;
2848  }
2849 
2851  {
2852  // set to end so begin()==end() is true: null is empty
2853  m_it.generic_iterator = 1;
2854  break;
2855  }
2856 
2857  default:
2858  {
2859  m_it.generic_iterator = 0;
2860  break;
2861  }
2862  }
2863  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
object_t * object
object (stored with pointer to save storage)
Definition: json.hpp:213
json_value m_value
the value of the current element
Definition: json.hpp:2203
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:215

Here is the caller graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
void nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::set_end ( )
inlineprivatenoexcept

Definition at line 2866 of file json.hpp.

References nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::array, and nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::object.

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

2867  {
2868  switch (m_object->m_type)
2869  {
2871  {
2872  m_it.object_iterator = m_object->m_value.object->cend();
2873  break;
2874  }
2875 
2877  {
2878  m_it.array_iterator = m_object->m_value.array->cend();
2879  break;
2880  }
2881 
2882  default:
2883  {
2884  m_it.generic_iterator = 1;
2885  break;
2886  }
2887  }
2888  }
value_t m_type
the type of the current element
Definition: json.hpp:2197
object_t * object
object (stored with pointer to save storage)
Definition: json.hpp:213
json_value m_value
the value of the current element
Definition: json.hpp:2203
pointer m_object
associated JSON instance
Definition: json.hpp:3276
array (ordered collection of values)
object (unordered set of name/value pairs)
internal_iterator< typename array_t::const_iterator, typename object_t::const_iterator > m_it
the actual iterator of the associated instance
Definition: json.hpp:3278
array_t * array
array (stored with pointer to save storage)
Definition: json.hpp:215

Here is the caller graph for this function:

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
reference nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::value ( ) const
inline

Definition at line 3269 of file json.hpp.

3270  {
3271  return operator*();
3272  }
reference operator*() const
return a reference to the value pointed to by the iterator
Definition: json.hpp:2892

Friends And Related Function Documentation

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
friend class basic_json
friend

Definition at line 2748 of file json.hpp.

Member Data Documentation

template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
internal_iterator<typename array_t::const_iterator, typename object_t::const_iterator> nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::m_it
private
template<template< typename U, typename V, typename...Args > class ObjectType = std::map, template< typename U, typename...Args > class ArrayType = std::vector, class StringType = std::string, class BooleanType = bool, class NumberIntegerType = int64_t, class NumberFloatType = double, template< typename U > class Allocator = std::allocator>
pointer nlohmann::basic_json< ObjectType, ArrayType, StringType, BooleanType, NumberIntegerType, NumberFloatType, Allocator >::const_iterator::m_object = nullptr
private

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