ScummVM API documentation
Common::ReadStream Class Referenceabstract

#include <stream.h>

Inheritance diagram for Common::ReadStream:
Common::Stream Common::ReadStreamEndian Common::SeekableReadStream Common::SeekableReadStreamEndian Common::SeekableReadStreamEndian

Public Member Functions

virtual bool eos () const =0
 
virtual uint32 read (void *dataPtr, uint32 dataSize)=0
 
Functions for reading data

The following methods all have default implementations. Subclasses in general should not overload them.

byte readByte ()
 
FORCEINLINE int8 readSByte ()
 
uint16 readUint16LE ()
 
uint32 readUint32LE ()
 
uint64 readUint64LE ()
 
uint16 readUint16BE ()
 
uint32 readUint32BE ()
 
uint64 readUint64BE ()
 
FORCEINLINE int16 readSint16LE ()
 
FORCEINLINE int32 readSint32LE ()
 
FORCEINLINE int64 readSint64LE ()
 
FORCEINLINE int16 readSint16BE ()
 
FORCEINLINE int32 readSint32BE ()
 
FORCEINLINE int64 readSint64BE ()
 
FORCEINLINE float readFloatLE ()
 
FORCEINLINE float readFloatBE ()
 
FORCEINLINE double readDoubleLE ()
 
FORCEINLINE double readDoubleBE ()
 
SeekableReadStreamreadStream (uint32 dataSize)
 
Common::String readPascalString (bool transformCR=true)
 
- Public Member Functions inherited from Common::Stream
virtual bool err () const
 
virtual void clearErr ()
 

Detailed Description

Generic interface for a readable data stream.

Member Function Documentation

◆ eos()

virtual bool Common::ReadStream::eos ( ) const
pure virtual

Return true if a read failed because the stream end has been reached.

This flag is cleared by clearErr(). For a SeekableReadStream, the flag is also cleared by a successful seek.

Note
The semantics of any implementation of this method is supposed to match that of ISO C feof(). In particular, in a stream with N bytes, reading exactly N bytes from the start should not set eos; only reading beyond the available data should set it.

◆ read()

virtual uint32 Common::ReadStream::read ( void *  dataPtr,
uint32  dataSize 
)
pure virtual

Read data from the stream.

Subclasses must implement this method. All other read methods are implemented using it.

Note
The semantics of any implementation of this method is supposed to match that of ISO C fread(), in particular where it concerns setting error and end of file/stream flags.
Parameters
dataPtrPointer to a buffer into which the data is read.
dataSizeNumber of bytes to be read.
Returns
The number of bytes that were actually read.

◆ readByte()

byte Common::ReadStream::readByte ( )
inline

Read an unsigned byte from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readSByte()

FORCEINLINE int8 Common::ReadStream::readSByte ( )
inline

Read a signed byte from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readUint16LE()

uint16 Common::ReadStream::readUint16LE ( )
inline

Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readUint32LE()

uint32 Common::ReadStream::readUint32LE ( )
inline

Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readUint64LE()

uint64 Common::ReadStream::readUint64LE ( )
inline

Read an unsigned 64-bit word stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readUint16BE()

uint16 Common::ReadStream::readUint16BE ( )
inline

Read an unsigned 16-bit word stored in big endian (MSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readUint32BE()

uint32 Common::ReadStream::readUint32BE ( )
inline

Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readUint64BE()

uint64 Common::ReadStream::readUint64BE ( )
inline

Read an unsigned 64-bit word stored in big endian (MSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readSint16LE()

FORCEINLINE int16 Common::ReadStream::readSint16LE ( )
inline

Read a signed 16-bit word stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readSint32LE()

FORCEINLINE int32 Common::ReadStream::readSint32LE ( )
inline

Read a signed 32-bit word stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readSint64LE()

FORCEINLINE int64 Common::ReadStream::readSint64LE ( )
inline

Read a signed 64-bit word stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readSint16BE()

FORCEINLINE int16 Common::ReadStream::readSint16BE ( )
inline

Read a signed 16-bit word stored in big endian (MSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readSint32BE()

FORCEINLINE int32 Common::ReadStream::readSint32BE ( )
inline

Read a signed 32-bit word stored in big endian (MSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readSint64BE()

FORCEINLINE int64 Common::ReadStream::readSint64BE ( )
inline

Read a signed 64-bit word stored in big endian (MSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readFloatLE()

FORCEINLINE float Common::ReadStream::readFloatLE ( )
inline

Read a 32-bit floating point value stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readFloatBE()

FORCEINLINE float Common::ReadStream::readFloatBE ( )
inline

Read a 32-bit floating point value stored in big endian order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readDoubleLE()

FORCEINLINE double Common::ReadStream::readDoubleLE ( )
inline

Read a 64-bit floating point value stored in little endian (LSB first) order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readDoubleBE()

FORCEINLINE double Common::ReadStream::readDoubleBE ( )
inline

Read a 64-bit floating point value stored in big endian order from the stream and return it.

Performs no error checking. The return value is undefined if a read error occurred (for which the client code can check by calling err() and eos() ).

◆ readStream()

SeekableReadStream* Common::ReadStream::readStream ( uint32  dataSize)

Read the specified amount of data into a malloc'ed buffer which is then wrapped into a MemoryReadStream.

The returned stream might contain less data than requested if reading more data failed. This is because of an I/O error or because the end of the stream was reached. It can be determined by calling err() and eos().

◆ readPascalString()

Common::String Common::ReadStream::readPascalString ( bool  transformCR = true)

Read a string in Pascal format, that is, one byte is string length, followed by string data.

Parameters
transformCRIf set (default), then transform \r into \n.

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