2 namespace SIMDJSON_IMPLEMENTATION {
51 simdjson_unused
bool has_value;
52 SIMDJSON_TRY( iter.start_array().get(has_value) );
56 simdjson_unused
bool has_value;
57 SIMDJSON_TRY( iter.start_root_array().get(has_value) );
62 SIMDJSON_TRY(iter.started_array().get(has_value));
67 #if SIMDJSON_DEVELOPMENT_CHECKS
76 auto error =
iter.json_iter().skip_child(
iter.depth()-1);
77 if(error) {
iter.abandon(); }
82 const uint8_t * starting_point{
iter.peek_start()};
84 if(error) {
return error; }
88 const uint8_t * final_point{
iter._json_iter->unsafe_pointer()};
89 return std::string_view(
reinterpret_cast<const char*
>(starting_point),
size_t(final_point - starting_point));
92 SIMDJSON_PUSH_DISABLE_WARNINGS
93 SIMDJSON_DISABLE_STRICT_OVERFLOW_WARNING
97 for(simdjson_unused
auto v : *
this) { count++; }
99 if(iter.error()) {
return iter.error(); }
105 SIMDJSON_POP_DISABLE_WARNINGS
109 auto error = iter.reset_array().get(is_not_empty);
110 if(error) {
return error; }
111 return !is_not_empty;
115 return iter.reset_array();
120 json_pointer = json_pointer.substr(1);
126 size_t array_index = 0;
128 for (i = 0; i < json_pointer.length() && json_pointer[i] !=
'/'; i++) {
129 uint8_t digit = uint8_t(json_pointer[i] -
'0');
132 array_index = array_index*10 + digit;
141 auto child = at(array_index);
148 if (i < json_pointer.length()) {
149 child = child.at_pointer(json_pointer.substr(i));
156 for (
auto value : *
this) {
157 if (i == index) {
return value; }
169 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::simdjson_result(
170 SIMDJSON_IMPLEMENTATION::ondemand::array &&value
172 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array>(
173 std::forward<SIMDJSON_IMPLEMENTATION::ondemand::array>(value)
177 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::simdjson_result(
180 : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::array>(error)
184 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::begin() noexcept {
186 return first.begin();
188 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::end() noexcept {
192 simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::count_elements() & noexcept {
193 if (error()) {
return error(); }
194 return first.count_elements();
196 simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::is_empty() & noexcept {
197 if (error()) {
return error(); }
198 return first.is_empty();
200 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::at(
size_t index) noexcept {
201 if (error()) {
return error(); }
202 return first.at(index);
204 simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array>::at_pointer(std::string_view json_pointer) noexcept {
205 if (error()) {
return error(); }
206 return first.at_pointer(json_pointer);
A forward-only JSON array.
A forward-only JSON array.
simdjson_inline simdjson_result< value > at(size_t index) noexcept
Get the value at the given index.
value_iterator iter
Iterator marking current position.
simdjson_inline simdjson_result< bool > is_empty() &noexcept
This method scans the beginning of the array and checks whether the array is empty.
simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
static simdjson_inline simdjson_result< array > start(value_iterator &iter) noexcept
Begin array iteration.
simdjson_inline simdjson_result< array_iterator > begin() noexcept
Begin array iteration.
simdjson_inline array() noexcept=default
Create a new invalid array.
simdjson_inline error_code consume() noexcept
Go to the end of the array, no matter where you are right now.
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
static simdjson_inline simdjson_result< array > start_root(value_iterator &iter) noexcept
Begin array iteration from the root.
static simdjson_inline simdjson_result< array > started(value_iterator &iter) noexcept
Begin array iteration.
simdjson_inline simdjson_result< std::string_view > raw_json() noexcept
Consumes the array and returns a string_view instance corresponding to the array as represented in JS...
simdjson_inline simdjson_result< array_iterator > end() noexcept
Sentinel representing the end of the array.
simdjson_result< bool > reset() &noexcept
Reset the iterator so that we are pointing back at the beginning of the array.
An ephemeral JSON value returned during iteration.
We want to support argument-dependent lookup (ADL).
error_code
All possible errors returned by simdjson.
@ INCORRECT_TYPE
JSON element has a different type than user expected.
@ OUT_OF_ORDER_ITERATION
tried to iterate an array or object out of order
@ INDEX_OUT_OF_BOUNDS
JSON array index too large.
@ INVALID_JSON_POINTER
Invalid JSON pointer reference.
The result of a simdjson operation that could fail.
simdjson_inline error_code error() const noexcept
The error.