1 #ifndef SIMDJSON_GENERIC_DOM_PARSER_IMPLEMENTATION_H
3 #ifndef SIMDJSON_CONDITIONAL_INCLUDE
4 #define SIMDJSON_GENERIC_DOM_PARSER_IMPLEMENTATION_H
5 #include "simdjson/generic/base.h"
6 #include "simdjson/internal/dom_parser_implementation.h"
10 namespace SIMDJSON_IMPLEMENTATION {
18 static_assert(
sizeof(
open_container) == 64/8,
"Open container must be 64 bits");
39 simdjson_warn_unused
error_code parse(const uint8_t *
buf,
size_t len, dom::document &
doc) noexcept final;
41 simdjson_warn_unused
error_code stage2(dom::document &
doc) noexcept final;
42 simdjson_warn_unused
error_code stage2_next(dom::document &
doc) noexcept final;
43 simdjson_warn_unused uint8_t *parse_string(const uint8_t *src, uint8_t *dst,
bool allow_replacement) const noexcept final;
44 simdjson_warn_unused uint8_t *parse_wobbly_string(const uint8_t *src, uint8_t *dst) const noexcept final;
45 inline simdjson_warn_unused
error_code set_capacity(
size_t capacity) noexcept final;
46 inline simdjson_warn_unused
error_code set_max_depth(
size_t max_depth) noexcept final;
48 simdjson_inline simdjson_warn_unused
error_code set_capacity_stage1(
size_t capacity);
56 namespace SIMDJSON_IMPLEMENTATION {
58 inline dom_parser_implementation::dom_parser_implementation() noexcept = default;
66 size_t max_structures = SIMDJSON_ROUNDUP_N(capacity, 64) + 2 + 7;
67 structural_indexes.reset(
new (std::nothrow) uint32_t[max_structures] );
68 if (!structural_indexes) { _capacity = 0;
return MEMALLOC; }
69 structural_indexes[0] = 0;
70 n_structural_indexes = 0;
76 inline simdjson_warn_unused
error_code dom_parser_implementation::set_max_depth(
size_t max_depth) noexcept {
79 is_array.reset(
new (std::nothrow)
bool[max_depth]);
82 _max_depth = max_depth;
size_t len
Length passed to stage 1.
dom::document * doc
Document passed to stage 2.
const uint8_t * buf
Buffer passed to stage 1.
std::unique_ptr< bool[]> is_array
Whether each open container is a [ or {.
std::unique_ptr< open_container[]> open_containers
Tape location of each open { or [.
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.
error_code
All possible errors returned by simdjson.
@ CAPACITY
This parser can't support a document that big.
@ MEMALLOC
Error allocating memory, most likely out of memory.
stage1_mode
This enum is used with the dom_parser_implementation::stage1 function.