simdjson 5.0.2
Ridiculously Fast JSON
Loading...
Searching...
No Matches
array_iterator.h
1#ifndef SIMDJSON_GENERIC_ONDEMAND_ARRAY_ITERATOR_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_ARRAY_ITERATOR_H
5#include <iterator>
6#include "simdjson/generic/implementation_simdjson_result_base.h"
7#include "simdjson/generic/ondemand/base.h"
8#include "simdjson/generic/ondemand/value_iterator.h"
9#endif // SIMDJSON_CONDITIONAL_INCLUDE
10
11
12namespace simdjson {
13namespace SIMDJSON_IMPLEMENTATION {
14namespace ondemand {
15
25public:
26 using iterator_category = std::input_iterator_tag;
28 using difference_type = std::ptrdiff_t;
29 using pointer = void;
30 using reference = value_type;
31
33 simdjson_inline array_iterator() noexcept = default;
34
35#if SIMDJSON_DEVELOPMENT_CHECKS
36 simdjson_inline ~array_iterator() noexcept;
37
38 simdjson_inline array_iterator(array_iterator&&) noexcept;
39 simdjson_inline array_iterator& operator=(array_iterator&&) noexcept;
40 simdjson_inline array_iterator(const array_iterator&) noexcept;
41 simdjson_inline array_iterator& operator=(const array_iterator&) noexcept;
42#endif
43
44 //
45 // Iterator interface
46 //
47
53 simdjson_inline simdjson_result<value>
54 operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
62 simdjson_inline bool operator==(const array_iterator &) const noexcept;
70 simdjson_inline bool operator!=(const array_iterator &) const noexcept;
76 simdjson_inline array_iterator &operator++() noexcept;
77
81 simdjson_warn_unused simdjson_inline bool at_end() const noexcept;
82
83private:
84#if SIMDJSON_DEVELOPMENT_CHECKS
85 bool has_been_referenced{false};
86 array* parent{nullptr};
87
88 simdjson_inline array_iterator(const value_iterator &_iter, array* _parent) noexcept;
89#endif
90 value_iterator iter{};
91
92 simdjson_inline array_iterator(const value_iterator &iter) noexcept;
93
94 friend class array;
95 friend class value;
96 friend struct simdjson_result<array_iterator>;
97};
98
99} // namespace ondemand
100} // namespace SIMDJSON_IMPLEMENTATION
101} // namespace simdjson
102
103namespace simdjson {
104
105template<>
106struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> {
107 using iterator_category = std::input_iterator_tag;
108 using value_type = simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>;
109 using difference_type = std::ptrdiff_t;
110 using pointer = void;
111 using reference = value_type;
112
113 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::array_iterator &&value) noexcept;
114 simdjson_inline simdjson_result(error_code error) noexcept;
115 simdjson_inline simdjson_result() noexcept = default;
116
117 //
118 // Iterator interface
119 //
120
121 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
122 simdjson_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &) const noexcept;
123 simdjson_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &) const noexcept;
124 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &operator++() noexcept;
125
126 simdjson_warn_unused simdjson_inline bool at_end() const noexcept;
127};
128
129} // namespace simdjson
130
131#endif // SIMDJSON_GENERIC_ONDEMAND_ARRAY_ITERATOR_H
simdjson_inline simdjson_result< value > operator*() noexcept
Get the current element.
simdjson_inline array_iterator() noexcept=default
Create a new, invalid array iterator.
simdjson_warn_unused simdjson_inline bool at_end() const noexcept
Check if the array is at the end.
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8
error_code
All possible errors returned by simdjson.
Definition error.h:19
The result of a simdjson operation that could fail.
Definition error.h:281
simdjson_inline error_code error() const noexcept
The error.
Definition error-inl.h:168