1 #ifndef SIMDJSON_DOM_PARSER_H
2 #define SIMDJSON_DOM_PARSER_H
4 #include "simdjson/dom/base.h"
5 #include "simdjson/dom/document.h"
510 #ifndef SIMDJSON_DISABLE_DEPRECATED_API
522 [[deprecated(
"Use allocate() instead.")]]
530 simdjson_inline size_t capacity() const noexcept;
546 simdjson_pure simdjson_inline
size_t max_depth() const noexcept;
564 #ifdef SIMDJSON_THREADS_ENABLED
580 using InvalidJSON [[deprecated(
"Use simdjson_error instead")]] =
simdjson_error;
583 std::unique_ptr<internal::dom_parser_implementation>
implementation{};
594 [[deprecated(
"Use the result of parser.parse() instead")]]
595 inline bool is_valid() const noexcept;
601 [[deprecated("Use the result of
parser.
parse() instead")]]
602 inline
int get_error_code() const noexcept;
606 inline std::
string get_error_message() const noexcept;
609 [[deprecated("Use cout << on the result of
parser.
parse() instead")]]
610 inline
bool print_json(std::ostream &os) const noexcept;
613 inline
bool dump_raw_tape(std::ostream &os) const noexcept;
622 size_t _max_capacity;
627 std::unique_ptr<
char[]> loaded_bytes;
630 size_t _loaded_bytes_capacity{0};
651 inline error_code ensure_capacity(
size_t desired_capacity) noexcept;
657 inline error_code ensure_capacity(document& doc,
size_t desired_capacity) noexcept;
660 inline simdjson_result<size_t> read_file(
const std::string &path) noexcept;
662 friend class parser::Iterator;
663 friend class document_stream;
A persistent document parser.
simdjson_inline parser(size_t max_capacity=SIMDJSON_MAXSIZE_BYTES) noexcept
Create a JSON parser.
simdjson_result< element > parse(const uint8_t *buf, size_t len, bool realloc_if_needed=true) &noexcept
Parse a JSON document and return a temporary reference to it.
simdjson_result< element > parse_into_document(document &doc, const uint8_t *buf, size_t len, bool realloc_if_needed=true) &noexcept
Parse a JSON document into a provide document instance and return a temporary reference to it.
simdjson_inline parser(parser &&other) noexcept
Take another parser's buffers and state.
simdjson_result< document_stream > load_many(const std::string &path, size_t batch_size=dom::DEFAULT_BATCH_SIZE) noexcept
Load a file containing many JSON documents.
bool threaded
When SIMDJSON_THREADS_ENABLED is not defined, the parser instance cannot use threads.
simdjson_inline void set_max_capacity(size_t max_capacity) noexcept
Set max_capacity.
simdjson_inline size_t max_capacity() const noexcept
The largest document this parser can automatically support.
simdjson_pure simdjson_inline size_t max_depth() const noexcept
The maximum level of nested object and arrays supported by this parser.
simdjson_result< element > load(const std::string &path) &noexcept
Load a JSON document from a file and return a reference to it.
simdjson_result< element > load_into_document(document &doc, const std::string &path) &noexcept
Load a JSON document from a file into a provide document instance and return a temporary reference to...
~parser()=default
Deallocate the JSON parser.
simdjson_inline size_t capacity() const noexcept
The largest document this parser can support without reallocating.
simdjson_inline parser & operator=(parser &&other) noexcept
Take another parser's buffers and state.
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...
simdjson_result< document_stream > parse_many(const uint8_t *buf, size_t len, size_t batch_size=dom::DEFAULT_BATCH_SIZE) noexcept
Parse a buffer containing many JSON documents.
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 SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS size_t SIMDJSON_MAXSIZE_BYTES
The maximum document size supported by simdjson.
const char * error_message(error_code error) noexcept
It is the convention throughout the code that the macro SIMDJSON_DEVELOPMENT_CHECKS determines whethe...
constexpr size_t DEFAULT_MAX_DEPTH
By default, simdjson supports this many nested objects and arrays.
error_code
All possible errors returned by simdjson.
@ UNINITIALIZED
unknown error, or uninitialized document
String with extra allocation for ease of use with parser::parse()
Exception thrown when an exception-supporting simdjson method is called.
The result of a simdjson operation that could fail.