1#ifndef SIMDJSON_GENERIC_ONDEMAND_ARRAY_ITERATOR_INL_H
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_ARRAY_ITERATOR_INL_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/ondemand/array_iterator.h"
7#include "simdjson/generic/ondemand/value-inl.h"
8#include "simdjson/generic/ondemand/value_iterator-inl.h"
12namespace SIMDJSON_IMPLEMENTATION {
20#if SIMDJSON_DEVELOPMENT_CHECKS
21 SIMDJSON_ASSUME(!has_been_referenced);
22 has_been_referenced =
true;
24 if (iter.error()) { iter.abandon();
return iter.error(); }
25 return value(iter.child());
28 return !(*
this != other);
31 return iter.is_open();
34#if SIMDJSON_DEVELOPMENT_CHECKS
35 has_been_referenced =
false;
40 if (( error = iter.error() )) {
return *
this; }
41 if (( error = iter.skip_child() )) {
return *
this; }
42 if (( error = iter.has_next_element().error() )) {
return *
this; }
55simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(
56 SIMDJSON_IMPLEMENTATION::ondemand::array_iterator &&value
58 : SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>(value))
60 first.iter.assert_is_valid();
62simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(
error_code error) noexcept
63 : SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>({}, error)
67simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator*() noexcept {
68 if (error()) {
return error(); }
71simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator==(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other)
const noexcept {
72 if (!first.iter.is_valid()) {
return !error(); }
73 return first == other.first;
75simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator!=(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other)
const noexcept {
76 if (!first.iter.is_valid()) {
return error(); }
77 return first != other.first;
79simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator++() noexcept {
81 if (error()) { second =
SUCCESS;
return *
this; }
85simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::at_end() const noexcept {
86 return !first.iter.is_valid() || first.at_end();
A forward-only JSON array.
simdjson_inline simdjson_result< value > operator*() noexcept
Get the current element.
simdjson_inline bool operator==(const array_iterator &) const noexcept
Check if we are at the end of the JSON.
simdjson_inline array_iterator & operator++() noexcept
Move to the next element.
simdjson_inline array_iterator() noexcept=default
Create a new, invalid array iterator.
simdjson_inline bool operator!=(const array_iterator &) const noexcept
Check if there are more elements in the JSON array.
simdjson_warn_unused simdjson_inline bool at_end() const noexcept
Check if the array is at the end.
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.