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

#include <elm/io/BufferedInStream.h>

+ Inheritance diagram for BufferedInStream:

Public Member Functions

 BufferedInStream (InStream &input, int size=default_size)
 
 BufferedInStream (InStream *input, bool close=false, int size=default_size)
 
 ~BufferedInStream () override
 
InStreamstream () const
 
void setStream (InStream &str)
 
void reset ()
 
int read (void *buffer, int size) override
 
int read (void) override
 
- Public Member Functions inherited from InStream
virtual ~InStream (void)
 
virtual CString lastErrorMessage (void)
 

Static Public Attributes

static const int default_size = 4096
 
- Static Public Attributes inherited from InStream
static const int FAILED = -1
 
static const int ENDED = -2
 
static InStreamnull = _null
 

Detailed Description

Input stream providing bufferization for reading another stream.

Constructor & Destructor Documentation

◆ BufferedInStream() [1/2]

BufferedInStream ( InStream input,
int  size = default_size 
)

Build a buffered input stream.

Parameters
inputInput stream to get data from.
sizeDefault size of the used buffer (optional).

◆ BufferedInStream() [2/2]

BufferedInStream ( InStream input,
bool  close = false,
int  size = default_size 
)

Build a buffered input stream.

Parameters
inputInput stream to get data from.
sizeDefault size of the used buffer (optional).
closeIf set to true, delete the underlying stream at deletion time (default to false).

◆ ~BufferedInStream()

~BufferedInStream ( )
override

Member Function Documentation

◆ read() [1/2]

int read ( void buffer,
int  size 
)
overridevirtual

Read some bytes from the stream and store them in the given buffer. This method does not ever read as many bytes as available in the buffer even if the stream is not ended. Insteadn a read returning 0 bytes means the end of stream is reached.

Parameters
bufferBuffer to write bytes in.
sizeSize of the buffer.
Returns
Number of read bytes, 0 for end of stream, -1 for an error.

Implements InStream.

◆ read() [2/2]

int read ( void  )
overridevirtual

Read one byte from the stream.

Returns
Read byte, FAILED for an error, ENDED for end of stream.

Reimplemented from InStream.

References InStream::ENDED, and InStream::FAILED.

◆ reset()

void reset ( )

Reset the buffer to empty.

Referenced by BufferedInStream::setStream().

◆ setStream()

void setStream ( InStream str)

Set the current stream to read. The buffer is reset.

Parameters
strNew stream.

References BufferedInStream::reset(), and elm::str().

◆ stream()

InStream& stream ( ) const
inline

Member Data Documentation

◆ default_size

const int default_size = 4096
static

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