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;
130#if SIMDJSON_SUPPORTS_CONCEPTS
131 template <
typename Func>
132 requires std::invocable<Func, value>
134 template <
typename Func>
153#if SIMDJSON_SUPPORTS_CONCEPTS
161 template <
typename T>
162 simdjson_warn_unused simdjson_inline
error_code get(T &out)
163 noexcept(custom_deserializable<T, array> ? nothrow_custom_deserializable<T, array> :
true) {
164 static_assert(custom_deserializable<T, array>);
165 return deserialize(*
this, out);
173 template <
typename T>
175 noexcept(custom_deserializable<T,
value> ? nothrow_custom_deserializable<T,
value> : true)
177 static_assert(std::is_default_constructible<T>::value,
"The specified type is not default constructible.");
179 SIMDJSON_TRY(get<T>(out));
223 simdjson_inline
array(const value_iterator &
iter) noexcept;
260#if SIMDJSON_SUPPORTS_CONCEPTS
261 template <
typename Func>
262 requires std::invocable<Func, SIMDJSON_IMPLEMENTATION::ondemand::value>
264 template <
typename Func>
266 simdjson_inline
error_code for_each_at_path_with_wildcard(std::string_view json_path, Func&& callback)
noexcept;
268#if SIMDJSON_SUPPORTS_CONCEPTS
274 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::array>) {
277 return first.get<T>();
280 simdjson_warn_unused simdjson_inline
error_code get(T& out)
noexcept {
282 if constexpr (std::is_same_v<T, SIMDJSON_IMPLEMENTATION::ondemand::array>) {
285 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_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 simdjson_result< array_iterator > begin() 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.