1 #ifndef SIMDJSON_GENERIC_ONDEMAND_VALUE_ITERATOR_H
3 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
4 #define SIMDJSON_GENERIC_ONDEMAND_VALUE_ITERATOR_H
5 #include "simdjson/generic/ondemand/base.h"
6 #include "simdjson/generic/implementation_simdjson_result_base.h"
10 namespace SIMDJSON_IMPLEMENTATION {
21 class value_iterator {
24 json_iterator *_json_iter{};
30 token_position _start_position{};
33 simdjson_inline value_iterator() noexcept = default;
38 simdjson_inline
void start_document() noexcept;
45 simdjson_warn_unused simdjson_inline
error_code skip_child() noexcept;
50 simdjson_inline
bool at_end() const noexcept;
55 simdjson_inline
bool at_start() const noexcept;
60 simdjson_inline
bool is_open() const noexcept;
65 simdjson_inline
bool at_first_field() const noexcept;
70 simdjson_inline
void abandon() noexcept;
75 simdjson_inline value_iterator child_value() const noexcept;
80 simdjson_inline int32_t depth() const noexcept;
87 simdjson_inline simdjson_result<
json_type> type() const noexcept;
104 simdjson_warn_unused simdjson_inline simdjson_result<
bool> start_object() noexcept;
112 simdjson_warn_unused simdjson_inline simdjson_result<
bool> start_root_object() noexcept;
120 simdjson_warn_unused simdjson_inline
error_code check_root_object() noexcept;
130 simdjson_warn_unused simdjson_inline simdjson_result<
bool> started_object() noexcept;
140 simdjson_warn_unused simdjson_inline simdjson_result<
bool> started_root_object() noexcept;
152 simdjson_warn_unused simdjson_inline simdjson_result<
bool> has_next_field() noexcept;
157 simdjson_warn_unused simdjson_inline simdjson_result<raw_json_string> field_key() noexcept;
162 simdjson_warn_unused simdjson_inline
error_code field_value() noexcept;
180 simdjson_warn_unused simdjson_inline
error_code find_field(const std::string_view key) noexcept;
199 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> find_field_raw(const std::string_view key) noexcept;
219 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> find_field_unordered_raw(const std::string_view key) noexcept;
236 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> start_array() noexcept;
244 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> start_root_array() noexcept;
252 simdjson_warn_unused simdjson_inline
error_code check_root_array() noexcept;
262 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> started_array() noexcept;
272 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> started_root_array() noexcept;
283 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> has_next_element() noexcept;
288 simdjson_warn_unused simdjson_inline value_iterator child() const noexcept;
298 simdjson_warn_unused simdjson_inline
simdjson_result<std::string_view> get_string(
bool allow_replacement) noexcept;
299 template <typename string_type>
300 simdjson_warn_unused simdjson_inline
error_code get_string(string_type& receiver,
bool allow_replacement) noexcept;
301 simdjson_warn_unused simdjson_inline
simdjson_result<std::string_view> get_wobbly_string() noexcept;
303 simdjson_warn_unused simdjson_inline
simdjson_result<uint64_t> get_uint64() noexcept;
304 simdjson_warn_unused simdjson_inline
simdjson_result<uint64_t> get_uint64_in_string() noexcept;
305 simdjson_warn_unused simdjson_inline
simdjson_result<int64_t> get_int64() noexcept;
306 simdjson_warn_unused simdjson_inline
simdjson_result<int64_t> get_int64_in_string() noexcept;
307 simdjson_warn_unused simdjson_inline
simdjson_result<
double> get_double() noexcept;
308 simdjson_warn_unused simdjson_inline
simdjson_result<
double> get_double_in_string() noexcept;
309 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> get_bool() noexcept;
310 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> is_null() noexcept;
311 simdjson_warn_unused simdjson_inline
bool is_negative() noexcept;
312 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> is_integer() noexcept;
313 simdjson_warn_unused simdjson_inline
simdjson_result<number_type> get_number_type() noexcept;
316 simdjson_warn_unused simdjson_inline
simdjson_result<std::string_view> get_root_string(
bool check_trailing,
bool allow_replacement) noexcept;
317 template <typename string_type>
318 simdjson_warn_unused simdjson_inline
error_code get_root_string(string_type& receiver,
bool check_trailing,
bool allow_replacement) noexcept;
319 simdjson_warn_unused simdjson_inline
simdjson_result<std::string_view> get_root_wobbly_string(
bool check_trailing) noexcept;
321 simdjson_warn_unused simdjson_inline
simdjson_result<uint64_t> get_root_uint64(
bool check_trailing) noexcept;
322 simdjson_warn_unused simdjson_inline
simdjson_result<uint64_t> get_root_uint64_in_string(
bool check_trailing) noexcept;
323 simdjson_warn_unused simdjson_inline
simdjson_result<int64_t> get_root_int64(
bool check_trailing) noexcept;
324 simdjson_warn_unused simdjson_inline
simdjson_result<int64_t> get_root_int64_in_string(
bool check_trailing) noexcept;
325 simdjson_warn_unused simdjson_inline
simdjson_result<
double> get_root_double(
bool check_trailing) noexcept;
326 simdjson_warn_unused simdjson_inline
simdjson_result<
double> get_root_double_in_string(
bool check_trailing) noexcept;
327 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> get_root_bool(
bool check_trailing) noexcept;
328 simdjson_warn_unused simdjson_inline
bool is_root_negative() noexcept;
329 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> is_root_integer(
bool check_trailing) noexcept;
330 simdjson_warn_unused simdjson_inline
simdjson_result<number_type> get_root_number_type(
bool check_trailing) noexcept;
331 simdjson_warn_unused simdjson_inline
simdjson_result<
number> get_root_number(
bool check_trailing) noexcept;
332 simdjson_warn_unused simdjson_inline
simdjson_result<
bool> is_root_null(
bool check_trailing) noexcept;
334 simdjson_inline
error_code error() const noexcept;
335 simdjson_inline uint8_t *&string_buf_loc() noexcept;
336 simdjson_inline const json_iterator &json_iter() const noexcept;
337 simdjson_inline json_iterator &json_iter() noexcept;
339 simdjson_inline
void assert_is_valid() const noexcept;
340 simdjson_inline
bool is_valid() const noexcept;
361 simdjson_inline
void move_at_start() noexcept;
369 simdjson_inline
void move_at_container_start() noexcept;
371 inline std::
string to_string() const noexcept;
372 simdjson_inline value_iterator(json_iterator *json_iter,
depth_t depth, token_position start_index) noexcept;
374 simdjson_inline
simdjson_result<
bool> parse_null(const uint8_t *json) const noexcept;
375 simdjson_inline
simdjson_result<
bool> parse_bool(const uint8_t *json) const noexcept;
376 simdjson_inline const uint8_t *peek_start() const noexcept;
377 simdjson_inline uint32_t peek_start_length() const noexcept;
378 simdjson_inline uint32_t peek_root_length() const noexcept;
409 simdjson_inline
void advance_scalar(const
char *type) noexcept;
410 simdjson_inline
void advance_root_scalar(const
char *type) noexcept;
411 simdjson_inline
void advance_non_root_scalar(const
char *type) noexcept;
413 simdjson_inline const uint8_t *peek_scalar(const
char *type) noexcept;
414 simdjson_inline const uint8_t *peek_root_scalar(const
char *type) noexcept;
415 simdjson_inline const uint8_t *peek_non_root_scalar(const
char *type) noexcept;
418 simdjson_inline
error_code start_container(uint8_t start_char, const
char *incorrect_type_message, const
char *type) noexcept;
419 simdjson_inline
error_code end_container() noexcept;
427 simdjson_inline
simdjson_result<const uint8_t *> advance_to_value() noexcept;
429 simdjson_inline
error_code incorrect_type_error(const
char *message) const noexcept;
430 simdjson_inline
error_code error_unless_more_tokens(uint32_t tokens=1) const noexcept;
432 simdjson_inline
bool is_at_start() const noexcept;
439 simdjson_inline
bool is_at_iterator_start() const noexcept;
448 simdjson_inline
bool is_at_key() const noexcept;
450 inline
void assert_at_start() const noexcept;
451 inline
void assert_at_container_start() const noexcept;
452 inline
void assert_at_root() const noexcept;
453 inline
void assert_at_child() const noexcept;
454 inline
void assert_at_next() const noexcept;
455 inline
void assert_at_non_root_start() const noexcept;
458 simdjson_inline token_position start_position() const noexcept;
461 simdjson_inline token_position position() const noexcept;
463 simdjson_inline token_position last_position() const noexcept;
465 simdjson_inline token_position end_position() const noexcept;
485 simdjson_inline
simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::value_iterator &&value) noexcept;
A forward-only JSON array.
A JSON field (key/value pair) in an object.
A string escaped per JSON rules, terminated with quote (").
An ephemeral JSON value returned during iteration.
json_type
The type of a JSON value.
int32_t depth_t
Represents the depth of a JSON value (number of nested arrays/objects).
The top level simdjson namespace, containing everything the library provides.
error_code
All possible errors returned by simdjson.
std::string to_string(T x)
Converts JSON to a string.
The result of a simdjson operation that could fail.
A type representing a JSON number.
The result of a simdjson operation that could fail.