simdjson  3.11.0
Ridiculously Fast JSON
simdjson::dom::document_stream Class Reference

A forward-only stream of documents. More...

Classes

class  iterator
 An iterator through a forward-only stream of documents. More...
 

Public Member Functions

simdjson_inline document_stream () noexcept
 Construct an uninitialized document_stream. More...
 
simdjson_inline document_stream (document_stream &&other) noexcept=default
 Move one document_stream to another.
 
simdjson_inline document_streamoperator= (document_stream &&other) noexcept=default
 Move one document_stream to another.
 
size_t size_in_bytes () const noexcept
 Returns the input size in bytes.
 
size_t truncated_bytes () const noexcept
 After iterating through the stream, this method returns the number of bytes that were not parsed at the end of the stream. More...
 
simdjson_inline iterator begin () noexcept
 Start iterating the documents in the stream.
 
simdjson_inline iterator end () noexcept
 The end of the stream, for iterator comparison purposes.
 

Detailed Description

A forward-only stream of documents.

Produced by parser::parse_many.

Definition at line 72 of file document_stream.h.

Constructor & Destructor Documentation

◆ document_stream()

simdjson_inline simdjson::dom::document_stream::document_stream ( )
noexcept

Construct an uninitialized document_stream.

{c++}
error = parser.parse_many(json).get(docs);
simdjson_inline document_stream() noexcept
Construct an uninitialized document_stream.
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.
Definition: parser-inl.h:170

Definition at line 110 of file document_stream-inl.h.

Member Function Documentation

◆ truncated_bytes()

size_t simdjson::dom::document_stream::truncated_bytes ( ) const
inlinenoexcept

After iterating through the stream, this method returns the number of bytes that were not parsed at the end of the stream.

If truncated_bytes() differs from zero, then the input was truncated maybe because incomplete JSON documents were found at the end of the stream. You may need to process the bytes in the interval [size_in_bytes()-truncated_bytes(), size_in_bytes()).

You should only call truncated_bytes() after streaming through all documents, like so:

document_stream stream = parser.parse_many(json,window); for(auto doc : stream) { // do something with doc } size_t truncated = stream.truncated_bytes();

Definition at line 266 of file document_stream-inl.h.


The documentation for this class was generated from the following files: