Stream wrapper that limits the number of bytes sent to the child stream, and reports EOF after the given length.
More...
#include <SyncStream.hxx>
|
| | MaxLengthStream (size_t length, SyncStream *delegate) |
| |
| ssize_t | write (const void *data, size_t len) override |
| | Main entry point to the data consumption.
|
| |
| | WrappedStream (SyncStream *delegate) |
| |
| void | set_delegate (SyncStream *delegate) |
| | Overrides the target where to send the incoming data onwards.
|
| |
| int | finalize (int status) override |
| | Called once after all data has been written to close the stream and release resources.
|
| |
| ssize_t | write_all (const void *data, size_t len) |
| | Repeatedly writes until all data has been consumed or an error occurs.
|
| |
|
| size_t | remaining_ |
| | How many bytes we still have to write.
|
| |
|
| static const uint8_t * | to_8 (const void *d) |
| | Converts a void pointer to an equivalent byte pointer.
|
| |
| static uint8_t * | to_8 (void *d) |
| | Converts a void pointer to an equivalent byte pointer.
|
| |
| std::unique_ptr< SyncStream > | delegate_ |
| | Where to write the data to.
|
| |
Stream wrapper that limits the number of bytes sent to the child stream, and reports EOF after the given length.
Definition at line 186 of file SyncStream.hxx.
◆ MaxLengthStream()
| MaxLengthStream::MaxLengthStream |
( |
size_t |
length, |
|
|
SyncStream * |
delegate |
|
) |
| |
|
inline |
- Parameters
-
| length | is the number of bytes after which to report error. |
| delegate | is the wrapped stream. Takes ownership of the pointer. |
Definition at line 191 of file SyncStream.hxx.
◆ ~MaxLengthStream()
| MaxLengthStream::~MaxLengthStream |
( |
| ) |
|
|
inline |
◆ write()
| ssize_t MaxLengthStream::write |
( |
const void * |
data, |
|
|
size_t |
len |
|
) |
| |
|
inlineoverridevirtual |
Main entry point to the data consumption.
- Parameters
-
| data | is the pointer to a block of data to consume. |
| len | is the number of bytes to consume. |
- Returns
- 0 if the stream is completed/EOF (not consuming data anymore); negative value if there is an error; or the number of bytes consumed from the stream.
Implements SyncStream.
Definition at line 201 of file SyncStream.hxx.
◆ remaining_
| size_t MaxLengthStream::remaining_ |
|
private |
How many bytes we still have to write.
Definition at line 222 of file SyncStream.hxx.
The documentation for this class was generated from the following file: