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"
12 namespace 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; }
45 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(
46 SIMDJSON_IMPLEMENTATION::ondemand::array_iterator &&value
48 : SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>(value))
50 first.iter.assert_is_valid();
52 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::simdjson_result(
error_code error) noexcept
53 : SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>({}, error)
57 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator*() noexcept {
61 simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator==(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other)
const noexcept {
62 if (!first.iter.is_valid()) {
return !error(); }
63 return first == other.first;
65 simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator!=(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &other)
const noexcept {
66 if (!first.iter.is_valid()) {
return error(); }
67 return first != other.first;
69 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> &simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator>::operator++() noexcept {
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.
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.
simdjson_inline error_code error() const noexcept
The error.