simdjson 5.0.2
Ridiculously Fast JSON
Loading...
Searching...
No Matches
object_iterator.h
1#ifndef SIMDJSON_GENERIC_ONDEMAND_OBJECT_ITERATOR_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_OBJECT_ITERATOR_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/implementation_simdjson_result_base.h"
7#include "simdjson/generic/ondemand/value_iterator.h"
8#endif // SIMDJSON_CONDITIONAL_INCLUDE
9
10namespace simdjson {
11namespace SIMDJSON_IMPLEMENTATION {
12namespace ondemand {
13
15public:
21 simdjson_inline object_iterator() noexcept = default;
22
23#if SIMDJSON_DEVELOPMENT_CHECKS
24 simdjson_inline ~object_iterator() noexcept;
25
26 simdjson_inline object_iterator(object_iterator&&) noexcept;
27 simdjson_inline object_iterator& operator=(object_iterator&&) noexcept;
28 simdjson_inline object_iterator(const object_iterator&) noexcept;
29 simdjson_inline object_iterator& operator=(const object_iterator&) noexcept;
30#endif
31
32 //
33 // Iterator interface
34 //
35
36 // Reads key and value, yielding them to the user.
37 // MUST ONLY BE CALLED ONCE PER ITERATION.
38 simdjson_inline simdjson_result<field> operator*() noexcept;
39 // Assumes it's being compared with the end. true if depth < iter->depth.
40 simdjson_inline bool operator==(const object_iterator &) const noexcept;
41 // Assumes it's being compared with the end. true if depth >= iter->depth.
42 simdjson_inline bool operator!=(const object_iterator &) const noexcept;
43 // Checks for ']' and ','
44 // YOU MUST NOT CALL THIS IF operator* YIELDED AN ERROR.
45 // YOU MUST NOT CALL THIS WITHOUT A CORRESPONDING operator* CALL.
46 simdjson_inline object_iterator &operator++() noexcept;
47
48private:
49#if SIMDJSON_DEVELOPMENT_CHECKS
50 bool has_been_referenced{false};
51 object* parent{nullptr};
52
53 simdjson_inline object_iterator(const value_iterator &_iter, object* _parent) noexcept;
54#endif
61 value_iterator iter{};
62
63 simdjson_inline object_iterator(const value_iterator &iter) noexcept;
64 friend struct simdjson_result<object_iterator>;
65 friend class object;
66};
67
68} // namespace ondemand
69} // namespace SIMDJSON_IMPLEMENTATION
70} // namespace simdjson
71
72namespace simdjson {
73
74template<>
75struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> {
76public:
77 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::object_iterator &&value) noexcept;
78 simdjson_inline simdjson_result(error_code error) noexcept;
79 simdjson_inline simdjson_result() noexcept = default;
80
81 //
82 // Iterator interface
83 //
84
85 // Reads key and value, yielding them to the user.
86 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
87 // Assumes it's being compared with the end. true if depth < iter->depth.
88 simdjson_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
89 // Assumes it's being compared with the end. true if depth >= iter->depth.
90 simdjson_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
91 // Checks for ']' and ','
92 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &operator++() noexcept;
93};
94
95} // namespace simdjson
96
97#endif // SIMDJSON_GENERIC_ONDEMAND_OBJECT_ITERATOR_H
simdjson_inline object_iterator() noexcept=default
Create a new invalid object_iterator.
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