simdjson 5.0.2
Ridiculously Fast JSON
Loading...
Searching...
No Matches
document-inl.h
1#ifndef SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_INL_H
2
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_INL_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/ondemand/array_iterator.h"
7#include "simdjson/generic/ondemand/document.h"
8#include "simdjson/generic/ondemand/json_type.h"
9#include "simdjson/generic/ondemand/raw_json_string.h"
10#include "simdjson/generic/ondemand/value.h"
11#include "simdjson/generic/ondemand/value-inl.h"
12#include "simdjson/generic/ondemand/array-inl.h"
13#include "simdjson/generic/ondemand/json_iterator-inl.h"
14#include "simdjson/generic/ondemand/object-inl.h"
15#include "simdjson/generic/ondemand/value_iterator-inl.h"
16#include "simdjson/generic/ondemand/deserialize.h"
17#endif // SIMDJSON_CONDITIONAL_INCLUDE
18
19#include <limits>
20
21namespace simdjson {
22namespace SIMDJSON_IMPLEMENTATION {
23namespace ondemand {
24
25simdjson_inline document::document(ondemand::json_iterator &&_iter) noexcept
26 : iter{std::forward<json_iterator>(_iter)}
27{
28 logger::log_start_value(iter, "document");
29}
30
31simdjson_inline document document::start(json_iterator &&iter) noexcept {
32 return document(std::forward<json_iterator>(iter));
33}
34
35inline void document::rewind() noexcept {
36 iter.rewind();
37}
38
39inline std::string document::to_debug_string() noexcept {
40 return iter.to_string();
41}
42
44 return iter.current_location();
45}
46
47inline int32_t document::current_depth() const noexcept {
48 return iter.depth();
49}
50
51inline bool document::at_end() const noexcept {
52 return iter.at_end();
53}
54
55
56inline bool document::is_alive() noexcept {
57 return iter.is_alive();
58}
59simdjson_inline value_iterator document::resume_value_iterator() noexcept {
60 return value_iterator(&iter, 1, iter.root_position());
61}
62simdjson_inline value_iterator document::get_root_value_iterator() noexcept {
63 return resume_value_iterator();
64}
65simdjson_inline simdjson_result<object> document::start_or_resume_object() noexcept {
66 if (iter.at_root()) {
67 return get_object();
68 } else {
69 return object::resume(resume_value_iterator());
70 }
71}
72simdjson_inline simdjson_result<value> document::get_value() noexcept {
73 // Make sure we start any arrays or objects before returning, so that start_root_<object/array>()
74 // gets called.
75
76 // It is the convention throughout the code that the macro `SIMDJSON_DEVELOPMENT_CHECKS` determines whether
77 // we check for OUT_OF_ORDER_ITERATION. Proper on::demand code should never trigger this error.
78#if SIMDJSON_DEVELOPMENT_CHECKS
79 if (!iter.at_root()) { return OUT_OF_ORDER_ITERATION; }
80#endif
81 // assert_at_root() serves two purposes: in Debug mode, whether or not
82 // SIMDJSON_DEVELOPMENT_CHECKS is set or not, it checks that we are at the root of
83 // the document (this will typically be redundant). In release mode, it generates
84 // SIMDJSON_ASSUME statements to allow the compiler to make assumptions.
85 iter.assert_at_root();
86 switch (*iter.peek()) {
87 case '[': {
88 // The following lines check that the document ends with ].
89 auto value_iterator = get_root_value_iterator();
90 auto error = value_iterator.check_root_array();
91 if(error) { return error; }
92 return value(get_root_value_iterator());
93 }
94 case '{': {
95 // The following lines would check that the document ends with }.
96 auto value_iterator = get_root_value_iterator();
97 auto error = value_iterator.check_root_object();
98 if(error) { return error; }
99 return value(get_root_value_iterator());
100 }
101 default:
102 // Unfortunately, scalar documents are a special case in simdjson and they cannot
103 // be safely converted to value instances.
105 }
106}
107simdjson_inline simdjson_result<array> document::get_array() & noexcept {
108 auto value = get_root_value_iterator();
109 return array::start_root(value);
110}
111simdjson_inline simdjson_result<object> document::get_object() & noexcept {
112 auto value = get_root_value_iterator();
113 return object::start_root(value);
114}
115
125 return get_root_value_iterator().get_root_uint64(true);
126}
128 return get_root_value_iterator().get_root_uint64_in_string(true);
129}
131 return get_root_value_iterator().get_root_int64(true);
132}
134 return get_root_value_iterator().get_root_int64_in_string(true);
135}
137 return narrow_integer<uint32_t>(get_uint64());
138}
140 return narrow_integer<int32_t>(get_int64());
141}
143 return narrow_integer<uint16_t>(get_uint64());
144}
146 return narrow_integer<int16_t>(get_int64());
147}
149 return narrow_integer<uint8_t>(get_uint64());
150}
151simdjson_inline simdjson_result<int8_t> document::get_int8() noexcept {
152 return narrow_integer<int8_t>(get_int64());
153}
155 return get_root_value_iterator().get_root_double(true);
156}
158 return get_root_value_iterator().get_root_double_in_string(true);
159}
160simdjson_inline simdjson_result<float> document::get_float() noexcept {
161 return get_root_value_iterator().get_root_float(true);
162}
164 return get_root_value_iterator().get_root_float_in_string(true);
165}
166#if SIMDJSON_SUPPORTS_FLOAT32_T
167simdjson_inline simdjson_result<std::float32_t> document::get_float32() noexcept {
168 float result;
169 SIMDJSON_TRY(get_float().get(result));
170 return static_cast<std::float32_t>(result);
171}
172#endif // SIMDJSON_SUPPORTS_FLOAT32_T
173#if SIMDJSON_SUPPORTS_FLOAT64_T
174simdjson_inline simdjson_result<std::float64_t> document::get_float64() noexcept {
175 double result;
176 SIMDJSON_TRY(get_double().get(result));
177 return static_cast<std::float64_t>(result);
178}
179#endif // SIMDJSON_SUPPORTS_FLOAT64_T
180simdjson_inline simdjson_result<std::string_view> document::get_string(bool allow_replacement) noexcept {
181 return get_root_value_iterator().get_root_string(true, allow_replacement);
182}
183#if SIMDJSON_SUPPORTS_CHAR8_T
184simdjson_inline simdjson_result<std::u8string_view> document::get_u8string(bool allow_replacement) noexcept {
185 std::string_view content;
186 SIMDJSON_TRY( get_string(allow_replacement).get(content) );
187 return internal::as_u8string_view(content);
188}
189#endif // SIMDJSON_SUPPORTS_CHAR8_T
190template <typename string_type>
191simdjson_warn_unused simdjson_inline error_code document::get_string(string_type& receiver, bool allow_replacement) noexcept {
192 return get_root_value_iterator().get_root_string(receiver, true, allow_replacement);
193}
195 return get_root_value_iterator().get_root_wobbly_string(true);
196}
198 return get_root_value_iterator().get_root_raw_json_string(true);
199}
200simdjson_inline simdjson_result<bool> document::get_bool() noexcept {
201 return get_root_value_iterator().get_root_bool(true);
202}
203simdjson_inline simdjson_result<bool> document::is_null() noexcept {
204 return get_root_value_iterator().is_root_null(true);
205}
206
207template<> simdjson_inline simdjson_result<array> document::get() & noexcept { return get_array(); }
208template<> simdjson_inline simdjson_result<object> document::get() & noexcept { return get_object(); }
209template<> simdjson_inline simdjson_result<raw_json_string> document::get() & noexcept { return get_raw_json_string(); }
210template<> simdjson_inline simdjson_result<std::string_view> document::get() & noexcept { return get_string(false); }
211#if SIMDJSON_SUPPORTS_CHAR8_T
212template<> simdjson_inline simdjson_result<std::u8string_view> document::get() & noexcept { return get_u8string(false); }
213#endif // SIMDJSON_SUPPORTS_CHAR8_T
214template<> simdjson_inline simdjson_result<double> document::get() & noexcept { return get_double(); }
215template<> simdjson_inline simdjson_result<float> document::get() & noexcept { return get_float(); }
216template<> simdjson_inline simdjson_result<uint64_t> document::get() & noexcept { return get_uint64(); }
217template<> simdjson_inline simdjson_result<int64_t> document::get() & noexcept { return get_int64(); }
218template<> simdjson_inline simdjson_result<uint32_t> document::get() & noexcept { return get_uint32(); }
219template<> simdjson_inline simdjson_result<int32_t> document::get() & noexcept { return get_int32(); }
220template<> simdjson_inline simdjson_result<uint16_t> document::get() & noexcept { return get_uint16(); }
221template<> simdjson_inline simdjson_result<int16_t> document::get() & noexcept { return get_int16(); }
222template<> simdjson_inline simdjson_result<uint8_t> document::get() & noexcept { return get_uint8(); }
223template<> simdjson_inline simdjson_result<int8_t> document::get() & noexcept { return get_int8(); }
224#if SIMDJSON_SUPPORTS_FLOAT32_T
225template<> simdjson_inline simdjson_result<std::float32_t> document::get() & noexcept { return get_float32(); }
226#endif // SIMDJSON_SUPPORTS_FLOAT32_T
227#if SIMDJSON_SUPPORTS_FLOAT64_T
228template<> simdjson_inline simdjson_result<std::float64_t> document::get() & noexcept { return get_float64(); }
229#endif // SIMDJSON_SUPPORTS_FLOAT64_T
230template<> simdjson_inline simdjson_result<bool> document::get() & noexcept { return get_bool(); }
231template<> simdjson_inline simdjson_result<value> document::get() & noexcept { return get_value(); }
232
233template<> simdjson_warn_unused simdjson_inline error_code document::get(array& out) & noexcept { return get_array().get(out); }
234template<> simdjson_warn_unused simdjson_inline error_code document::get(object& out) & noexcept { return get_object().get(out); }
235template<> simdjson_warn_unused simdjson_inline error_code document::get(raw_json_string& out) & noexcept { return get_raw_json_string().get(out); }
236template<> simdjson_warn_unused simdjson_inline error_code document::get(std::string_view& out) & noexcept { return get_string(false).get(out); }
237#if SIMDJSON_SUPPORTS_CHAR8_T
238template<> simdjson_warn_unused simdjson_inline error_code document::get(std::u8string_view& out) & noexcept { return get_u8string(false).get(out); }
239#endif // SIMDJSON_SUPPORTS_CHAR8_T
240template<> simdjson_warn_unused simdjson_inline error_code document::get(double& out) & noexcept { return get_double().get(out); }
241template<> simdjson_warn_unused simdjson_inline error_code document::get(float& out) & noexcept { return get_float().get(out); }
242template<> simdjson_warn_unused simdjson_inline error_code document::get(uint64_t& out) & noexcept { return get_uint64().get(out); }
243template<> simdjson_warn_unused simdjson_inline error_code document::get(int64_t& out) & noexcept { return get_int64().get(out); }
244template<> simdjson_warn_unused simdjson_inline error_code document::get(uint32_t& out) & noexcept { return get_uint32().get(out); }
245template<> simdjson_warn_unused simdjson_inline error_code document::get(int32_t& out) & noexcept { return get_int32().get(out); }
246template<> simdjson_warn_unused simdjson_inline error_code document::get(uint16_t& out) & noexcept { return get_uint16().get(out); }
247template<> simdjson_warn_unused simdjson_inline error_code document::get(int16_t& out) & noexcept { return get_int16().get(out); }
248template<> simdjson_warn_unused simdjson_inline error_code document::get(uint8_t& out) & noexcept { return get_uint8().get(out); }
249template<> simdjson_warn_unused simdjson_inline error_code document::get(int8_t& out) & noexcept { return get_int8().get(out); }
250#if SIMDJSON_SUPPORTS_FLOAT32_T
251template<> simdjson_warn_unused simdjson_inline error_code document::get(std::float32_t& out) & noexcept { return get_float32().get(out); }
252#endif // SIMDJSON_SUPPORTS_FLOAT32_T
253#if SIMDJSON_SUPPORTS_FLOAT64_T
254template<> simdjson_warn_unused simdjson_inline error_code document::get(std::float64_t& out) & noexcept { return get_float64().get(out); }
255#endif // SIMDJSON_SUPPORTS_FLOAT64_T
256template<> simdjson_warn_unused simdjson_inline error_code document::get(bool& out) & noexcept { return get_bool().get(out); }
257template<> simdjson_warn_unused simdjson_inline error_code document::get(value& out) & noexcept { return get_value().get(out); }
258
259template<> simdjson_deprecated simdjson_inline simdjson_result<raw_json_string> document::get() && noexcept { return get_raw_json_string(); }
260template<> simdjson_deprecated simdjson_inline simdjson_result<std::string_view> document::get() && noexcept { return get_string(false); }
261#if SIMDJSON_SUPPORTS_CHAR8_T
262template<> simdjson_deprecated simdjson_inline simdjson_result<std::u8string_view> document::get() && noexcept { return get_u8string(false); }
263#endif // SIMDJSON_SUPPORTS_CHAR8_T
264template<> simdjson_deprecated simdjson_inline simdjson_result<double> document::get() && noexcept { return std::forward<document>(*this).get_double(); }
265template<> simdjson_deprecated simdjson_inline simdjson_result<float> document::get() && noexcept { return std::forward<document>(*this).get_float(); }
266template<> simdjson_deprecated simdjson_inline simdjson_result<uint64_t> document::get() && noexcept { return std::forward<document>(*this).get_uint64(); }
267template<> simdjson_deprecated simdjson_inline simdjson_result<int64_t> document::get() && noexcept { return std::forward<document>(*this).get_int64(); }
268template<> simdjson_deprecated simdjson_inline simdjson_result<bool> document::get() && noexcept { return std::forward<document>(*this).get_bool(); }
269template<> simdjson_deprecated simdjson_inline simdjson_result<value> document::get() && noexcept { return get_value(); }
270
271#if SIMDJSON_EXCEPTIONS
272template <class T>
273simdjson_deprecated simdjson_inline document::operator T() && noexcept(false) { return get<T>(); }
274template <class T>
275simdjson_inline document::operator T() & noexcept(false) { return get<T>(); }
276simdjson_inline document::operator array() & noexcept(false) { return get_array(); }
277simdjson_inline document::operator object() & noexcept(false) { return get_object(); }
278simdjson_inline document::operator uint64_t() noexcept(false) { return get_uint64(); }
279simdjson_inline document::operator int64_t() noexcept(false) { return get_int64(); }
280simdjson_inline document::operator double() noexcept(false) { return get_double(); }
281simdjson_inline document::operator std::string_view() noexcept(false) simdjson_lifetime_bound { return get_string(false); }
282simdjson_inline document::operator raw_json_string() noexcept(false) simdjson_lifetime_bound { return get_raw_json_string(); }
283simdjson_inline document::operator bool() noexcept(false) { return get_bool(); }
284simdjson_inline document::operator value() noexcept(false) { return get_value(); }
285
286#endif
288 auto a = get_array();
289 simdjson_result<size_t> answer = a.count_elements();
290 /* If there was an array, we are now left pointing at its first element. */
291 if(answer.error() == SUCCESS) { rewind(); }
292 return answer;
293}
295 auto a = get_object();
296 simdjson_result<size_t> answer = a.count_fields();
297 /* If there was an object, we are now left pointing at its first element. */
298 if(answer.error() == SUCCESS) { rewind(); }
299 return answer;
300}
301simdjson_inline simdjson_result<value> document::at(size_t index) & noexcept {
302 auto a = get_array();
303 return a.at(index);
304}
306 return get_array().begin();
307}
308simdjson_inline simdjson_result<array_iterator> document::end() & noexcept {
309 return {};
310}
311
312simdjson_inline simdjson_result<value> document::find_field(std::string_view key) & noexcept {
313 return start_or_resume_object().find_field(key);
314}
315simdjson_inline simdjson_result<value> document::find_field(const char *key) & noexcept {
316 return start_or_resume_object().find_field(key);
317}
318simdjson_inline simdjson_result<value> document::find_field_unordered(std::string_view key) & noexcept {
319 return start_or_resume_object().find_field_unordered(key);
320}
321simdjson_inline simdjson_result<value> document::find_field_unordered(const char *key) & noexcept {
322 return start_or_resume_object().find_field_unordered(key);
323}
324simdjson_inline simdjson_result<value> document::operator[](std::string_view key) & noexcept {
325 return start_or_resume_object()[key];
326}
327simdjson_inline simdjson_result<value> document::operator[](const char *key) & noexcept {
328 return start_or_resume_object()[key];
329}
330
331simdjson_warn_unused simdjson_inline error_code document::consume() noexcept {
332 bool scalar = false;
333 auto error = is_scalar().get(scalar);
334 if(error) { return error; }
335 if(scalar) {
336 iter.return_current_and_advance();
337 return SUCCESS;
338 }
339 error = iter.skip_child(0);
340 if(error) { iter.abandon(); }
341 return error;
342}
343
345 auto _iter = get_root_value_iterator();
346 const uint8_t * starting_point{_iter.peek_start()};
347 auto error = consume();
348 if(error) { return error; }
349 // After 'consume()', we could be left pointing just beyond the document, but that
350 // is ok because we are not going to dereference the final pointer position, we just
351 // use it to compute the length in bytes.
352 const uint8_t * final_point{iter.unsafe_pointer()};
353 return std::string_view(reinterpret_cast<const char*>(starting_point), size_t(final_point - starting_point));
354}
355
356simdjson_inline simdjson_result<json_type> document::type() noexcept {
357 return get_root_value_iterator().type();
358}
359
360simdjson_inline simdjson_result<bool> document::is_scalar() noexcept {
361 // For more speed, we could do:
362 // return iter.is_single_token();
363 json_type this_type;
364 auto error = type().get(this_type);
365 if(error) { return error; }
366 return ! ((this_type == json_type::array) || (this_type == json_type::object));
367}
368
369simdjson_inline simdjson_result<bool> document::is_string() noexcept {
370 json_type this_type;
371 auto error = type().get(this_type);
372 if(error) { return error; }
373 return (this_type == json_type::string);
374}
375
376simdjson_inline bool document::is_negative() noexcept {
377 return get_root_value_iterator().is_root_negative();
378}
379
380simdjson_inline simdjson_result<bool> document::is_integer() noexcept {
381 return get_root_value_iterator().is_root_integer(true);
382}
383
385 return get_root_value_iterator().get_root_number_type(true);
386}
387
389 return get_root_value_iterator().get_root_number(true);
390}
391
392
394 auto _iter = get_root_value_iterator();
395 return std::string_view(reinterpret_cast<const char*>(_iter.peek_start()), _iter.peek_root_length());
396}
397
398simdjson_inline simdjson_result<value> document::at_pointer(std::string_view json_pointer) noexcept {
399 rewind(); // Rewind the document each time at_pointer is called
400 if (json_pointer.empty()) {
401 return this->get_value();
402 }
403 json_type t;
404 SIMDJSON_TRY(type().get(t));
405 switch (t)
406 {
407 case json_type::array:
408 return (*this).get_array().at_pointer(json_pointer);
410 return (*this).get_object().at_pointer(json_pointer);
411 default:
413 }
414}
415
416simdjson_inline simdjson_result<value> document::at_path(std::string_view json_path) noexcept {
417 rewind(); // Rewind the document each time at_pointer is called
418 if (json_path.empty()) {
419 return this->get_value();
420 }
421 json_type t;
422 SIMDJSON_TRY(type().get(t));
423 switch (t) {
424 case json_type::array:
425 return (*this).get_array().at_path(json_path);
427 return (*this).get_object().at_path(json_path);
428 default:
430 }
431}
432
433#if SIMDJSON_SUPPORTS_CONCEPTS
434template <typename Func>
435 requires std::invocable<Func, value>
436#else
437template <typename Func>
438#endif
439simdjson_inline error_code document::for_each_at_path_with_wildcard(std::string_view json_path, Func&& callback) noexcept {
440 rewind(); // Rewind the document each time for_each_at_path_with_wildcard is called
441 if (json_path.empty()) {
443 }
444 json_type t;
445 SIMDJSON_TRY(type().get(t));
446 switch (t) {
447 case json_type::array:
448 return (*this).get_array().for_each_at_path_with_wildcard(json_path, std::forward<Func>(callback));
450 return (*this).get_object().for_each_at_path_with_wildcard(json_path, std::forward<Func>(callback));
451 default:
453 }
454}
455
456#if SIMDJSON_SUPPORTS_CONCEPTS && SIMDJSON_STATIC_REFLECTION
457
458template<constevalutil::fixed_string... FieldNames, typename T>
459 requires(std::is_class_v<T> && (sizeof...(FieldNames) > 0))
460simdjson_warn_unused simdjson_inline error_code document::extract_into(T& out) & noexcept {
461 // Helper to check if a field name matches any of the requested fields
462 auto should_extract = [](std::string_view field_name) constexpr -> bool {
463 return ((FieldNames.view() == field_name) || ...);
464 };
465
466 // Iterate through all members of T using reflection
467 template for (constexpr auto mem : std::define_static_array(
468 std::meta::nonstatic_data_members_of(^^T, std::meta::access_context::unchecked()))) {
469
470 if constexpr (!std::meta::is_const(mem) && std::meta::is_public(mem)) {
471 constexpr std::string_view key = std::define_static_string(std::meta::identifier_of(mem));
472
473 // Only extract this field if it's in our list of requested fields
474 if constexpr (should_extract(key)) {
475 // Try to find and extract the field
476 if constexpr (concepts::optional_type<decltype(out.[:mem:])>) {
477 // For optional fields, it's ok if they're missing
478 auto field_result = find_field_unordered(key);
479 if (!field_result.error()) {
480 auto error = field_result.get(out.[:mem:]);
481 if (error && error != NO_SUCH_FIELD) {
482 return error;
483 }
484 } else if (field_result.error() != NO_SUCH_FIELD) {
485 return field_result.error();
486 } else {
487 out.[:mem:].reset();
488 }
489 } else {
490 // For required fields (in the requested list), fail if missing
491 SIMDJSON_TRY((*this)[key].get(out.[:mem:]));
492 }
493 }
494 }
495 };
496
497 return SUCCESS;
498}
499
500#endif // SIMDJSON_SUPPORTS_CONCEPTS && SIMDJSON_STATIC_REFLECTION
501
502} // namespace ondemand
503} // namespace SIMDJSON_IMPLEMENTATION
504} // namespace simdjson
505
506namespace simdjson {
507
508simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::simdjson_result(
509 SIMDJSON_IMPLEMENTATION::ondemand::document &&value
510) noexcept :
511 implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document>(
512 std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(value)
513 )
514{
515}
516simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::simdjson_result(
517 error_code error
518) noexcept :
519 implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document>(
520 error
521 )
522{
523}
524simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::count_elements() & noexcept {
525 if (error()) { return error(); }
526 return first.count_elements();
527}
528simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::count_fields() & noexcept {
529 if (error()) { return error(); }
530 return first.count_fields();
531}
532simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::at(size_t index) & noexcept {
533 if (error()) { return error(); }
534 return first.at(index);
535}
536simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::rewind() noexcept {
537 if (error()) { return error(); }
538 first.rewind();
539 return SUCCESS;
540}
541simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::begin() & noexcept {
542 if (error()) { return error(); }
543 return first.begin();
544}
545simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::end() & noexcept {
546 return {};
547}
548simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field_unordered(std::string_view key) & noexcept {
549 if (error()) { return error(); }
550 return first.find_field_unordered(key);
551}
552simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field_unordered(const char *key) & noexcept {
553 if (error()) { return error(); }
554 return first.find_field_unordered(key);
555}
556simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator[](std::string_view key) & noexcept {
557 if (error()) { return error(); }
558 return first[key];
559}
560simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator[](const char *key) & noexcept {
561 if (error()) { return error(); }
562 return first[key];
563}
564simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field(std::string_view key) & noexcept {
565 if (error()) { return error(); }
566 return first.find_field(key);
567}
568simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::find_field(const char *key) & noexcept {
569 if (error()) { return error(); }
570 return first.find_field(key);
571}
572simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_array() & noexcept {
573 if (error()) { return error(); }
574 return first.get_array();
575}
576simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_object() & noexcept {
577 if (error()) { return error(); }
578 return first.get_object();
579}
580simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_uint64() noexcept {
581 if (error()) { return error(); }
582 return first.get_uint64();
583}
584simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_uint64_in_string() noexcept {
585 if (error()) { return error(); }
586 return first.get_uint64_in_string();
587}
588simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_int64() noexcept {
589 if (error()) { return error(); }
590 return first.get_int64();
591}
592simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_int64_in_string() noexcept {
593 if (error()) { return error(); }
594 return first.get_int64_in_string();
595}
596simdjson_inline simdjson_result<uint32_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_uint32() noexcept {
597 if (error()) { return error(); }
598 return first.get_uint32();
599}
600simdjson_inline simdjson_result<int32_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_int32() noexcept {
601 if (error()) { return error(); }
602 return first.get_int32();
603}
604simdjson_inline simdjson_result<uint16_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_uint16() noexcept {
605 if (error()) { return error(); }
606 return first.get_uint16();
607}
608simdjson_inline simdjson_result<int16_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_int16() noexcept {
609 if (error()) { return error(); }
610 return first.get_int16();
611}
612simdjson_inline simdjson_result<uint8_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_uint8() noexcept {
613 if (error()) { return error(); }
614 return first.get_uint8();
615}
616simdjson_inline simdjson_result<int8_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_int8() noexcept {
617 if (error()) { return error(); }
618 return first.get_int8();
619}
620simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_double() noexcept {
621 if (error()) { return error(); }
622 return first.get_double();
623}
624simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_double_in_string() noexcept {
625 if (error()) { return error(); }
626 return first.get_double_in_string();
627}
628simdjson_inline simdjson_result<float> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_float() noexcept {
629 if (error()) { return error(); }
630 return first.get_float();
631}
632simdjson_inline simdjson_result<float> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_float_in_string() noexcept {
633 if (error()) { return error(); }
634 return first.get_float_in_string();
635}
636#if SIMDJSON_SUPPORTS_FLOAT32_T
637simdjson_inline simdjson_result<std::float32_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_float32() noexcept {
638 if (error()) { return error(); }
639 return first.get_float32();
640}
641#endif // SIMDJSON_SUPPORTS_FLOAT32_T
642#if SIMDJSON_SUPPORTS_FLOAT64_T
643simdjson_inline simdjson_result<std::float64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_float64() noexcept {
644 if (error()) { return error(); }
645 return first.get_float64();
646}
647#endif // SIMDJSON_SUPPORTS_FLOAT64_T
648simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_string(bool allow_replacement) noexcept {
649 if (error()) { return error(); }
650 return first.get_string(allow_replacement);
651}
652#if SIMDJSON_SUPPORTS_CHAR8_T
653simdjson_inline simdjson_result<std::u8string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_u8string(bool allow_replacement) noexcept {
654 if (error()) { return error(); }
655 return first.get_u8string(allow_replacement);
656}
657#endif // SIMDJSON_SUPPORTS_CHAR8_T
658template <typename string_type>
659simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_string(string_type& receiver, bool allow_replacement) noexcept {
660 if (error()) { return error(); }
661 return first.get_string(receiver, allow_replacement);
662}
663simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_wobbly_string() noexcept {
664 if (error()) { return error(); }
665 return first.get_wobbly_string();
666}
667simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_raw_json_string() noexcept {
668 if (error()) { return error(); }
669 return first.get_raw_json_string();
670}
671simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_bool() noexcept {
672 if (error()) { return error(); }
673 return first.get_bool();
674}
675simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_value() noexcept {
676 if (error()) { return error(); }
677 return first.get_value();
678}
679simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_null() noexcept {
680 if (error()) { return error(); }
681 return first.is_null();
682}
683
684template<typename T>
685simdjson_inline simdjson_result<T> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get() &
686#if SIMDJSON_SUPPORTS_CONCEPTS
687 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document>)
688#else
689 noexcept
690#endif
691{
692 if (error()) { return error(); }
693 return first.get<T>();
694}
695template<typename T>
696simdjson_deprecated simdjson_inline simdjson_result<T> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get() &&
697#if SIMDJSON_SUPPORTS_CONCEPTS
698 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document>)
699#else
700 noexcept
701#endif
702{
703 if (error()) { return error(); }
704 return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(first).get<T>();
705}
706template<typename T>
707simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get(T &out) &
708#if SIMDJSON_SUPPORTS_CONCEPTS
709 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document>)
710#else
711 noexcept
712#endif
713{
714 if (error()) { return error(); }
715 return first.get<T>(out);
716}
717template<typename T>
718simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get(T &out) &&
719#if SIMDJSON_SUPPORTS_CONCEPTS
720 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document>)
721#else
722 noexcept
723#endif
724{
725 if (error()) { return error(); }
726 return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(first).get<T>(out);
727}
728
729template<> simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>() & noexcept = delete;
730template<> simdjson_deprecated simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>() && noexcept {
731 if (error()) { return error(); }
732 return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(first);
733}
734template<> simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>(SIMDJSON_IMPLEMENTATION::ondemand::document &out) & noexcept = delete;
735template<> simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get<SIMDJSON_IMPLEMENTATION::ondemand::document>(SIMDJSON_IMPLEMENTATION::ondemand::document &out) && noexcept {
736 if (error()) { return error(); }
737 out = std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document>(first);
738 return SUCCESS;
739}
740
741simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::type() noexcept {
742 if (error()) { return error(); }
743 return first.type();
744}
745
746simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_scalar() noexcept {
747 if (error()) { return error(); }
748 return first.is_scalar();
749}
750
751simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_string() noexcept {
752 if (error()) { return error(); }
753 return first.is_string();
754}
755
756simdjson_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_negative() noexcept {
757 if (error()) { return error(); }
758 return first.is_negative();
759}
760
761simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::is_integer() noexcept {
762 if (error()) { return error(); }
763 return first.is_integer();
764}
765
766simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::number_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_number_type() noexcept {
767 if (error()) { return error(); }
768 return first.get_number_type();
769}
770
771simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::get_number() noexcept {
772 if (error()) { return error(); }
773 return first.get_number();
774}
775
776
777#if SIMDJSON_EXCEPTIONS
778template <class T, typename std::enable_if<std::is_same<T, SIMDJSON_IMPLEMENTATION::ondemand::document>::value == false>::type>
779simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator T() noexcept(false) {
780 if (error()) { throw simdjson_error(error()); }
781 return first;
782}
783simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false) {
784 if (error()) { throw simdjson_error(error()); }
785 return first;
786}
787simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false) {
788 if (error()) { throw simdjson_error(error()); }
789 return first;
790}
791simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator uint64_t() noexcept(false) {
792 if (error()) { throw simdjson_error(error()); }
793 return first.get_uint64();
794}
795simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator int64_t() noexcept(false) {
796 if (error()) { throw simdjson_error(error()); }
797 return first.get_int64();
798}
799simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator double() noexcept(false) {
800 if (error()) { throw simdjson_error(error()); }
801 return first.get_double();
802}
803simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator std::string_view() noexcept(false) {
804 if (error()) { throw simdjson_error(error()); }
805 return first.get_string();
806}
807simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false) {
808 if (error()) { throw simdjson_error(error()); }
809 return first.get_raw_json_string();
810}
811simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator bool() noexcept(false) {
812 if (error()) { throw simdjson_error(error()); }
813 return first.get_bool();
814}
815simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false) {
816 if (error()) { throw simdjson_error(error()); }
817 return first;
818}
819#endif
820
821
822simdjson_inline simdjson_result<const char *> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::current_location() noexcept {
823 if (error()) { return error(); }
824 return first.current_location();
825}
826
827simdjson_inline bool simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::at_end() const noexcept {
828 if (error()) { return error(); }
829 return first.at_end();
830}
831
832
833simdjson_inline int32_t simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::current_depth() const noexcept {
834 if (error()) { return error(); }
835 return first.current_depth();
836}
837
838simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::raw_json_token() noexcept {
839 if (error()) { return error(); }
840 return first.raw_json_token();
841}
842
843simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::at_pointer(std::string_view json_pointer) noexcept {
844 if (error()) { return error(); }
845 return first.at_pointer(json_pointer);
846}
847
848simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::at_path(std::string_view json_path) noexcept {
849 if (error()) { return error(); }
850 return first.at_path(json_path);
851}
852
853#if SIMDJSON_SUPPORTS_CONCEPTS
854template <typename Func>
855 requires std::invocable<Func, SIMDJSON_IMPLEMENTATION::ondemand::value>
856#else
857template <typename Func>
858#endif
859simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::for_each_at_path_with_wildcard(std::string_view json_path, Func&& callback) noexcept {
860 if (error()) { return error(); }
861 return first.for_each_at_path_with_wildcard(json_path, std::forward<Func>(callback));
862}
863
864#if SIMDJSON_STATIC_REFLECTION
865template<constevalutil::fixed_string... FieldNames, typename T>
866 requires(std::is_class_v<T> && (sizeof...(FieldNames) > 0))
867simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document>::extract_into(T& out) & noexcept {
868 if (error()) { return error(); }
869 return first.extract_into<FieldNames...>(out);
870}
871#endif // SIMDJSON_STATIC_REFLECTION
872
873} // namespace simdjson
874
875
876namespace simdjson {
877namespace SIMDJSON_IMPLEMENTATION {
878namespace ondemand {
879
880simdjson_inline document_reference::document_reference() noexcept : doc{nullptr} {}
881simdjson_inline document_reference::document_reference(document &d) noexcept : doc(&d) {}
882simdjson_inline void document_reference::rewind() noexcept { doc->rewind(); }
883simdjson_inline simdjson_result<array> document_reference::get_array() & noexcept { return doc->get_array(); }
884simdjson_inline simdjson_result<object> document_reference::get_object() & noexcept { return doc->get_object(); }
899simdjson_inline simdjson_result<uint64_t> document_reference::get_uint64() noexcept { return doc->get_root_value_iterator().get_root_uint64(false); }
900simdjson_inline simdjson_result<uint64_t> document_reference::get_uint64_in_string() noexcept { return doc->get_root_value_iterator().get_root_uint64_in_string(false); }
901simdjson_inline simdjson_result<int64_t> document_reference::get_int64() noexcept { return doc->get_root_value_iterator().get_root_int64(false); }
902simdjson_inline simdjson_result<int64_t> document_reference::get_int64_in_string() noexcept { return doc->get_root_value_iterator().get_root_int64_in_string(false); }
903simdjson_inline simdjson_result<uint32_t> document_reference::get_uint32() noexcept { return narrow_integer<uint32_t>(get_uint64()); }
904simdjson_inline simdjson_result<int32_t> document_reference::get_int32() noexcept { return narrow_integer<int32_t>(get_int64()); }
905simdjson_inline simdjson_result<uint16_t> document_reference::get_uint16() noexcept { return narrow_integer<uint16_t>(get_uint64()); }
906simdjson_inline simdjson_result<int16_t> document_reference::get_int16() noexcept { return narrow_integer<int16_t>(get_int64()); }
907simdjson_inline simdjson_result<uint8_t> document_reference::get_uint8() noexcept { return narrow_integer<uint8_t>(get_uint64()); }
908simdjson_inline simdjson_result<int8_t> document_reference::get_int8() noexcept { return narrow_integer<int8_t>(get_int64()); }
909simdjson_inline simdjson_result<double> document_reference::get_double() noexcept { return doc->get_root_value_iterator().get_root_double(false); }
910simdjson_inline simdjson_result<double> document_reference::get_double_in_string() noexcept { return doc->get_root_value_iterator().get_root_double_in_string(false); }
911simdjson_inline simdjson_result<float> document_reference::get_float() noexcept { return doc->get_root_value_iterator().get_root_float(false); }
912simdjson_inline simdjson_result<float> document_reference::get_float_in_string() noexcept { return doc->get_root_value_iterator().get_root_float_in_string(false); }
913#if SIMDJSON_SUPPORTS_FLOAT32_T
914simdjson_inline simdjson_result<std::float32_t> document_reference::get_float32() noexcept {
915 float result;
916 SIMDJSON_TRY(get_float().get(result));
917 return static_cast<std::float32_t>(result);
918}
919#endif // SIMDJSON_SUPPORTS_FLOAT32_T
920#if SIMDJSON_SUPPORTS_FLOAT64_T
921simdjson_inline simdjson_result<std::float64_t> document_reference::get_float64() noexcept {
922 double result;
923 SIMDJSON_TRY(get_double().get(result));
924 return static_cast<std::float64_t>(result);
925}
926#endif // SIMDJSON_SUPPORTS_FLOAT64_T
927simdjson_inline simdjson_result<std::string_view> document_reference::get_string(bool allow_replacement) noexcept { return doc->get_root_value_iterator().get_root_string(false, allow_replacement); }
928#if SIMDJSON_SUPPORTS_CHAR8_T
929simdjson_inline simdjson_result<std::u8string_view> document_reference::get_u8string(bool allow_replacement) noexcept {
930 std::string_view content;
931 SIMDJSON_TRY( get_string(allow_replacement).get(content) );
932 return internal::as_u8string_view(content);
933}
934#endif // SIMDJSON_SUPPORTS_CHAR8_T
935template <typename string_type>
936simdjson_warn_unused simdjson_inline error_code document_reference::get_string(string_type& receiver, bool allow_replacement) noexcept { return doc->get_root_value_iterator().get_root_string(receiver, false, allow_replacement); }
937simdjson_inline simdjson_result<std::string_view> document_reference::get_wobbly_string() noexcept { return doc->get_root_value_iterator().get_root_wobbly_string(false); }
938simdjson_inline simdjson_result<raw_json_string> document_reference::get_raw_json_string() noexcept { return doc->get_root_value_iterator().get_root_raw_json_string(false); }
939simdjson_inline simdjson_result<bool> document_reference::get_bool() noexcept { return doc->get_root_value_iterator().get_root_bool(false); }
940simdjson_inline simdjson_result<value> document_reference::get_value() noexcept { return doc->get_value(); }
941simdjson_inline simdjson_result<bool> document_reference::is_null() noexcept { return doc->get_root_value_iterator().is_root_null(false); }
942template<> simdjson_inline simdjson_result<array> document_reference::get() & noexcept { return get_array(); }
943template<> simdjson_inline simdjson_result<object> document_reference::get() & noexcept { return get_object(); }
944template<> simdjson_inline simdjson_result<raw_json_string> document_reference::get() & noexcept { return get_raw_json_string(); }
945template<> simdjson_inline simdjson_result<std::string_view> document_reference::get() & noexcept { return get_string(false); }
946#if SIMDJSON_SUPPORTS_CHAR8_T
947template<> simdjson_inline simdjson_result<std::u8string_view> document_reference::get() & noexcept { return get_u8string(false); }
948#endif // SIMDJSON_SUPPORTS_CHAR8_T
949template<> simdjson_inline simdjson_result<double> document_reference::get() & noexcept { return get_double(); }
950template<> simdjson_inline simdjson_result<float> document_reference::get() & noexcept { return get_float(); }
951template<> simdjson_inline simdjson_result<uint64_t> document_reference::get() & noexcept { return get_uint64(); }
952template<> simdjson_inline simdjson_result<int64_t> document_reference::get() & noexcept { return get_int64(); }
953template<> simdjson_inline simdjson_result<uint32_t> document_reference::get() & noexcept { return get_uint32(); }
954template<> simdjson_inline simdjson_result<int32_t> document_reference::get() & noexcept { return get_int32(); }
955template<> simdjson_inline simdjson_result<uint16_t> document_reference::get() & noexcept { return get_uint16(); }
956template<> simdjson_inline simdjson_result<int16_t> document_reference::get() & noexcept { return get_int16(); }
957template<> simdjson_inline simdjson_result<uint8_t> document_reference::get() & noexcept { return get_uint8(); }
958template<> simdjson_inline simdjson_result<int8_t> document_reference::get() & noexcept { return get_int8(); }
959#if SIMDJSON_SUPPORTS_FLOAT32_T
960template<> simdjson_inline simdjson_result<std::float32_t> document_reference::get() & noexcept { return get_float32(); }
961#endif // SIMDJSON_SUPPORTS_FLOAT32_T
962#if SIMDJSON_SUPPORTS_FLOAT64_T
963template<> simdjson_inline simdjson_result<std::float64_t> document_reference::get() & noexcept { return get_float64(); }
964#endif // SIMDJSON_SUPPORTS_FLOAT64_T
965template<> simdjson_inline simdjson_result<bool> document_reference::get() & noexcept { return get_bool(); }
966template<> simdjson_inline simdjson_result<value> document_reference::get() & noexcept { return get_value(); }
967#if SIMDJSON_EXCEPTIONS
968template <class T>
969simdjson_inline document_reference::operator T() noexcept(false) { return get<T>(); }
970simdjson_inline document_reference::operator array() & noexcept(false) { return array(*doc); }
971simdjson_inline document_reference::operator object() & noexcept(false) { return object(*doc); }
972simdjson_inline document_reference::operator uint64_t() noexcept(false) { return get_uint64(); }
973simdjson_inline document_reference::operator int64_t() noexcept(false) { return get_int64(); }
974simdjson_inline document_reference::operator double() noexcept(false) { return get_double(); }
975simdjson_inline document_reference::operator std::string_view() noexcept(false) { return std::string_view(*doc); }
976simdjson_inline document_reference::operator raw_json_string() noexcept(false) { return get_raw_json_string(); }
977simdjson_inline document_reference::operator bool() noexcept(false) { return get_bool(); }
978simdjson_inline document_reference::operator value() noexcept(false) { return value(*doc); }
979#endif
980simdjson_inline simdjson_result<size_t> document_reference::count_elements() & noexcept { return doc->count_elements(); }
981simdjson_inline simdjson_result<size_t> document_reference::count_fields() & noexcept { return doc->count_fields(); }
982simdjson_inline simdjson_result<value> document_reference::at(size_t index) & noexcept { return doc->at(index); }
983simdjson_inline simdjson_result<array_iterator> document_reference::begin() & noexcept { return doc->begin(); }
984simdjson_inline simdjson_result<array_iterator> document_reference::end() & noexcept { return doc->end(); }
985simdjson_inline simdjson_result<value> document_reference::find_field(std::string_view key) & noexcept { return doc->find_field(key); }
986simdjson_inline simdjson_result<value> document_reference::find_field(const char *key) & noexcept { return doc->find_field(key); }
987simdjson_inline simdjson_result<value> document_reference::operator[](std::string_view key) & noexcept { return (*doc)[key]; }
988simdjson_inline simdjson_result<value> document_reference::operator[](const char *key) & noexcept { return (*doc)[key]; }
989simdjson_inline simdjson_result<value> document_reference::find_field_unordered(std::string_view key) & noexcept { return doc->find_field_unordered(key); }
990simdjson_inline simdjson_result<value> document_reference::find_field_unordered(const char *key) & noexcept { return doc->find_field_unordered(key); }
991simdjson_inline simdjson_result<json_type> document_reference::type() noexcept { return doc->type(); }
992simdjson_inline simdjson_result<bool> document_reference::is_scalar() noexcept { return doc->is_scalar(); }
993simdjson_inline simdjson_result<bool> document_reference::is_string() noexcept { return doc->is_string(); }
994simdjson_inline simdjson_result<const char *> document_reference::current_location() noexcept { return doc->current_location(); }
995simdjson_inline int32_t document_reference::current_depth() const noexcept { return doc->current_depth(); }
996simdjson_inline bool document_reference::is_negative() noexcept { return doc->is_negative(); }
997simdjson_inline simdjson_result<bool> document_reference::is_integer() noexcept { return doc->get_root_value_iterator().is_root_integer(false); }
998simdjson_inline simdjson_result<number_type> document_reference::get_number_type() noexcept { return doc->get_root_value_iterator().get_root_number_type(false); }
999simdjson_inline simdjson_result<number> document_reference::get_number() noexcept { return doc->get_root_value_iterator().get_root_number(false); }
1000simdjson_inline simdjson_result<std::string_view> document_reference::raw_json_token() noexcept { return doc->raw_json_token(); }
1001simdjson_inline simdjson_result<value> document_reference::at_pointer(std::string_view json_pointer) noexcept { return doc->at_pointer(json_pointer); }
1002simdjson_inline simdjson_result<value> document_reference::at_path(std::string_view json_path) noexcept { return doc->at_path(json_path); }
1003#if SIMDJSON_SUPPORTS_CONCEPTS
1004template <typename Func>
1005 requires std::invocable<Func, value>
1006#else
1007template <typename Func>
1008#endif
1009simdjson_inline error_code document_reference::for_each_at_path_with_wildcard(std::string_view json_path, Func&& callback) noexcept { return doc->for_each_at_path_with_wildcard(json_path, std::forward<Func>(callback)); }
1010simdjson_inline simdjson_result<std::string_view> document_reference::raw_json() noexcept { return doc->raw_json();}
1011simdjson_inline document_reference::operator document&() const noexcept { return *doc; }
1012#if SIMDJSON_SUPPORTS_CONCEPTS && SIMDJSON_STATIC_REFLECTION
1013template<constevalutil::fixed_string... FieldNames, typename T>
1014 requires(std::is_class_v<T> && (sizeof...(FieldNames) > 0))
1015simdjson_warn_unused simdjson_inline error_code document_reference::extract_into(T& out) & noexcept {
1016 return doc->extract_into<FieldNames...>(out);
1017}
1018#endif // SIMDJSON_SUPPORTS_CONCEPTS && SIMDJSON_STATIC_REFLECTION
1019} // namespace ondemand
1020} // namespace SIMDJSON_IMPLEMENTATION
1021} // namespace simdjson
1022
1023
1024
1025namespace simdjson {
1026simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::document_reference value, error_code error)
1027 noexcept : implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>(std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>(value), error) {}
1028
1029
1030simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::count_elements() & noexcept {
1031 if (error()) { return error(); }
1032 return first.count_elements();
1033}
1034simdjson_inline simdjson_result<size_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::count_fields() & noexcept {
1035 if (error()) { return error(); }
1036 return first.count_fields();
1037}
1038simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::at(size_t index) & noexcept {
1039 if (error()) { return error(); }
1040 return first.at(index);
1041}
1042simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::rewind() noexcept {
1043 if (error()) { return error(); }
1044 first.rewind();
1045 return SUCCESS;
1046}
1047simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::begin() & noexcept {
1048 if (error()) { return error(); }
1049 return first.begin();
1050}
1051simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array_iterator> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::end() & noexcept {
1052 return {};
1053}
1054simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field_unordered(std::string_view key) & noexcept {
1055 if (error()) { return error(); }
1056 return first.find_field_unordered(key);
1057}
1058simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field_unordered(const char *key) & noexcept {
1059 if (error()) { return error(); }
1060 return first.find_field_unordered(key);
1061}
1062simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator[](std::string_view key) & noexcept {
1063 if (error()) { return error(); }
1064 return first[key];
1065}
1066simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator[](const char *key) & noexcept {
1067 if (error()) { return error(); }
1068 return first[key];
1069}
1070simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field(std::string_view key) & noexcept {
1071 if (error()) { return error(); }
1072 return first.find_field(key);
1073}
1074simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::find_field(const char *key) & noexcept {
1075 if (error()) { return error(); }
1076 return first.find_field(key);
1077}
1078simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::array> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_array() & noexcept {
1079 if (error()) { return error(); }
1080 return first.get_array();
1081}
1082simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::object> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_object() & noexcept {
1083 if (error()) { return error(); }
1084 return first.get_object();
1085}
1086simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_uint64() noexcept {
1087 if (error()) { return error(); }
1088 return first.get_uint64();
1089}
1090simdjson_inline simdjson_result<uint64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_uint64_in_string() noexcept {
1091 if (error()) { return error(); }
1092 return first.get_uint64_in_string();
1093}
1094simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_int64() noexcept {
1095 if (error()) { return error(); }
1096 return first.get_int64();
1097}
1098simdjson_inline simdjson_result<int64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_int64_in_string() noexcept {
1099 if (error()) { return error(); }
1100 return first.get_int64_in_string();
1101}
1102simdjson_inline simdjson_result<uint32_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_uint32() noexcept {
1103 if (error()) { return error(); }
1104 return first.get_uint32();
1105}
1106simdjson_inline simdjson_result<int32_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_int32() noexcept {
1107 if (error()) { return error(); }
1108 return first.get_int32();
1109}
1110simdjson_inline simdjson_result<uint16_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_uint16() noexcept {
1111 if (error()) { return error(); }
1112 return first.get_uint16();
1113}
1114simdjson_inline simdjson_result<int16_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_int16() noexcept {
1115 if (error()) { return error(); }
1116 return first.get_int16();
1117}
1118simdjson_inline simdjson_result<uint8_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_uint8() noexcept {
1119 if (error()) { return error(); }
1120 return first.get_uint8();
1121}
1122simdjson_inline simdjson_result<int8_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_int8() noexcept {
1123 if (error()) { return error(); }
1124 return first.get_int8();
1125}
1126simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_double() noexcept {
1127 if (error()) { return error(); }
1128 return first.get_double();
1129}
1130simdjson_inline simdjson_result<double> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_double_in_string() noexcept {
1131 if (error()) { return error(); }
1132 return first.get_double_in_string();
1133}
1134simdjson_inline simdjson_result<float> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_float() noexcept {
1135 if (error()) { return error(); }
1136 return first.get_float();
1137}
1138simdjson_inline simdjson_result<float> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_float_in_string() noexcept {
1139 if (error()) { return error(); }
1140 return first.get_float_in_string();
1141}
1142#if SIMDJSON_SUPPORTS_FLOAT32_T
1143simdjson_inline simdjson_result<std::float32_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_float32() noexcept {
1144 if (error()) { return error(); }
1145 return first.get_float32();
1146}
1147#endif // SIMDJSON_SUPPORTS_FLOAT32_T
1148#if SIMDJSON_SUPPORTS_FLOAT64_T
1149simdjson_inline simdjson_result<std::float64_t> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_float64() noexcept {
1150 if (error()) { return error(); }
1151 return first.get_float64();
1152}
1153#endif // SIMDJSON_SUPPORTS_FLOAT64_T
1154simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_string(bool allow_replacement) noexcept {
1155 if (error()) { return error(); }
1156 return first.get_string(allow_replacement);
1157}
1158#if SIMDJSON_SUPPORTS_CHAR8_T
1159simdjson_inline simdjson_result<std::u8string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_u8string(bool allow_replacement) noexcept {
1160 if (error()) { return error(); }
1161 return first.get_u8string(allow_replacement);
1162}
1163#endif // SIMDJSON_SUPPORTS_CHAR8_T
1164template <typename string_type>
1165simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_string(string_type& receiver, bool allow_replacement) noexcept {
1166 if (error()) { return error(); }
1167 return first.get_string(receiver, allow_replacement);
1168}
1169simdjson_inline simdjson_result<std::string_view> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_wobbly_string() noexcept {
1170 if (error()) { return error(); }
1171 return first.get_wobbly_string();
1172}
1173simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_raw_json_string() noexcept {
1174 if (error()) { return error(); }
1175 return first.get_raw_json_string();
1176}
1177simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_bool() noexcept {
1178 if (error()) { return error(); }
1179 return first.get_bool();
1180}
1181simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_value() noexcept {
1182 if (error()) { return error(); }
1183 return first.get_value();
1184}
1185simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_null() noexcept {
1186 if (error()) { return error(); }
1187 return first.is_null();
1188}
1189template<typename T>
1191#if SIMDJSON_SUPPORTS_CONCEPTS
1192 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document_reference>)
1193#else
1194 noexcept
1195#endif
1196{
1197 if (error()) { return error(); }
1198 return first.get<T>();
1199}
1200template<typename T>
1202#if SIMDJSON_SUPPORTS_CONCEPTS
1203 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document_reference>)
1204#else
1205 noexcept
1206#endif
1207{
1208 if (error()) { return error(); }
1209 return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>(first).get<T>();
1210}
1211template <class T>
1213#if SIMDJSON_SUPPORTS_CONCEPTS
1214 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document_reference>)
1215#else
1216 noexcept
1217#endif
1218{
1219 if (error()) { return error(); }
1220 return first.get<T>(out);
1221}
1222template <class T>
1224#if SIMDJSON_SUPPORTS_CONCEPTS
1225 noexcept(nothrow_gettable<T, SIMDJSON_IMPLEMENTATION::ondemand::document_reference>)
1226#else
1227 noexcept
1228#endif
1229{
1230 if (error()) { return error(); }
1231 return std::forward<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>(first).get<T>(out);
1232}
1233simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::json_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::type() noexcept {
1234 if (error()) { return error(); }
1235 return first.type();
1236}
1237simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_scalar() noexcept {
1238 if (error()) { return error(); }
1239 return first.is_scalar();
1240}
1241simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_string() noexcept {
1242 if (error()) { return error(); }
1243 return first.is_string();
1244}
1245template <>
1246simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get(SIMDJSON_IMPLEMENTATION::ondemand::document_reference &out) & noexcept {
1247 if (error()) { return error(); }
1248 out = first;
1249 return SUCCESS;
1250}
1251template <>
1252simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get(SIMDJSON_IMPLEMENTATION::ondemand::document_reference &out) && noexcept {
1253 if (error()) { return error(); }
1254 out = first;
1255 return SUCCESS;
1256}
1257simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_negative() noexcept {
1258 if (error()) { return error(); }
1259 return first.is_negative();
1260}
1261simdjson_inline simdjson_result<bool> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::is_integer() noexcept {
1262 if (error()) { return error(); }
1263 return first.is_integer();
1264}
1265simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::number_type> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_number_type() noexcept {
1266 if (error()) { return error(); }
1267 return first.get_number_type();
1268}
1269simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::number> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::get_number() noexcept {
1270 if (error()) { return error(); }
1271 return first.get_number();
1272}
1273#if SIMDJSON_EXCEPTIONS
1274template <class T>
1275simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator T() noexcept(false) {
1276 static_assert(std::is_same<T, SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::value == false, "You should not call get<T> when T is a document");
1277 static_assert(std::is_same<T, SIMDJSON_IMPLEMENTATION::ondemand::document>::value == false, "You should not call get<T> when T is a document");
1278 if (error()) { throw simdjson_error(error()); }
1279 return first.get<T>();
1280}
1281simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::array() & noexcept(false) {
1282 if (error()) { throw simdjson_error(error()); }
1283 return first;
1284}
1285simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::object() & noexcept(false) {
1286 if (error()) { throw simdjson_error(error()); }
1287 return first;
1288}
1289simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator uint64_t() noexcept(false) {
1290 if (error()) { throw simdjson_error(error()); }
1291 return first.get_uint64();
1292}
1293simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator int64_t() noexcept(false) {
1294 if (error()) { throw simdjson_error(error()); }
1295 return first.get_int64();
1296}
1297simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator double() noexcept(false) {
1298 if (error()) { throw simdjson_error(error()); }
1299 return first.get_double();
1300}
1301simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator std::string_view() noexcept(false) {
1302 if (error()) { throw simdjson_error(error()); }
1303 return first.get_string();
1304}
1305simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::raw_json_string() noexcept(false) {
1306 if (error()) { throw simdjson_error(error()); }
1307 return first.get_raw_json_string();
1308}
1309simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator bool() noexcept(false) {
1310 if (error()) { throw simdjson_error(error()); }
1311 return first.get_bool();
1312}
1313simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::operator SIMDJSON_IMPLEMENTATION::ondemand::value() noexcept(false) {
1314 if (error()) { throw simdjson_error(error()); }
1315 return first;
1316}
1317#endif
1318
1319simdjson_inline simdjson_result<const char *> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::current_location() noexcept {
1320 if (error()) { return error(); }
1321 return first.current_location();
1322}
1323
1325 if (error()) { return error(); }
1326 return first.raw_json_token();
1327}
1328
1330 if (error()) { return error(); }
1331 return first.at_pointer(json_pointer);
1332}
1333
1334simdjson_inline simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::value> simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::at_path(std::string_view json_path) noexcept {
1335 if (error()) {
1336 return error();
1337 }
1338 return first.at_path(json_path);
1339}
1340#if SIMDJSON_SUPPORTS_CONCEPTS
1341template <typename Func>
1342 requires std::invocable<Func, SIMDJSON_IMPLEMENTATION::ondemand::value>
1343#else
1344template <typename Func>
1345#endif
1346simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::for_each_at_path_with_wildcard(std::string_view json_path, Func&& callback) noexcept {
1347 if (error()) {
1348 return error();
1349 }
1350 return first.for_each_at_path_with_wildcard(json_path, std::forward<Func>(callback));
1351}
1352#if SIMDJSON_STATIC_REFLECTION
1353template<constevalutil::fixed_string... FieldNames, typename T>
1354 requires(std::is_class_v<T> && (sizeof...(FieldNames) > 0))
1355simdjson_warn_unused simdjson_inline error_code simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_reference>::extract_into(T& out) & noexcept {
1356 if (error()) { return error(); }
1357 return first.extract_into<FieldNames...>(out);
1358}
1359#endif // SIMDJSON_STATIC_REFLECTION
1360} // namespace simdjson
1361
1362#endif // SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_INL_H
static simdjson_inline simdjson_result< array > start_root(value_iterator &iter) noexcept
Begin array iteration from the root.
Definition array-inl.h:68
simdjson_inline simdjson_result< uint64_t > get_uint64() noexcept
The document_reference instances are used primarily/solely for streams of JSON documents.
simdjson_inline simdjson_result< value > at(size_t index) &noexcept
Get the value at the given index in the array.
simdjson_inline simdjson_result< int16_t > get_int16() noexcept
Cast this JSON value to a 16-bit signed integer.
simdjson_inline simdjson_result< float > get_float() noexcept
Cast this JSON value to a float (binary32).
simdjson_warn_unused simdjson_inline error_code consume() noexcept
Consumes the document.
simdjson_inline int32_t current_depth() const noexcept
Returns the current depth in the document if in bounds.
simdjson_inline simdjson_result< array_iterator > begin() &noexcept
Begin array iteration.
simdjson_inline simdjson_result< uint16_t > get_uint16() noexcept
Cast this JSON value to a 16-bit unsigned integer.
simdjson_inline simdjson_result< size_t > count_fields() &noexcept
This method scans the object and counts the number of key-value pairs.
simdjson_inline simdjson_result< std::string_view > get_string(bool allow_replacement=false) noexcept
Cast this JSON value to a string.
simdjson_warn_unused simdjson_inline simdjson_result< number > get_number() noexcept
Attempt to parse an ondemand::number.
bool is_alive() noexcept
Some unrecoverable error conditions may render the document instance unusable.
simdjson_inline error_code for_each_at_path_with_wildcard(std::string_view json_path, Func &&callback) noexcept
Call the provided callback for each value matching the given JSONPath expression with wildcard suppor...
simdjson_inline simdjson_result< uint8_t > get_uint8() noexcept
Cast this JSON value to an 8-bit unsigned integer.
simdjson_inline simdjson_result< bool > get_bool() noexcept
Cast this JSON value to a bool.
simdjson_inline simdjson_result< object > get_object() &noexcept
Cast this JSON value to an object.
simdjson_inline simdjson_result< bool > is_string() noexcept
Checks whether the document is a string.
simdjson_inline simdjson_result< uint64_t > get_uint64() noexcept
Cast this JSON value to an unsigned integer.
simdjson_inline bool is_negative() noexcept
Checks whether the document is a negative number.
simdjson_inline document() noexcept=default
Create a new invalid document.
simdjson_inline simdjson_result< std::string_view > raw_json_token() noexcept
Get the raw JSON for this token.
simdjson_inline simdjson_result< float > get_float_in_string() noexcept
Cast this JSON value (inside string) to a float (binary32).
simdjson_inline simdjson_result< uint64_t > get_uint64_in_string() noexcept
Cast this JSON value (inside string) to an unsigned integer.
simdjson_inline simdjson_result< bool > is_null() noexcept
Checks if this JSON value is null.
simdjson_inline simdjson_result< int8_t > get_int8() noexcept
Cast this JSON value to an 8-bit signed integer.
simdjson_inline simdjson_result< int64_t > get_int64() noexcept
Cast this JSON value to a signed integer.
simdjson_inline simdjson_result< int32_t > get_int32() noexcept
Cast this JSON value to a 32-bit signed integer.
simdjson_inline simdjson_result< value > at_pointer(std::string_view json_pointer) noexcept
Get the value associated with the given JSON pointer.
simdjson_inline simdjson_result< json_type > type() noexcept
Get the type of this JSON value.
simdjson_inline simdjson_result< array_iterator > end() &noexcept
Sentinel representing the end of the array.
simdjson_inline simdjson_result< double > get_double_in_string() noexcept
Cast this JSON value (inside string) to a double.
simdjson_inline simdjson_result< value > at_path(std::string_view json_path) noexcept
Get the value associated with the given JSONPath expression.
json_iterator iter
Current position in the document.
Definition document.h:934
simdjson_inline simdjson_result< double > get_double() noexcept
Cast this JSON value to a double.
std::string to_debug_string() noexcept
Returns debugging information.
void rewind() noexcept
Reset the iterator inside the document instance so we are pointing back at the beginning of the docum...
simdjson_inline simdjson_result< std::string_view > raw_json() noexcept
Consumes the document and returns a string_view instance corresponding to the document as represented...
simdjson_inline simdjson_result< value > find_field_unordered(std::string_view key) &noexcept
Look up a field by name on an object, without regard to key order.
simdjson_inline simdjson_result< int64_t > get_int64_in_string() noexcept
Cast this JSON value (inside string) to a signed integer.
simdjson_inline simdjson_result< size_t > count_elements() &noexcept
This method scans the array and counts the number of elements.
simdjson_inline simdjson_result< value > get_value() noexcept
Cast this JSON value to a value when the document is an object or an array.
simdjson_inline simdjson_result< value > find_field(std::string_view key) &noexcept
Look up a field by name on an object (order-sensitive).
simdjson_inline simdjson_result< number_type > get_number_type() noexcept
Determine the number type (integer or floating-point number) as quickly as possible.
simdjson_inline simdjson_result< uint32_t > get_uint32() noexcept
Cast this JSON value to a 32-bit unsigned integer.
simdjson_inline simdjson_result< bool > is_scalar() noexcept
Checks whether the document is a scalar (string, number, null, Boolean).
simdjson_inline simdjson_result< std::string_view > get_wobbly_string() noexcept
Cast this JSON value to a string.
bool at_end() const noexcept
Returns true if this document has been fully parsed.
simdjson_inline simdjson_result< array > get_array() &noexcept
Cast this JSON value to an array.
simdjson_inline simdjson_result< bool > is_integer() noexcept
Checks whether the document is an integer number.
simdjson_result< const char * > current_location() const noexcept
Returns the current location in the document if in bounds.
simdjson_inline simdjson_result< T > get() &noexcept
Get this value as the given type.
Definition document.h:314
simdjson_inline simdjson_result< raw_json_string > get_raw_json_string() noexcept
Cast this JSON value to a raw_json_string.
A forward-only JSON object field iterator.
Definition object.h:130
A string escaped per JSON rules, terminated with quote (").
An ephemeral JSON value returned during iteration.
Definition value.h:22
@ object
A JSON object ( { "a": 1, "b" 2, ... } )
@ string
A JSON string ( "a" or "hello world\n" ...)
The top level simdjson namespace, containing everything the library provides.
Definition base.h:8
error_code
All possible errors returned by simdjson.
Definition error.h:19
@ SCALAR_DOCUMENT_AS_VALUE
A scalar document is treated as a value.
Definition error.h:49
@ OUT_OF_ORDER_ITERATION
tried to iterate an array or object out of order (checked when SIMDJSON_DEVELOPMENT_CHECKS=1)
Definition error.h:46
@ NO_SUCH_FIELD
JSON field not found in object.
Definition error.h:40
@ SUCCESS
No error.
Definition error.h:20
@ INVALID_JSON_POINTER
Invalid JSON pointer syntax.
Definition error.h:42
The result of a simdjson operation that could fail.
Definition error.h:281
simdjson_inline error_code error() const noexcept
The error.
Definition error-inl.h:168
simdjson_warn_unused simdjson_inline error_code get(T &value) &&noexcept
Move the value to the provided variable.
Definition error-inl.h:163