Base module
StreamWriter
Packet stream writer class.
StreamWriter
#include <icy/packetio.h>Inherits:
PacketProcessor
Packet stream writer class.
This class can be connected to a [PacketStream](icy-PacketStream.html#packetstream) to write output to any class that derives from std::ostream. It's most regularly used for writing output files.
Public Attributes
| Return | Name | Description |
|---|---|---|
PacketSignal | emitter |
emitter
PacketSignal emitterPublic Methods
| Return | Name | Description |
|---|---|---|
StreamWriter inline | #### Parameters | |
~StreamWriter virtual inline | Closes any open std::ofstream and deletes the owned stream. | |
void | process virtual inline | Serializes the packet via write(), flushes it to the output stream, then forwards the packet to the next processor. |
StreamT & | stream inline | Returns the internal output stream cast to StreamT. |
void | onStreamStateChange virtual inline | Closes the output file on Closed or [Error](icy-Error.html#error) stream state transitions. |
std::ostream & | stream inline | #### Returns |
StreamWriter
inline
inline StreamWriter(std::ostream * stream)Parameters
streamOutput stream to write to; takes ownership.
~StreamWriter
virtual inline
virtual inline ~StreamWriter()Closes any open std::ofstream and deletes the owned stream.
process
virtual inline
virtual inline void process(IPacket & packet)Serializes the packet via write(), flushes it to the output stream, then forwards the packet to the next processor.
Parameters
packetIncoming packet to process.
stream
inline
template<class StreamT> inline StreamT & stream()Returns the internal output stream cast to StreamT.
Parameters
StreamTTarget stream type derived fromstd::ostream.
Returns
Reference to the cast stream.
Exceptions
std::runtime_errorif the cast fails.
onStreamStateChange
virtual inline
virtual inline void onStreamStateChange(const PacketStreamState & state)Closes the output file on Closed or [Error](icy-Error.html#error) stream state transitions.
Parameters
stateNew stream state.
stream
inline
inline std::ostream & stream()Returns
Reference to the underlying output stream.
Exceptions
std::runtime_errorif the stream pointer is null.
Protected Attributes
| Return | Name | Description |
|---|---|---|
std::ostream * | _ostream |
_ostream
std::ostream * _ostream