1#ifndef SIMDJSON_GENERIC_ONDEMAND_JSON_ITERATOR_H
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_JSON_ITERATOR_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/implementation_simdjson_result_base.h"
7#include "simdjson/generic/ondemand/token_iterator.h"
11namespace SIMDJSON_IMPLEMENTATION {
21 token_iterator token{};
22 ondemand::parser *parser{};
28 uint8_t *_string_buf_loc{};
55 token_position _root{};
62 bool _streaming{
false};
63#ifdef SIMDJSON_EXPERIMENTAL_ALLOW_INCOMPLETE_JSON
64 bool _allow_incomplete_json{
false};
68 simdjson_inline json_iterator() noexcept = default;
69 simdjson_inline json_iterator(json_iterator &&other) noexcept;
70 simdjson_inline json_iterator &operator=(json_iterator &&other) noexcept;
71 simdjson_inline explicit json_iterator(const json_iterator &other) noexcept = default;
72 simdjson_inline json_iterator &operator=(const json_iterator &other) noexcept = default;
76 simdjson_warn_unused simdjson_inline
error_code skip_child(
depth_t parent_depth) noexcept;
81 simdjson_inline
bool at_root() const noexcept;
89 simdjson_inline
bool streaming() const noexcept;
90#ifdef SIMDJSON_EXPERIMENTAL_ALLOW_INCOMPLETE_JSON
91 simdjson_inline
bool allow_incomplete_json() const noexcept;
92 simdjson_inline
size_t remaining_input_length(const uint8_t *json) const noexcept;
98 simdjson_inline token_position root_position() const noexcept;
102 simdjson_inline
void assert_at_document_depth() const noexcept;
106 simdjson_inline
void assert_at_root() const noexcept;
111 simdjson_inline
bool at_end() const noexcept;
116 simdjson_inline
bool is_alive() const noexcept;
121 simdjson_inline
void abandon() noexcept;
126 simdjson_inline const uint8_t *return_current_and_advance() noexcept;
134 simdjson_inline
bool is_single_token() const noexcept;
141 simdjson_inline
void assert_more_tokens(uint32_t required_tokens=1) const noexcept;
147 simdjson_inline
void assert_valid_position(token_position position) const noexcept;
158 simdjson_inline const uint8_t *peek(int32_t delta=0) const noexcept;
166 simdjson_inline uint32_t peek_length(int32_t delta=0) const noexcept;
175 simdjson_inline const uint8_t *unsafe_pointer() const noexcept;
186 simdjson_inline const uint8_t *peek(token_position position) const noexcept;
194 simdjson_inline uint32_t peek_length(token_position position) const noexcept;
202 simdjson_inline uint32_t peek_root_length(token_position position) const noexcept;
211 simdjson_inline const uint8_t *peek_last() const noexcept;
220 simdjson_inline
void ascend_to(
depth_t parent_depth) noexcept;
229 simdjson_inline
void descend_to(
depth_t child_depth) noexcept;
230 simdjson_inline
void descend_to(
depth_t child_depth, int32_t delta) noexcept;
235 simdjson_inline
depth_t depth() const noexcept;
240 simdjson_inline uint8_t *&string_buf_loc() noexcept;
248 simdjson_warn_unused simdjson_inline
error_code report_error(
error_code error, const
char *message) noexcept;
255 simdjson_warn_unused simdjson_inline
error_code optional_error(
error_code error, const
char *message) noexcept;
262 simdjson_warn_unused simdjson_inline
bool copy_to_buffer(const uint8_t *json, uint32_t max_len, uint8_t *tmpbuf,
size_t N) noexcept;
264 simdjson_inline token_position position() const noexcept;
270 simdjson_inline simdjson_result<std::string_view> unescape(raw_json_string in,
bool allow_replacement) noexcept;
271 simdjson_inline simdjson_result<std::string_view> unescape_wobbly(raw_json_string in) noexcept;
273 simdjson_inline
void reenter_child(token_position position,
depth_t child_depth) noexcept;
275 simdjson_warn_unused simdjson_inline
error_code consume_character(
char c) noexcept;
276#if SIMDJSON_DEVELOPMENT_CHECKS
277 simdjson_inline token_position start_position(
depth_t depth)
const noexcept;
278 simdjson_inline
void set_start_position(
depth_t depth, token_position position)
noexcept;
282 inline std::string
to_string() const noexcept;
287 inline simdjson_result<const
char *> current_location() const noexcept;
293 inline
void rewind() noexcept;
300 inline
bool balanced() const noexcept;
302 simdjson_inline json_iterator(const uint8_t *buf, ondemand::parser *parser) noexcept;
303#ifdef SIMDJSON_EXPERIMENTAL_ALLOW_INCOMPLETE_JSON
304 simdjson_inline json_iterator(
const uint8_t *buf, ondemand::parser *parser,
bool streaming)
noexcept;
307 simdjson_inline token_position last_position() const noexcept;
309 simdjson_inline token_position end_position() const noexcept;
311 simdjson_inline token_position end() const noexcept;
313 friend class document;
314 friend class document_stream;
318 friend class raw_json_string;
320 friend class value_iterator;
322 template <typename... Args>
323 friend simdjson_inline
void logger::log_line(const json_iterator &iter, const
char *title_prefix, const
char *title, std::string_view detail,
int delta,
int depth_delta, logger::log_level level, Args&&... args) noexcept;
324 template <typename... Args>
325 friend simdjson_inline
void logger::log_line(const json_iterator &iter, token_position index,
depth_t depth, const
char *title_prefix, const
char *title, std::string_view detail, logger::log_level level, Args&&... args) noexcept;
337 simdjson_inline
simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::json_iterator &&value)
noexcept;
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.
The result of a simdjson operation that could fail.