1#ifndef SIMDJSON_GENERIC_ONDEMAND_ARRAY_H
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"
12namespace SIMDJSON_IMPLEMENTATION {
25 simdjson_inline
array() noexcept = default;
141#if SIMDJSON_SUPPORTS_CONCEPTS
142 template <
typename Func>
143 requires std::invocable<Func, value>
145 template <
typename Func>
164#if SIMDJSON_SUPPORTS_CONCEPTS
172 template <
typename T>
173 simdjson_warn_unused simdjson_inline
error_code get(T &out)
174 noexcept(nothrow_gettable<T, array>) {
175 static_assert(custom_deserializable<T, array>);
176 return deserialize(*
this, out);
184 template <
typename T>
186 noexcept(nothrow_gettable<T,
array>)
188 static_assert(std::is_default_constructible<T>::value,
"The specified type is not default constructible.");
190 SIMDJSON_TRY(get<T>(out));
234 simdjson_inline
array(const value_iterator &
iter) noexcept;
242#if SIMDJSON_DEVELOPMENT_CHECKS
244 simdjson_inline
void set_locked(
bool _locked)
noexcept;
248 friend class document;
251 friend class array_iterator;
276#if SIMDJSON_SUPPORTS_CONCEPTS
277 template <
typename Func>
278 requires std::invocable<Func, SIMDJSON_IMPLEMENTATION::ondemand::value>
280 template <
typename Func>
282 simdjson_inline
error_code for_each_at_path_with_wildcard(std::string_view json_path, Func&& callback)
noexcept;
284#if SIMDJSON_SUPPORTS_CONCEPTS
288 simdjson_inline
simdjson_result<T> get()
noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::array>) {
290 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::array>) {
293 return first.get<T>();
296 simdjson_warn_unused simdjson_inline
error_code get(T& out)
noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::array>) {
298 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::array>) {
301 SIMDJSON_TRY( first.get<T>(out) );
A forward-only JSON array.
A forward-only JSON array.
error_code for_each_at_path_with_wildcard(std::string_view json_path, Func &&callback) noexcept
Call the provided callback for each value matching the given JSONPath expression with wildcard suppor...
simdjson_inline simdjson_result< value > at(size_t index) noexcept
Get the value at the given index.
value_iterator iter
Iterator marking current position.
simdjson_inline simdjson_result< bool > is_empty() &noexcept
This method scans the beginning of the array and checks whether the array is empty.
simdjson_inline simdjson_result< array_iterator > begin() &noexcept
Begin array iteration.
simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
static simdjson_inline simdjson_result< array > start(value_iterator &iter) noexcept
Begin array iteration.
simdjson_inline array() noexcept=default
Create a new invalid array.
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
simdjson_result< value > at_path(std::string_view json_path) noexcept
Get the value associated with the given JSONPath expression.
static simdjson_inline simdjson_result< array > start_root(value_iterator &iter) noexcept
Begin array iteration from the root.
static simdjson_inline simdjson_result< array > started(value_iterator &iter) noexcept
Begin array iteration.
simdjson_warn_unused simdjson_inline error_code consume() noexcept
Go to the end of the array, no matter where you are right now.
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...
simdjson_inline simdjson_result< array_iterator > end() noexcept
Sentinel representing the end of the array.
simdjson_result< bool > reset() &noexcept
Reset the iterator so that we are pointing back at the beginning of the array.
An ephemeral JSON value returned during iteration.
The top level simdjson namespace, containing everything the library provides.
error_code
All possible errors returned by simdjson.
The result of a simdjson operation that could fail.
The result of a simdjson operation that could fail.
simdjson_inline error_code error() const noexcept
The error.
simdjson_warn_unused simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.