simdjson 4.1.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 simdjson_inline object_iterator &operator++() noexcept;
36
37private:
44 value_iterator iter{};
45
46 simdjson_inline object_iterator(const value_iterator &iter) noexcept;
47 friend struct simdjson_result<object_iterator>;
48 friend class object;
49};
50
51} // namespace ondemand
52} // namespace SIMDJSON_IMPLEMENTATION
53} // namespace simdjson
54
55namespace simdjson {
56
57template<>
58struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> {
59public:
60 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::object_iterator &&value) noexcept;
61 simdjson_inline simdjson_result(error_code error) noexcept;
62 simdjson_inline simdjson_result() noexcept = default;
63
64 //
65 // Iterator interface
66 //
67
68 // Reads key and value, yielding them to the user.
69 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
70 // Assumes it's being compared with the end. true if depth < iter->depth.
71 simdjson_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
72 // Assumes it's being compared with the end. true if depth >= iter->depth.
73 simdjson_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
74 // Checks for ']' and ','
75 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &operator++() noexcept;
76};
77
78} // namespace simdjson
79
80#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.
A forward-only JSON object field iterator.
Definition object.h:20
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:278
simdjson_inline error_code error() const noexcept
The error.
Definition error-inl.h:168