|
Open Model Railroad Network (OpenMRN)
|
Stream wrapper that contains a small internal buffer to ensure that all writes are at least a certain minimum size long. More...
#include <SyncStream.hxx>
Public Member Functions | |
| MinWriteStream (unsigned min_write_length, uint8_t fill_byte, SyncStream *delegate) | |
| MinWriteStream (unsigned min_write_length, SyncStream *delegate) | |
| ssize_t | write (const void *data, size_t len) override |
| Main entry point to the data consumption. | |
| int | finalize (int status) override |
| Called once after all data has been written to close the stream and release resources. | |
Public Member Functions inherited from WrappedStream | |
| 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. | |
Public Member Functions inherited from SyncStream | |
| ssize_t | write_all (const void *data, size_t len) |
| Repeatedly writes until all data has been consumed or an error occurs. | |
Private Attributes | |
| uint8_t * | buffer_ |
| unsigned | bufLength_ |
| Number of used bytes in the buffer. | |
| unsigned | minWriteLength_ |
| Total length of the buffer. | |
| uint8_t | fillByte_ |
| What byte to append to the stream at finalize time when we still have bytes to send onwards. | |
| uint8_t | needsFill_ |
| Whether to do fill (1: yes, 0: no). | |
Additional Inherited Members | |
Static Protected Member Functions inherited from SyncStream | |
| 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. | |
Protected Attributes inherited from WrappedStream | |
| std::unique_ptr< SyncStream > | delegate_ |
| Where to write the data to. | |
Stream wrapper that contains a small internal buffer to ensure that all writes are at least a certain minimum size long.
The delegate has to guarantee that it will always accept a min_size length write.
Definition at line 228 of file SyncStream.hxx.
|
inline |
Definition at line 231 of file SyncStream.hxx.
|
inline |
Definition at line 242 of file SyncStream.hxx.
|
inline |
Definition at line 252 of file SyncStream.hxx.
|
inlineoverridevirtual |
Called once after all data has been written to close the stream and release resources.
Return 0 on success, <0 on failure.
| status | is an error code seen by wrapping streams. Default 0 (OK), if negative, streams might want to roll back their changes. |
Reimplemented from SyncStream.
Definition at line 299 of file SyncStream.hxx.
|
inlineoverridevirtual |
Main entry point to the data consumption.
| data | is the pointer to a block of data to consume. |
| len | is the number of bytes to consume. |
Implements SyncStream.
Definition at line 258 of file SyncStream.hxx.
|
private |
Definition at line 315 of file SyncStream.hxx.
|
private |
Number of used bytes in the buffer.
Definition at line 317 of file SyncStream.hxx.
|
private |
What byte to append to the stream at finalize time when we still have bytes to send onwards.
Definition at line 323 of file SyncStream.hxx.
|
private |
Total length of the buffer.
All writes to the downstream object will be at least this long.
Definition at line 320 of file SyncStream.hxx.
|
private |
Whether to do fill (1: yes, 0: no).
Definition at line 325 of file SyncStream.hxx.