1#ifndef SIMDJSON_GENERIC_ONDEMAND_RANGES_H
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_RANGES_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/ondemand/array.h"
7#include "simdjson/generic/ondemand/array_iterator.h"
8#include "simdjson/generic/ondemand/object.h"
9#include "simdjson/generic/ondemand/object_iterator.h"
10#include "simdjson/generic/ondemand/field.h"
11#include "simdjson/generic/ondemand/value.h"
14#if SIMDJSON_SUPPORTS_RANGES
17namespace SIMDJSON_IMPLEMENTATION {
31class array_range_iterator {
33 using iterator_concept = std::input_iterator_tag;
34 using value_type = simdjson_result<value>;
35 using reference = simdjson_result<value>;
36 using difference_type = std::ptrdiff_t;
38 simdjson_inline array_range_iterator() noexcept = default;
39 simdjson_inline explicit array_range_iterator(array_iterator iter) noexcept;
45 simdjson_inline simdjson_result<value> operator*() const noexcept;
46 simdjson_inline array_range_iterator& operator++() noexcept;
47SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
48 simdjson_inline
void operator++(
int) noexcept;
49SIMDJSON_POP_DISABLE_WARNINGS
54 simdjson_inline friend
bool operator==(const array_range_iterator& a,
55 const array_range_iterator& b) noexcept {
56 return a.iter_ == b.iter_;
60 mutable array_iterator iter_{};
82 simdjson_inline array_range() noexcept = default;
83 simdjson_inline explicit array_range(array& arr) noexcept;
85 simdjson_inline array_range_iterator begin() noexcept;
86 simdjson_inline array_range_iterator end() noexcept;
89 simdjson_inline error_code error() const noexcept {
return error_; }
92 array_iterator begin_{};
93 array_iterator end_{};
103class object_range_iterator {
105 using iterator_concept = std::input_iterator_tag;
106 using value_type = simdjson_result<field>;
107 using reference = simdjson_result<field>;
108 using difference_type = std::ptrdiff_t;
110 simdjson_inline object_range_iterator() noexcept = default;
111 simdjson_inline explicit object_range_iterator(object_iterator iter) noexcept;
113 simdjson_inline simdjson_result<field> operator*() const noexcept;
114 simdjson_inline object_range_iterator& operator++() noexcept;
115SIMDJSON_PUSH_DISABLE_ALL_WARNINGS
116 simdjson_inline
void operator++(
int) noexcept;
117SIMDJSON_POP_DISABLE_WARNINGS
118 simdjson_inline friend
bool operator==(const object_range_iterator& a,
119 const object_range_iterator& b) noexcept {
120 return a.iter_ == b.iter_;
124 mutable object_iterator iter_{};
138 simdjson_inline object_range() noexcept = default;
139 simdjson_inline explicit object_range(
object& obj) noexcept;
141 simdjson_inline object_range_iterator begin() noexcept;
142 simdjson_inline object_range_iterator end() noexcept;
145 simdjson_inline error_code error() const noexcept {
return error_; }
148 object_iterator begin_{};
149 object_iterator end_{};
154simdjson_inline array_range get_range(array& arr)
noexcept;
157simdjson_inline object_range get_key_value_range(
object& obj)
noexcept;
159#if SIMDJSON_EXCEPTIONS
161simdjson_inline array_range get_range(simdjson_result<array> result);
164simdjson_inline object_range get_key_value_range(simdjson_result<object> result);
174inline constexpr bool enable_view<simdjson::SIMDJSON_IMPLEMENTATION::ondemand::array_range> =
true;
176inline constexpr bool enable_view<simdjson::SIMDJSON_IMPLEMENTATION::ondemand::object_range> =
true;
The top level simdjson namespace, containing everything the library provides.
error_code
All possible errors returned by simdjson.