Elm  1.0
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
elm::io::BlockOutStream Class Reference

#include <elm/io/BlockOutStream.h>

+ Inheritance diagram for elm::io::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 elm::io::OutStream
virtual ~OutStream (void)
 
virtual CString lastErrorMessage (void)
 

Additional Inherited Members

- Static Public Attributes inherited from elm::io::OutStream
static OutStreamnull = _null
 

Detailed Description

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

Constructor & Destructor Documentation

elm::io::BlockOutStream::BlockOutStream ( int  size = 4096,
int  inc = 256 
)

Build a new block output stream.

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

Member Function Documentation

char * elm::io::BlockOutStream::block ( void  ) const

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 elm::block::DynBlock::base().

Referenced by elm::StringBuffer::copyString().

void elm::io::BlockOutStream::clear ( void  )

Clear the block receiving bytes from output.

References elm::block::DynBlock::reset().

char * elm::io::BlockOutStream::detach ( void  )

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 elm::block::DynBlock::detach().

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

int elm::io::BlockOutStream::flush ( void  )
virtual

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

Returns
0 for success, less than 0 for error.

Implements elm::io::OutStream.

void elm::io::BlockOutStream::setSize ( int  size)

Change the size of the current block.

Parameters
sizeNew size occupied by the block.

References elm::block::DynBlock::setSize().

Referenced by elm::StringBuffer::reset().

int elm::io::BlockOutStream::size ( void  ) const

Get the current size of stored bytes in this stream.

References elm::block::DynBlock::size().

Referenced by elm::StringBuffer::copyString(), and elm::StringBuffer::length().

CString elm::io::BlockOutStream::toCString ( void  )

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

Returns
Buffer converted to C string.

References detach(), and write().

String elm::io::BlockOutStream::toString ( void  )

Convert the buffer to a String object.

Returns
String object.

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

int elm::io::BlockOutStream::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 elm::io::OutStream.

References elm::block::DynBlock::put().

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

int elm::io::BlockOutStream::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 elm::io::OutStream.

References elm::block::DynBlock::put().


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