simdjson 4.4.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 //
36 // Iterator interface
37 //
38
44 simdjson_inline simdjson_result<value>
45 operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
53 simdjson_inline bool operator==(const array_iterator &) const noexcept;
61 simdjson_inline bool operator!=(const array_iterator &) const noexcept;
67 simdjson_inline array_iterator &operator++() noexcept;
68
72 simdjson_warn_unused simdjson_inline bool at_end() const noexcept;
73
74private:
75#if SIMDJSON_DEVELOPMENT_CHECKS
76 bool has_been_referenced{false};
77#endif
78 value_iterator iter{};
79
80 simdjson_inline array_iterator(const value_iterator &iter) noexcept;
81
82 friend class array;
83 friend class value;
84 friend struct simdjson_result<array_iterator>;
85};
86
87} // namespace ondemand
88} // namespace SIMDJSON_IMPLEMENTATION
89} // namespace simdjson
90
91namespace simdjson {
92
93template<>
94struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> {
95 using iterator_category = std::input_iterator_tag;
96 using value_type = simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value>;
97 using difference_type = std::ptrdiff_t;
98 using pointer = void;
99 using reference = value_type;
100
101 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::array_iterator &&value) noexcept;
102 simdjson_inline simdjson_result(error_code error) noexcept;
103 simdjson_inline simdjson_result() noexcept = default;
104
105 //
106 // Iterator interface
107 //
108
109 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
110 simdjson_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &) const noexcept;
111 simdjson_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &) const noexcept;
112 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &operator++() noexcept;
113
114 simdjson_warn_unused simdjson_inline bool at_end() const noexcept;
115};
116
117} // namespace simdjson
118
119#endif // SIMDJSON_GENERIC_ONDEMAND_ARRAY_ITERATOR_H
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.
An ephemeral JSON value returned during iteration.
Definition value.h:22
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:280
simdjson_inline error_code error() const noexcept
The error.
Definition error-inl.h:168