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

#include <elm/io/BlockOutStream.h>

+ Inheritance diagram for BlockOutStream:

Public Member Functions

 BlockOutStream (int size=4096, int inc=256)
 
const char * block (void) const
 
int size (void) const
 
char * detach (void)
 
void clear (void)
 
void setSize (int size)
 
CString toCString (void)
 
String toString (void)
 
virtual int write (const char *buffer, int size)
 
virtual int write (char byte)
 
virtual int flush (void)
 
- Public Member Functions inherited from OutStream
virtual ~OutStream (void)
 
virtual CString lastErrorMessage (void)
 
virtual bool supportsANSI () const
 

Additional Inherited Members

- Static Public Attributes inherited from OutStream
static OutStreamnull = _null
 

Detailed Description

This class provides an out stream stocking output bytes in memory in a continuous blocks.

Constructor & Destructor Documentation

◆ BlockOutStream()

BlockOutStream ( int  size = 4096,
int  inc = 256 
)
inline

Build a new block output stream.

Parameters
sizeInitial size of the block.
incValue of the increment for enlarging the block.

Member Function Documentation

◆ block()

char * block ( void  ) const
inline

Get a pointer on the start of the storage block. This pointer remains only valid until an output is performed on the stream.

Returns
Current storage memory block.

References DynBlock::base().

Referenced by StringBuffer::copyString(), and StringBuffer::toCString().

◆ clear()

void clear ( void  )
inline

Clear the block receiving bytes from output.

References DynBlock::reset().

Referenced by StringBuffer::reset().

◆ detach()

char * detach ( void  )
inline

Detach the block from the stream. After this call, the stream will perform no management on the memory block and the caller is responsible for deleting it. It is an error to perform more output after this call unless restart() is called.

Returns
Base of the block.

References DynBlock::detach().

Referenced by BlockOutStream::toCString(), and StringBuffer::toString().

◆ flush()

int flush ( void  )
virtual

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

Returns
0 for success, less than 0 for error.

Implements OutStream.

◆ setSize()

void setSize ( int  size)
inline

Change the size of the current block.

Parameters
sizeNew size occupied by the block.

References DynBlock::setSize(), and BlockOutStream::size().

◆ size()

int size ( void  ) const
inline

Get the current size of stored bytes in this stream.

References DynBlock::size().

Referenced by StringBuffer::copyString(), StringBuffer::length(), BlockOutStream::setSize(), and BlockOutStream::write().

◆ toCString()

CString toCString ( void  )

Convert the buffer to a CString object. (this object must not be used after this call and the caller is responsible for freeing the C string buffer).

Returns
Buffer converted to C string.

References BlockOutStream::detach(), and BlockOutStream::write().

◆ toString()

String toString ( void  )

Convert the buffer to a String object.

Returns
String object.

References DynBlock::base(), and DynBlock::size().

◆ write() [1/2]

int write ( char  byte)
virtual

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 DynBlock::put().

◆ write() [2/2]

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

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 DynBlock::put(), and BlockOutStream::size().

Referenced by BlockOutStream::toCString(), StringBuffer::toCString(), and StringBuffer::toString().


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