1#ifndef SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_STREAM_H
3#ifndef SIMDJSON_CONDITIONAL_INCLUDE
4#define SIMDJSON_GENERIC_ONDEMAND_DOCUMENT_STREAM_H
5#include "simdjson/generic/ondemand/base.h"
6#include "simdjson/generic/implementation_simdjson_result_base.h"
7#include "simdjson/generic/ondemand/document.h"
8#include "simdjson/generic/ondemand/parser.h"
11#ifdef SIMDJSON_THREADS_ENABLED
14#include <condition_variable>
18namespace SIMDJSON_IMPLEMENTATION {
21#ifdef SIMDJSON_THREADS_ENABLED
38 void run(document_stream *
ds, parser * stage1,
size_t next_batch_start);
55 document_stream *
owner{};
69 friend class document_stream;
127 using difference_type = std::ptrdiff_t;
128 using iterator_category = std::input_iterator_tag;
133 simdjson_inline
iterator()
noexcept;
138 simdjson_inline
reference operator*()
noexcept;
142 inline iterator& operator++()
noexcept;
147 simdjson_inline
bool operator!=(
const iterator &
other)
const noexcept;
164 simdjson_inline
size_t current_index()
const noexcept;
185 simdjson_inline std::string_view source()
const noexcept;
195 inline bool at_end()
const noexcept;
206 friend class json_iterator;
238 bool allow_comma_separated
286 bool allow_comma_separated;
295 size_t batch_start{0};
298 #ifdef SIMDJSON_THREADS_ENABLED
302 inline void load_from_stage1_thread() noexcept;
305 inline
void start_stage1_thread() noexcept;
308 inline
void finish_stage1_thread() noexcept;
313 std::unique_ptr<stage1_worker> worker{
new(std::nothrow) stage1_worker()};
318 ondemand::parser stage1_thread_parser{};
320 friend struct stage1_worker;
324 friend class document;
325 friend class json_iterator;
327 friend struct simdjson::internal::simdjson_result_base<ondemand::document_stream>;
336struct simdjson_result<SIMDJSON_IMPLEMENTATION::ondemand::document_stream> :
public SIMDJSON_IMPLEMENTATION::implementation_simdjson_result_base<SIMDJSON_IMPLEMENTATION::ondemand::document_stream> {
338 simdjson_inline simdjson_result(SIMDJSON_IMPLEMENTATION::ondemand::document_stream &&value)
noexcept;
339 simdjson_inline simdjson_result(error_code error)
noexcept;
340 simdjson_inline simdjson_result() noexcept = default;
A forward-only JSON array.
simdjson_inline array() noexcept=default
Create a new invalid array.
A forward-only stream of documents.
simdjson_inline iterator end() noexcept
The end of the stream, for iterator comparison purposes.
simdjson_inline document_stream(document_stream &&other) noexcept=default
Move one document_stream to another.
size_t size_in_bytes() const noexcept
Returns the input size in bytes.
simdjson_inline document_stream & operator=(document_stream &&other) noexcept=default
Move one document_stream to another.
size_t truncated_bytes() const noexcept
After iterating through the stream, this method returns the number of bytes that were not parsed at t...
simdjson_inline iterator begin() noexcept
Start iterating the documents in the stream.
simdjson_inline document_stream() noexcept
Construct an uninitialized document_stream.
A JSON fragment iterator.
simdjson_unused simdjson_inline bool operator==(const raw_json_string &a, std::string_view c) noexcept
Comparisons between raw_json_string and std::string_view instances are potentially unsafe: the user i...
The top level simdjson namespace, containing everything the library provides.
error_code
All possible errors returned by simdjson.
@ UNINITIALIZED
unknown error, or uninitialized document