simdjson  3.9.4
Ridiculously Fast JSON
array.h
1 #ifndef SIMDJSON_GENERIC_ONDEMAND_ARRAY_H
2 
3 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
4 #define SIMDJSON_GENERIC_ONDEMAND_ARRAY_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 
10 namespace simdjson {
11 namespace SIMDJSON_IMPLEMENTATION {
12 namespace ondemand {
13 
17 class array {
18 public:
24  simdjson_inline array() noexcept = default;
25 
31  simdjson_inline simdjson_result<array_iterator> begin() noexcept;
37  simdjson_inline simdjson_result<array_iterator> end() noexcept;
52  simdjson_inline simdjson_result<size_t> count_elements() & noexcept;
62  simdjson_inline simdjson_result<bool> is_empty() & noexcept;
73  inline simdjson_result<bool> reset() & noexcept;
102  inline simdjson_result<value> at_pointer(std::string_view json_pointer) noexcept;
103 
117  inline simdjson_result<value> at_path(std::string_view json_path) noexcept;
118 
123  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
124 
132  simdjson_inline simdjson_result<value> at(size_t index) noexcept;
133 protected:
137  simdjson_inline error_code consume() noexcept;
138 
146  static simdjson_inline simdjson_result<array> start(value_iterator &iter) noexcept;
155  static simdjson_inline simdjson_result<array> start_root(value_iterator &iter) noexcept;
164  static simdjson_inline simdjson_result<array> started(value_iterator &iter) noexcept;
165 
173  simdjson_inline array(const value_iterator &iter) noexcept;
174 
180  value_iterator iter{};
181 
182  friend class value;
183  friend class document;
184  friend struct simdjson_result<value>;
185  friend struct simdjson_result<array>;
186  friend class array_iterator;
187 };
188 
189 } // namespace ondemand
190 } // namespace SIMDJSON_IMPLEMENTATION
191 } // namespace simdjson
192 
193 namespace simdjson {
194 
195 template<>
196 struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> : public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array> {
197 public:
199  simdjson_inline simdjson_result(error_code error) noexcept;
200  simdjson_inline simdjson_result() noexcept = default;
201 
204  inline simdjson_result<size_t> count_elements() & noexcept;
205  inline simdjson_result<bool> is_empty() & noexcept;
206  inline simdjson_result<bool> reset() & noexcept;
207  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at(size_t index) noexcept;
208  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_pointer(std::string_view json_pointer) noexcept;
209  simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> at_path(std::string_view json_path) noexcept;
210  simdjson_inline simdjson_result<std::string_view> raw_json() noexcept;
211 
212 };
213 
214 } // namespace simdjson
215 
216 #endif // SIMDJSON_GENERIC_ONDEMAND_ARRAY_H
simdjson_inline simdjson_result< value > at(size_t index) noexcept
Get the value at the given index.
Definition: array-inl.h:219
value_iterator iter
Iterator marking current position.
Definition: array.h:180
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:119
simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
Definition: array-inl.h:130
static simdjson_inline simdjson_result< array > start(value_iterator &iter) noexcept
Begin array iteration.
Definition: array-inl.h:60
simdjson_inline simdjson_result< array_iterator > begin() noexcept
Begin array iteration.
Definition: array-inl.h:78
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:87
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
Definition: array-inl.h:106
simdjson_result< value > at_path(std::string_view json_path) noexcept
Get the value associated with the given JSONPath expression.
Definition: array-inl.h:213
static simdjson_inline simdjson_result< array > start_root(value_iterator &iter) noexcept
Begin array iteration from the root.
Definition: array-inl.h:67
static simdjson_inline simdjson_result< array > started(value_iterator &iter) noexcept
Begin array iteration.
Definition: array-inl.h:72
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:93
simdjson_inline simdjson_result< array_iterator > end() noexcept
Sentinel representing the end of the array.
Definition: array-inl.h:84
simdjson_result< bool > reset() &noexcept
Reset the iterator so that we are pointing back at the beginning of the array.
Definition: array-inl.h:126
An ephemeral JSON value returned during iteration.
Definition: value.h:18
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:215
simdjson_inline error_code error() const noexcept
The error.
Definition: error-inl.h:131
simdjson_inline T & value() &noexcept(false)
Get the result value.