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

Simple stream implementation that appends all data to a given std::string. More...

#include <SyncStream.hxx>

Inheritance diagram for StringAppendStream:
SyncStream

Public Member Functions

 StringAppendStream (std::string *output)
 
void set_output (std::string *output)
 
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

std::string * output_
 

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

Simple stream implementation that appends all data to a given std::string.

Definition at line 330 of file SyncStream.hxx.

Constructor & Destructor Documentation

◆ StringAppendStream()

StringAppendStream::StringAppendStream ( std::string *  output)
inline
Parameters
outputis the string to write the data to. Does NOT take ownership of the pointer.

Definition at line 334 of file SyncStream.hxx.

Member Function Documentation

◆ set_output()

void StringAppendStream::set_output ( std::string *  output)
inline

Definition at line 337 of file SyncStream.hxx.

◆ write()

ssize_t StringAppendStream::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 341 of file SyncStream.hxx.

Member Data Documentation

◆ output_

std::string* StringAppendStream::output_
private

Definition at line 347 of file SyncStream.hxx.


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