simdjson 4.4.0
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 //
24 // Iterator interface
25 //
26
27 // Reads key and value, yielding them to the user.
28 // MUST ONLY BE CALLED ONCE PER ITERATION.
29 simdjson_inline simdjson_result<field> operator*() noexcept;
30 // Assumes it's being compared with the end. true if depth < iter->depth.
31 simdjson_inline bool operator==(const object_iterator &) const noexcept;
32 // Assumes it's being compared with the end. true if depth >= iter->depth.
33 simdjson_inline bool operator!=(const object_iterator &) const noexcept;
34 // Checks for ']' and ','
35 // YOU MUST NOT CALL THIS IF operator* YIELDED AN ERROR.
36 // YOU MUST NOT CALL THIS WITHOUT A CORRESPONDING operator* CALL.
37 simdjson_inline object_iterator &operator++() noexcept;
38
39private:
40#if SIMDJSON_DEVELOPMENT_CHECKS
41 bool has_been_referenced{false};
42#endif
49 value_iterator iter{};
50
51 simdjson_inline object_iterator(const value_iterator &iter) noexcept;
52 friend struct simdjson_result<object_iterator>;
53 friend class object;
54};
55
56} // namespace ondemand
57} // namespace SIMDJSON_IMPLEMENTATION
58} // namespace simdjson
59
60namespace simdjson {
61
62template<>
63struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> {
64public:
65 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::object_iterator &&value) noexcept;
66 simdjson_inline simdjson_result(error_code error) noexcept;
67 simdjson_inline simdjson_result() noexcept = default;
68
69 //
70 // Iterator interface
71 //
72
73 // Reads key and value, yielding them to the user.
74 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
75 // Assumes it's being compared with the end. true if depth < iter->depth.
76 simdjson_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
77 // Assumes it's being compared with the end. true if depth >= iter->depth.
78 simdjson_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
79 // Checks for ']' and ','
80 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &operator++() noexcept;
81};
82
83} // namespace simdjson
84
85#endif // SIMDJSON_GENERIC_ONDEMAND_OBJECT_ITERATOR_H
A JSON field (key/value pair) in an object.
Definition field.h:22
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:280
simdjson_inline error_code error() const noexcept
The error.
Definition error-inl.h:168