simdjson  3.1.6
Ridiculously Fast JSON
object_iterator.h
1 #include "simdjson/error.h"
2 
3 namespace simdjson {
4 namespace SIMDJSON_IMPLEMENTATION {
5 namespace ondemand {
6 
7 class field;
8 
10 public:
16  simdjson_inline object_iterator() noexcept = default;
17 
18  //
19  // Iterator interface
20  //
21 
22  // Reads key and value, yielding them to the user.
23  // MUST ONLY BE CALLED ONCE PER ITERATION.
24  simdjson_inline simdjson_result<field> operator*() noexcept;
25  // Assumes it's being compared with the end. true if depth < iter->depth.
26  simdjson_inline bool operator==(const object_iterator &) const noexcept;
27  // Assumes it's being compared with the end. true if depth >= iter->depth.
28  simdjson_inline bool operator!=(const object_iterator &) const noexcept;
29  // Checks for ']' and ','
30  simdjson_inline object_iterator &operator++() noexcept;
31 
32 private:
39  value_iterator iter{};
40 
41  simdjson_inline object_iterator(const value_iterator &iter) noexcept;
42  friend struct simdjson_result<object_iterator>;
43  friend class object;
44 };
45 
46 } // namespace ondemand
47 } // namespace SIMDJSON_IMPLEMENTATION
48 } // namespace simdjson
49 
50 namespace simdjson {
51 
52 template<>
53 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> {
54 public:
56  simdjson_inline simdjson_result(error_code error) noexcept;
57  simdjson_inline simdjson_result() noexcept = default;
58 
59  //
60  // Iterator interface
61  //
62 
63  // Reads key and value, yielding them to the user.
64  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> operator*() noexcept; // MUST ONLY BE CALLED ONCE PER ITERATION.
65  // Assumes it's being compared with the end. true if depth < iter->depth.
66  simdjson_inline bool operator==(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
67  // Assumes it's being compared with the end. true if depth >= iter->depth.
68  simdjson_inline bool operator!=(const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &) const noexcept;
69  // Checks for ']' and ','
70  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &operator++() noexcept;
71 };
72 
73 } // namespace simdjson
A JSON field (key/value pair) in an object.
Definition: field.h:14
simdjson_inline object_iterator() noexcept=default
Create a new invalid object_iterator.
A forward-only JSON object field iterator.
Definition: object.h:10
We want to support argument-dependent lookup (ADL).
error_code
All possible errors returned by simdjson.
Definition: error.h:17
The result of a simdjson operation that could fail.
Definition: error.h:205
simdjson_inline error_code error() const noexcept
The error.
Definition: error-inl.h:132
simdjson_inline T & value() &noexcept(false)
Get the result value.