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 {
23#if SIMDJSON_DEVELOPMENT_CHECKS
25 : parent{_parent}, iter{_iter}
27 if (parent) parent->set_locked(
true);
31#if SIMDJSON_DEVELOPMENT_CHECKS
32simdjson_inline object_iterator::~object_iterator() noexcept
34 if (parent) parent->set_locked(
false);
38 : has_been_referenced{other.has_been_referenced},
40 iter{std::move(other.iter)}
42 other.parent =
nullptr;
45simdjson_inline object_iterator& object_iterator::operator=(object_iterator&& other)
noexcept {
49 parent->set_locked(
false);
50 has_been_referenced = other.has_been_referenced;
51 parent = other.parent;
52 iter = std::move(other.iter);
54 other.parent =
nullptr;
60 : has_been_referenced{other.has_been_referenced},
65simdjson_inline object_iterator& object_iterator::operator=(
const object_iterator& other)
noexcept {
69 parent->set_locked(
false);
70 has_been_referenced = other.has_been_referenced;
78simdjson_inline simdjson_result<field> object_iterator::operator*() noexcept {
79#if SIMDJSON_DEVELOPMENT_CHECKS
81 SIMDJSON_ASSUME(!has_been_referenced);
82 has_been_referenced =
true;
85 if (error) { iter.abandon();
return error; }
86 auto result = field::start(iter);
89 if (result.error()) { iter.abandon(); }
92simdjson_inline
bool object_iterator::operator==(
const object_iterator &other)
const noexcept {
93 return !(*
this != other);
95simdjson_inline
bool object_iterator::operator!=(
const object_iterator &)
const noexcept {
96 return iter.is_open();
99SIMDJSON_PUSH_DISABLE_WARNINGS
100SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING
101simdjson_inline object_iterator &object_iterator::operator++() noexcept {
102#if SIMDJSON_DEVELOPMENT_CHECKS
104 SIMDJSON_ASSUME(has_been_referenced);
105 has_been_referenced =
false;
109 if (!iter.is_open()) {
return *
this; }
112 if ((error = iter.skip_child() )) {
return *
this; }
114 simdjson_unused
bool has_value;
115 if ((error = iter.has_next_field().get(has_value) )) {
return *
this; };
118SIMDJSON_POP_DISABLE_WARNINGS
167simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::simdjson_result(
168 SIMDJSON_IMPLEMENTATION::ondemand::object_iterator &&value
170 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>(value))
172 first.iter.assert_is_valid();
174simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::simdjson_result(
error_code error) noexcept
175 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>({}, error)
179simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::field> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator*() noexcept {
180 if (error()) {
return error(); }
184simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator==(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other)
const noexcept {
185 if (!first.iter.is_valid()) {
return !error(); }
186 return first == other.first;
189simdjson_inline
bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator!=(
const simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &other)
const noexcept {
190 if (!first.iter.is_valid()) {
return error(); }
191 return first != other.first;
194simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator> &simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object_iterator>::operator++() noexcept {
196 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.