1#ifndef SIMDJSON_GENERIC_ONDEMAND_PARSER_H
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_PARSER_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/implementation_simdjson_result_base.h"
13namespace SIMDJSON_IMPLEMENTATION {
21static constexpr size_t DEFAULT_BATCH_SIZE = 1000000;
30static constexpr size_t MINIMAL_BATCH_SIZE = 32;
48 simdjson_inline
parser &operator=(
const parser &other) =
delete;
49 simdjson_inline
parser &operator=(
parser &&other)
noexcept =
default;
118#ifdef SIMDJSON_EXPERIMENTAL_ALLOW_INCOMPLETE_JSON
122 simdjson_warn_unused simdjson_result<document> iterate(const char *json, size_t len, size_t capacity) & noexcept;
274 simdjson_pure simdjson_inline
size_t capacity() const noexcept;
276 simdjson_pure simdjson_inline
size_t max_capacity() const noexcept;
277 simdjson_inline
void set_max_capacity(
size_t max_capacity) noexcept;
284 simdjson_pure simdjson_inline
size_t max_depth() const noexcept;
300 #ifdef SIMDJSON_THREADS_ENABLED
360#if SIMDJSON_DEVELOPMENT_CHECKS
368 bool string_buffer_overflow(
const uint8_t *string_buf_loc)
const noexcept;
382 static simdjson_inline simdjson_warn_unused ondemand::parser&
get_parser();
394 static simdjson_inline simdjson_warn_unused std::unique_ptr<ondemand::parser>& get_parser_instance();
396 static simdjson_inline simdjson_warn_unused std::unique_ptr<ondemand::parser>& get_threadlocal_parser_if_exists();
398 std::unique_ptr<simdjson::internal::dom_parser_implementation>
implementation{};
400 size_t _max_capacity;
402 std::unique_ptr<uint8_t[]> string_buf{};
404#if SIMDJSON_DEVELOPMENT_CHECKS
405 std::unique_ptr<token_position[]> start_positions{};
408 friend class json_iterator;
409 friend class document_stream;
419struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::parser> :
public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::parser> {
421 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::parser &&value)
noexcept;
423 simdjson_inline simdjson_result() noexcept = default;
A forward-only stream of documents.
A JSON fragment iterator.
simdjson_warn_unused simdjson_result< document > iterate(padded_string_view json) &noexcept
Start iterating an on-demand JSON document.
static simdjson_inline bool release_parser()
Release the parser instance initialized by get_parser() and all the associated resources (memory).
simdjson_pure simdjson_inline size_t max_capacity() const noexcept
The maximum capacity of this parser (the largest document it is allowed to process).
simdjson_inline simdjson_result< std::string_view > unescape(raw_json_string in, uint8_t *&dst, bool allow_replacement=false) const noexcept
Unescape this JSON string, replacing \ with \, with newline, etc.
~parser() noexcept=default
Deallocate the JSON parser.
simdjson_pure simdjson_inline size_t max_depth() const noexcept
The maximum depth of this parser (the most deeply nested objects and arrays it can process).
simdjson_pure simdjson_inline size_t capacity() const noexcept
The capacity of this parser (the largest document it can process).
simdjson_inline simdjson_result< std::string_view > unescape_wobbly(raw_json_string in, uint8_t *&dst) const noexcept
Unescape this JSON string, replacing \ with \, with newline, etc.
bool threaded
When SIMDJSON_THREADS_ENABLED is not defined, the parser instance cannot use threads.
simdjson_warn_unused error_code allocate(size_t capacity, size_t max_depth=DEFAULT_MAX_DEPTH) noexcept
Ensure this parser has enough memory to process JSON documents up to capacity bytes in length and max...
static simdjson_inline simdjson_warn_unused ondemand::parser & get_parser()
Get a unique parser instance corresponding to the current thread.
simdjson_result< document_stream > iterate_many(const uint8_t *buf, size_t len, size_t batch_size=DEFAULT_BATCH_SIZE, bool allow_comma_separated=false) noexcept
Parse a buffer containing many JSON documents.
A string escaped per JSON rules, terminated with quote (").
An implementation of simdjson for a particular CPU architecture.
User-provided string that promises it has extra padded bytes at the end for use with parser::parse().
The top level simdjson namespace, containing everything the library provides.
constexpr size_t DEFAULT_MAX_DEPTH
By default, simdjson supports this many nested objects and arrays.
error_code
All possible errors returned by simdjson.
SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS constexpr size_t SIMDJSON_MAXSIZE_BYTES
The maximum document size supported by simdjson.
String with extra allocation for ease of use with parser::parse()
The result of a simdjson operation that could fail.
simdjson_inline error_code error() const noexcept
The error.