simdjson 5.0.2
Ridiculously Fast JSON
Loading...
Searching...
No Matches
base.h
1
5#ifndef SIMDJSON_BASE_H
6#define SIMDJSON_BASE_H
7
8#include "simdjson/common_defs.h"
9#include "simdjson/compiler_check.h"
10#include "simdjson/error.h"
11#include "simdjson/portability.h"
12#include "simdjson/concepts.h"
13#include "simdjson/constevalutil.h"
14
15#if SIMDJSON_SUPPORTS_CHAR8_T
16#include <string>
17#include <string_view>
18#endif
19
23namespace simdjson {
24
25SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS
26
28constexpr size_t SIMDJSON_MAXSIZE_BYTES = 0xFFFFFFFF;
33
42constexpr size_t SIMDJSON_PADDING = 64;
43
49constexpr size_t DEFAULT_MAX_DEPTH = 1024;
50
51SIMDJSON_POP_DISABLE_UNUSED_WARNINGS
52
53class implementation;
54struct padded_string;
56enum class stage1_mode;
57
81
82namespace internal {
83
84template<typename T>
85class atomic_ptr;
86class dom_parser_implementation;
87class escape_json_string;
88class tape_ref;
89struct value128;
90enum class tape_type;
91
92#if SIMDJSON_SUPPORTS_CHAR8_T
100simdjson_inline std::u8string_view as_u8string_view(std::string_view v) noexcept {
101 return std::u8string_view(reinterpret_cast<const char8_t *>(v.data()), v.size());
102}
103#endif // SIMDJSON_SUPPORTS_CHAR8_T
104
111template <typename string_type>
112simdjson_inline void assign_utf8(string_type &receiver, std::string_view content) noexcept {
113 receiver = content;
114}
115
116#if SIMDJSON_SUPPORTS_CHAR8_T
123template <typename traits_type, typename allocator_type>
124simdjson_inline void assign_utf8(std::basic_string<char8_t, traits_type, allocator_type> &receiver, std::string_view content) noexcept {
125 receiver.assign(reinterpret_cast<const char8_t *>(content.data()), content.size());
126}
127
132template <typename traits_type>
133simdjson_inline void assign_utf8(std::basic_string_view<char8_t, traits_type> &receiver, std::string_view content) noexcept {
134 receiver = std::basic_string_view<char8_t, traits_type>(reinterpret_cast<const char8_t *>(content.data()), content.size());
135}
136#endif // SIMDJSON_SUPPORTS_CHAR8_T
137
138} // namespace internal
139} // namespace simdjson
140
141#endif // SIMDJSON_BASE_H
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.
Definition base.h:8
constexpr size_t SIMDJSON_MAX_DEPTH
The maximum depth of nested objects and arrays supported by simdjson.
Definition base.h:32
stream_format
Stream format for parse_many/iterate_many.
Definition base.h:61
@ comma_delimited
Comma-separated JSON documents (e.g., {...},{...},{...})
@ whitespace_delimited
Whitespace-delimited JSON documents (default, includes NDJSON/JSONL)
@ newline_delimited
NDJSON/JSON Lines where each document occupies exactly one line: documents are separated by line feed...
@ comma_delimited_array
A single JSON array whose elements are iterated as comma-separated documents (e.g....
@ json_sequence
RFC 7464 JSON text sequences (RS-delimited)
constexpr size_t DEFAULT_MAX_DEPTH
By default, simdjson supports this many nested objects and arrays.
Definition base.h:49
SIMDJSON_PUSH_DISABLE_UNUSED_WARNINGS constexpr size_t SIMDJSON_MAXSIZE_BYTES
The maximum document size supported by simdjson.
Definition base.h:28
stage1_mode
This enum is used with the dom_parser_implementation::stage1 function.
constexpr size_t SIMDJSON_PADDING
The amount of padding needed in a buffer to parse JSON.
Definition base.h:42
String with extra allocation for ease of use with parser::parse()