8 #include <nlohmann/detail/meta/type_traits.hpp>
9 #include <nlohmann/detail/value_t.hpp>
15 template<
typename string_type>
16 void int_to_string( string_type& target, std::size_t value )
25 using difference_type = std::ptrdiff_t;
29 using iterator_category = std::input_iterator_tag;
30 using string_type =
typename std::remove_cv< typename std::remove_reference<decltype( std::declval<IteratorType>().
key() ) >::type >::type;
36 std::size_t array_index = 0;
38 mutable std::size_t array_index_last = 0;
40 mutable string_type array_index_str =
"0";
42 const string_type empty_str =
"";
65 return anchor == o.anchor;
71 return anchor != o.anchor;
75 const string_type&
key()
const
77 JSON_ASSERT(anchor.m_object !=
nullptr);
79 switch (anchor.m_object->type())
84 if (array_index != array_index_last)
86 int_to_string( array_index_str, array_index );
87 array_index_last = array_index;
89 return array_index_str;
103 typename IteratorType::reference
value()
const
105 return anchor.value();
114 typename IteratorType::reference container;
136 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 0,
int> = 0>
144 template<std::
size_t N,
typename IteratorType, enable_if_t<N == 1,
int> = 0>
158 #if defined(__clang__)
160 #pragma clang diagnostic push
161 #pragma clang diagnostic ignored "-Wmismatched-tags"
163 template<
typename IteratorType>
165 :
public std::integral_constant<std::size_t, 2> {};
167 template<std::
size_t N,
typename IteratorType>
171 using type = decltype(
172 get<N>(std::declval <
175 #if defined(__clang__)
176 #pragma clang diagnostic pop
Definition: iteration_proxy.hpp:23
iteration_proxy_value & operator*()
dereference operator (needed for range-based for)
Definition: iteration_proxy.hpp:48
bool operator!=(const iteration_proxy_value &o) const
inequality operator (needed for range-based for)
Definition: iteration_proxy.hpp:69
IteratorType::reference value() const
return value of the iterator
Definition: iteration_proxy.hpp:103
iteration_proxy_value & operator++()
increment operator (needed for range-based for)
Definition: iteration_proxy.hpp:54
const string_type & key() const
return key of the iterator
Definition: iteration_proxy.hpp:75
bool operator==(const iteration_proxy_value &o) const
equality operator (needed for InputIterator)
Definition: iteration_proxy.hpp:63
proxy class for the items() function
Definition: iteration_proxy.hpp:111
iteration_proxy_value< IteratorType > begin() noexcept
return iterator begin (needed for range-based for)
Definition: iteration_proxy.hpp:122
iteration_proxy_value< IteratorType > end() noexcept
return iterator end (needed for range-based for)
Definition: iteration_proxy.hpp:128
iteration_proxy(typename IteratorType::reference cont) noexcept
construct iteration proxy from a container
Definition: iteration_proxy.hpp:118
@ object
object (unordered set of name/value pairs)
@ array
array (ordered collection of values)
namespace for Niels Lohmann
Definition: adl_serializer.hpp:9
NLOHMANN_BASIC_JSON_TPL_DECLARATION std::string to_string(const NLOHMANN_BASIC_JSON_TPL &j)
user-defined to_string function for JSON values
Definition: json.hpp:8684