OpenEnroth cf228e9
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
BlobOutputStream Class Reference

#include <BlobOutputStream.h>

Inheritance diagram for BlobOutputStream:
OutputStream detail::MemoryFileSystemOutputStream

Public Member Functions

 BlobOutputStream ()=default
 
 BlobOutputStream (Blob *target, std::string_view displayPath={})
 
virtual ~BlobOutputStream ()
 
void open (Blob *target, std::string_view displayPath={})
 
- Public Member Functions inherited from OutputStream
virtual ~OutputStream ()
 
void write (const void *data, size_t size)
 
void write (std::string_view s)
 
void write (const Blob &blob)
 
void flush ()
 
void close ()
 
bool isOpen () const
 
size_t position () const
 
size_t size () const
 
const std::string & displayPath () const
 

Protected Member Functions

virtual void _overflow (const void *data, size_t size, Buffer *buffer) override
 
virtual void _flush (Buffer *buffer) override
 
virtual void _close (Buffer *buffer) override
 
- Protected Member Functions inherited from OutputStream
 OutputStream ()=default
 
void open (Buffer buffer, std::string_view displayPath)
 
virtual void _overflow (const void *data, size_t size, Buffer *buffer)=0
 
virtual void _flush (Buffer *buffer)=0
 
virtual void _close (Buffer *buffer)=0
 

Private Types

using base_type = OutputStream
 

Private Member Functions

Blob materialize ()
 
void closeInternal ()
 

Private Attributes

Blob_target = nullptr
 
ChunkBuffer _chunks
 

Additional Inherited Members

- Public Types inherited from OutputStream
using Buffer = StreamBuffer< char >
 

Detailed Description

Output stream that writes into a Blob.

Data is accumulated in geometrically growing internal chunks (1KB up to 1MB) and transferred to the target Blob when close() is called. Calling flush() also transfers data but always makes a copy. close() can avoid the copy when all data fits in a single chunk.

Member Typedef Documentation

◆ base_type

Constructor & Destructor Documentation

◆ BlobOutputStream() [1/2]

BlobOutputStream::BlobOutputStream ( )
default

◆ BlobOutputStream() [2/2]

BlobOutputStream::BlobOutputStream ( Blob target,
std::string_view  displayPath = {} 
)
explicit
Parameters
targetBlob to write into. Must outlive this stream.
displayPathDisplay path for error reporting.

◆ ~BlobOutputStream()

BlobOutputStream::~BlobOutputStream ( )
virtual

Member Function Documentation

◆ _close()

void BlobOutputStream::_close ( Buffer buffer)
overrideprotectedvirtual

Flushes any remaining buffered data and releases held resources.

Derived implementations should call OutputStream::_close() at the end.

Parameters
[in,out]bufferCurrent buffer state.
Exceptions
ExceptionOn error.

Implements OutputStream.

Reimplemented in detail::MemoryFileSystemOutputStream.

◆ _flush()

void BlobOutputStream::_flush ( Buffer buffer)
overrideprotectedvirtual

Flushes buffered data to the underlying target.

Parameters
[in,out]bufferCurrent buffer state.
Exceptions
ExceptionOn error.

Implements OutputStream.

◆ _overflow()

void BlobOutputStream::_overflow ( const void *  data,
size_t  size,
Buffer buffer 
)
overrideprotectedvirtual

Called when a write doesn't fit in the current buffer. Implementations should handle the overflow data (write it out or store it), and provide a new writable buffer via the out parameter.

Parameters
dataPointer to the overflow data to write.
sizeSize of the overflow data, always greater than buffer->remaining().
[in,out]bufferCurrent buffer state on input. Set to the new buffer state on output. Data in [buffer->start, buffer->pos) is treated as dirty (not yet flushed).
Exceptions
ExceptionOn error.

Implements OutputStream.

◆ closeInternal()

void BlobOutputStream::closeInternal ( )
private

◆ materialize()

Blob BlobOutputStream::materialize ( )
private

◆ open()

void BlobOutputStream::open ( Blob target,
std::string_view  displayPath = {} 
)

Opens the stream for writing into the given blob.

Parameters
targetBlob to write into. Must outlive this stream.
displayPathDisplay path for error reporting.

Member Data Documentation

◆ _chunks

ChunkBuffer BlobOutputStream::_chunks
private

◆ _target

Blob* BlobOutputStream::_target = nullptr
private

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