Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
BufferedOutStream Class Reference

#include <elm/io/BufferedOutStream.h>

+ Inheritance diagram for BufferedOutStream:

Public Member Functions

 BufferedOutStream (OutStream &output, size_t size=default_size)
 
 BufferedOutStream (OutStream *output, bool close=false, size_t size=default_size)
 
 ~BufferedOutStream () override
 
void reset ()
 
void setStream (OutStream &str)
 
OutStreamstream () const
 
int write (const char *buffer, int size) override
 
int write (char byte) override
 
int flush (void) override
 
CString lastErrorMessage (void) override
 
bool supportsANSI () const override
 
- Public Member Functions inherited from OutStream
virtual ~OutStream (void)
 

Static Public Attributes

static const int default_size = 4096
 
- Static Public Attributes inherited from OutStream
static OutStreamnull = _null
 

Detailed Description

This stream provides buffered action for a given output stream.

Constructor & Destructor Documentation

◆ BufferedOutStream() [1/2]

BufferedOutStream ( OutStream output,
size_t  size = default_size 
)

Build a buffer out stream.

Parameters
outputOutput stream to buffer in.
sizeSize of the buffer.

◆ BufferedOutStream() [2/2]

BufferedOutStream ( OutStream output,
bool  close = false,
size_t  size = default_size 
)

Build a buffer out stream.

Parameters
outputOutput stream to buffer in.
closeIf set to true, the underlying stream is closed at destruction time (default to false).
sizeSize of the buffer.

◆ ~BufferedOutStream()

~BufferedOutStream ( )
override

Member Function Documentation

◆ flush()

int flush ( void  )
overridevirtual

Cause the current stream to dump its buffer to the medium.

Returns
0 for success, less than 0 for error.

Implements OutStream.

References OutStream::write().

Referenced by BufferedOutStream::setStream(), BufferedOutStream::write(), and BufferedOutStream::~BufferedOutStream().

◆ lastErrorMessage()

CString lastErrorMessage ( void  )
overridevirtual

Return a message for the last error.

Returns
Message of the last error.

Reimplemented from OutStream.

References OutStream::lastErrorMessage().

◆ reset()

void reset ( )

Reset the stream without flushing.

◆ setStream()

void setStream ( OutStream str)

Change the buffered stream, flushing remaining content.

Parameters
strNew stream.

References BufferedOutStream::flush(), and elm::str().

◆ stream()

OutStream & stream ( ) const
inline

Get the underlying output stream.

Returns
Buffered stream.

◆ supportsANSI()

bool supportsANSI ( ) const
overridevirtual

Test if the current stream knows how to decode ANSI special codes. The default implementation returns false.

Returns
True if ANSI code are supported, false else.

Reimplemented from OutStream.

References OutStream::supportsANSI().

◆ write() [1/2]

int write ( char  byte)
overridevirtual

Write a byte to the stream.

Parameters
byteByte to write.
Returns
1 for success or less than 0 for an error.

Reimplemented from OutStream.

References elm::io::byte(), and BufferedOutStream::flush().

◆ write() [2/2]

int write ( const char *  buffer,
int  size 
)
overridevirtual

This is the main method of an output stream: the given buffer is put on the stream.

Parameters
bufferByte buffer to write.
sizeSize of the byte buffer.
Returns
Number of transferred bytes or less than 0 for an error.

Implements OutStream.

References BufferedOutStream::flush(), and OutStream::write().

Member Data Documentation

◆ default_size

const int default_size = 4096
static

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