simdjson  3.2.0
Ridiculously Fast JSON
array.h
1 #include "simdjson/error.h"
2 
3 namespace simdjson {
4 namespace SIMDJSON_IMPLEMENTATION {
5 namespace ondemand {
6 
7 class value;
8 class document;
9 
13 class array {
14 public:
20  simdjson_inline array() noexcept = default;
21 
27  simdjson_inline simdjson_result<array_iterator> begin() noexcept;
33  simdjson_inline simdjson_result<array_iterator> end() noexcept;
48  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
58  simdjson_inline simdjson_result<bool> is_empty() & noexcept;
69  inline simdjson_result<bool> reset() & noexcept;
98  inline simdjson_result<value> at_pointer(std::string_view json_pointer) noexcept;
103  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
104 
112  simdjson_inline simdjson_result<value> at(size_t index) noexcept;
113 protected:
117  simdjson_inline error_code consume() noexcept;
118 
126  static simdjson_inline simdjson_result<array> start(value_iterator &iter) noexcept;
135  static simdjson_inline simdjson_result<array> start_root(value_iterator &iter) noexcept;
144  static simdjson_inline simdjson_result<array> started(value_iterator &iter) noexcept;
145 
153  simdjson_inline array(const value_iterator &iter) noexcept;
154 
160  value_iterator iter{};
161 
162  friend class value;
163  friend class document;
164  friend struct simdjson_result<value>;
165  friend struct simdjson_result<array>;
166  friend class array_iterator;
167 };
168 
169 } // namespace ondemand
170 } // namespace SIMDJSON_IMPLEMENTATION
171 } // namespace simdjson
172 
173 namespace simdjson {
174 
175 template<>
176 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array> {
177 public:
179  simdjson_inline simdjson_result(error_code error) noexcept;
180  simdjson_inline simdjson_result() noexcept = default;
181 
184  inline simdjson_result<size_t> count_elements() & noexcept;
185  inline simdjson_result<bool> is_empty() & noexcept;
186  inline simdjson_result<bool> reset() & noexcept;
187  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at(size_t index) noexcept;
188  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_pointer(std::string_view json_pointer) noexcept;
189  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
190 
191 };
192 
193 } // namespace simdjson
simdjson_inline simdjson_result< value > at(size_t index) noexcept
Get the value at the given index.
Definition: array-inl.h:154
value_iterator iter
Iterator marking current position.
Definition: array.h:160
simdjson_inline simdjson_result< bool > is_empty() &noexcept
This method scans the beginning of the array and checks whether the array is empty.
Definition: array-inl.h:107
simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
Definition: array-inl.h:118
static simdjson_inline simdjson_result< array > start(value_iterator &iter) noexcept
Begin array iteration.
Definition: array-inl.h:48
simdjson_inline simdjson_result< array_iterator > begin() noexcept
Begin array iteration.
Definition: array-inl.h:66
simdjson_inline array() noexcept=default
Create a new invalid array.
simdjson_inline error_code consume() noexcept
Go to the end of the array, no matter where you are right now.
Definition: array-inl.h:75
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
Definition: array-inl.h:94
static simdjson_inline simdjson_result< array > start_root(value_iterator &iter) noexcept
Begin array iteration from the root.
Definition: array-inl.h:55
static simdjson_inline simdjson_result< array > started(value_iterator &iter) noexcept
Begin array iteration.
Definition: array-inl.h:60
simdjson_inline simdjson_result< std::string_view > raw_json() noexcept
Consumes the array and returns a string_view instance corresponding to the array as represented in JS...
Definition: array-inl.h:81
simdjson_inline simdjson_result< array_iterator > end() noexcept
Sentinel representing the end of the array.
Definition: array-inl.h:72
simdjson_result< bool > reset() &noexcept
Reset the iterator so that we are pointing back at the beginning of the array.
Definition: array-inl.h:114
An ephemeral JSON value returned during iteration.
Definition: value.h:17
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.