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 (iter.error()) { iter.abandon();
return iter.error(); }
21 return value(iter.child());
24 return !(*
this !=
other);
27 return iter.is_open();
33 if (( error = iter.error() )) {
return *
this; }
34 if (( error = iter.skip_child() )) {
return *
this; }
35 if (( error = iter.has_next_element().error() )) {
return *
this; }
48simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(
49 SIMDJSON_IMPLEMENTATION::ondemand::array_iterator &&value
51 : SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>(value))
53 first.iter.assert_is_valid();
55simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(
error_code error) noexcept
56 : SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>({}, error)
60simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator*() noexcept {
61 if (error()) {
return error(); }
64simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator==(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other)
const noexcept {
65 if (!first.iter.is_valid()) {
return !error(); }
66 return first == other.first;
68simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator!=(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other)
const noexcept {
69 if (!first.iter.is_valid()) {
return error(); }
70 return first != other.first;
72simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator++() noexcept {
74 if (error()) { second =
SUCCESS;
return *
this; }
78simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::at_end() const noexcept {
79 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.
A forward-only JSON 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.