|
OpenEnroth cf228e9
|
#include <BlobOutputStream.h>
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 > |
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.
|
private |
|
default |
|
explicit |
| target | Blob to write into. Must outlive this stream. |
| displayPath | Display path for error reporting. |
|
virtual |
|
overrideprotectedvirtual |
Flushes any remaining buffered data and releases held resources.
Derived implementations should call OutputStream::_close() at the end.
| [in,out] | buffer | Current buffer state. |
| Exception | On error. |
Implements OutputStream.
Reimplemented in detail::MemoryFileSystemOutputStream.
|
overrideprotectedvirtual |
Flushes buffered data to the underlying target.
| [in,out] | buffer | Current buffer state. |
| Exception | On error. |
Implements OutputStream.
|
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.
| data | Pointer to the overflow data to write. | |
| size | Size of the overflow data, always greater than buffer->remaining(). | |
| [in,out] | buffer | Current 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). |
| Exception | On error. |
Implements OutputStream.
|
private |
|
private |
| void BlobOutputStream::open | ( | Blob * | target, |
| std::string_view | displayPath = {} |
||
| ) |
Opens the stream for writing into the given blob.
| target | Blob to write into. Must outlive this stream. |
| displayPath | Display path for error reporting. |
|
private |
|
private |