1#ifndef SIMDJSON_GENERIC_ONDEMAND_OBJECT_ITERATOR_INL_H
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_OBJECT_ITERATOR_INL_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/ondemand/object_iterator.h"
7#include "simdjson/generic/ondemand/field-inl.h"
8#include "simdjson/generic/ondemand/value_iterator-inl.h"
12namespace SIMDJSON_IMPLEMENTATION {
23simdjson_inline simdjson_result<field> object_iterator::operator*() noexcept {
24#if SIMDJSON_DEVELOPMENT_CHECKS
26 SIMDJSON_ASSUME(!has_been_referenced);
27 has_been_referenced =
true;
30 if (error) { iter.abandon();
return error; }
31 auto result = field::start(iter);
34 if (result.error()) { iter.abandon(); }
37simdjson_inline
bool object_iterator::operator==(
const object_iterator &other)
const noexcept {
38 return !(*
this != other);
40simdjson_inline
bool object_iterator::operator!=(
const object_iterator &)
const noexcept {
41 return iter.is_open();
44SIMDJSON_PUSH_DISABLE_WARNINGS
45SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING
46simdjson_inline object_iterator &object_iterator::operator++() noexcept {
47#if SIMDJSON_DEVELOPMENT_CHECKS
49 SIMDJSON_ASSUME(has_been_referenced);
50 has_been_referenced =
false;
54 if (!iter.is_open()) {
return *
this; }
57 if ((error = iter.skip_child() )) {
return *
this; }
59 simdjson_unused
bool has_value;
60 if ((error = iter.has_next_field().get(has_value) )) {
return *
this; };
63SIMDJSON_POP_DISABLE_WARNINGS
112simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::simdjson_result(
113 SIMDJSON_IMPLEMENTATION::ondemand::object_iterator &&value
115 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>(value))
117 first.iter.assert_is_valid();
119simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::simdjson_result(
error_code error) noexcept
120 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>({}, error)
124simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator*() noexcept {
125 if (error()) {
return error(); }
129simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator==(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other)
const noexcept {
130 if (!first.iter.is_valid()) {
return !error(); }
131 return first == other.first;
134simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator!=(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other)
const noexcept {
135 if (!first.iter.is_valid()) {
return error(); }
136 return first != other.first;
139simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator++() noexcept {
141 if (error()) { second =
SUCCESS;
return *
this; }
simdjson_inline object_iterator() noexcept=default
Create a new invalid object_iterator.
The top level simdjson namespace, containing everything the library provides.
error_code
All possible errors returned by simdjson.