Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
HeaderStream Class Reference

Stream implementation that takes a fixed number of bytes, filling in a header structure, and then returns EOF. More...

#include <SyncStream.hxx>

Inheritance diagram for HeaderStream:
SyncStream

Public Member Functions

 HeaderStream (void *header, size_t header_size)
 
ssize_t write (const void *data, size_t len) override
 Main entry point to the data consumption.
 
- Public Member Functions inherited from SyncStream
virtual int finalize (int status)
 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.
 

Private Attributes

uint8_t * data_
 Pointer where we need to save the incoming bytes.
 
size_t remaining_
 How many bytes we still need to save.
 

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.
 

Detailed Description

Stream implementation that takes a fixed number of bytes, filling in a header structure, and then returns EOF.

Definition at line 113 of file SyncStream.hxx.

Constructor & Destructor Documentation

◆ HeaderStream()

HeaderStream::HeaderStream ( void *  header,
size_t  header_size 
)
inline

Definition at line 116 of file SyncStream.hxx.

Member Function Documentation

◆ write()

ssize_t HeaderStream::write ( const void *  data,
size_t  len 
)
inlineoverridevirtual

Main entry point to the data consumption.

Parameters
datais the pointer to a block of data to consume.
lenis 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 122 of file SyncStream.hxx.

Member Data Documentation

◆ data_

uint8_t* HeaderStream::data_
private

Pointer where we need to save the incoming bytes.

Definition at line 140 of file SyncStream.hxx.

◆ remaining_

size_t HeaderStream::remaining_
private

How many bytes we still need to save.

Definition at line 142 of file SyncStream.hxx.


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