ScummVM
Common::ReadStream Class Referenceabstract

Generic interface for a readable data stream. More...

#include <stream.h>

+ Inheritance diagram for Common::ReadStream:
+ Collaboration diagram for Common::ReadStream:

Public Member Functions

virtual bool eos () const =0
 Returns true if a read failed because the stream end has been reached. More...
 
virtual uint32 read (void *dataPtr, uint32 dataSize)=0
 Read data from the stream. More...
 
byte readByte ()
 Read an unsigned byte from the stream and return it. More...
 
FORCEINLINE int8 readSByte ()
 Read a signed byte from the stream and return it. More...
 
uint16 readUint16LE ()
 Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
uint32 readUint32LE ()
 Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
uint64 readUint64LE ()
 Read an unsigned 64-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
uint16 readUint16BE ()
 Read an unsigned 16-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
uint32 readUint32BE ()
 Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
uint64 readUint64BE ()
 Read an unsigned 64-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
FORCEINLINE int16 readSint16LE ()
 Read a signed 16-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE int32 readSint32LE ()
 Read a signed 32-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE int64 readSint64LE ()
 Read a signed 64-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE int16 readSint16BE ()
 Read a signed 16-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
FORCEINLINE int32 readSint32BE ()
 Read a signed 32-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
FORCEINLINE int64 readSint64BE ()
 Read a signed 64-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
FORCEINLINE float readFloatLE ()
 Read a 32-bit floating point value stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE float readFloatBE ()
 Read a 32-bit floating point value stored in big endian order from the stream and return it. More...
 
FORCEINLINE double readDoubleLE ()
 Read a 64-bit floating point value stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE double readDoubleBE ()
 Read a 64-bit floating point value stored in big endian order from the stream and return it. More...
 
SeekableReadStreamreadStream (uint32 dataSize)
 Read the specified amount of data into a malloc'ed buffer which then is wrapped into a MemoryReadStream. More...
 
Common::String readPascalString (bool transformCR=true)
 Read stream in Pascal format, that is, one byte is string length, followed by string data. More...
 
virtual bool eos () const =0
 Returns true if a read failed because the stream end has been reached. More...
 
virtual uint32 read (void *dataPtr, uint32 dataSize)=0
 Read data from the stream. More...
 
uint8 readByte ()
 Read an unsigned byte from the stream and return it. More...
 
FORCEINLINE sint8 readSByte ()
 Read a signed byte from the stream and return it. More...
 
uint16 readUint16LE ()
 Read an unsigned 16-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
uint32 readUint32LE ()
 Read an unsigned 32-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
uint16 readUint16BE ()
 Read an unsigned 16-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
uint32 readUint32BE ()
 Read an unsigned 32-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
FORCEINLINE sint16 readSint16LE ()
 Read a signed 16-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE sint32 readSint32LE ()
 Read a signed 32-bit word stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE sint16 readSint16BE ()
 Read a signed 16-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
FORCEINLINE sint32 readSint32BE ()
 Read a signed 32-bit word stored in big endian (MSB first) order from the stream and return it. More...
 
SeekableReadStreamreadStream (uint32 dataSize)
 Read the specified amount of data into a malloc'ed buffer which then is wrapped into a MemoryReadStream. More...
 
- Public Member Functions inherited from Common::Stream
virtual ~Stream ()
 
virtual bool err () const
 Returns true if an I/O failure occurred. More...
 
virtual void clearErr ()
 Reset the I/O error status as returned by err(). More...
 
virtual ~Stream ()
 
virtual bool err () const
 Returns true if an I/O failure occurred. More...
 
virtual void clearErr ()
 Reset the I/O error status as returned by err(). More...
 

Detailed Description

Generic interface for a readable data stream.

Definition at line 280 of file stream.h.

Member Function Documentation

◆ eos() [1/2]

◆ eos() [2/2]

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

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

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

Note
The semantics of any implementation of this method are supposed to match those 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.

Implemented in Parallaction::PowerPackerStream, Common::MemoryReadWriteStream, Sci::MemoryDynamicRWStream, Common::File, BladeRunner::SaveFileReadStream, Scumm::ScummDiskImage, LastExpress::SavegameStream, Scumm::ScummNESFile, Fullpipe::MfcArchive, Tinsel::TinselFile, Scumm::ScummFile, Gob::SaveConverter, Titanic::y222, ZVision::LzssReadStream, StdioStream, Kyra::EndianAwareStreamWrapper, Groovie::LzssReadStream, Scumm::BaseScummFile, Common::GZipReadStream, Common::PackBitsReadStream, InVMSave, Common::IFFParser::IFFChunkNav, DS::DSFileStream, Networking::NetworkReadStream, PS2FileStream, PspIoStream, Common::MemoryReadStream, Common::MemoryReadStream, TizenFileStream, Common::SubReadStream, StdioStream, InFRAMSave, InPAKSave, RomfsStream, SymbianStdioStream, and AssetInputStream.

◆ read() [1/2]

◆ read() [2/2]

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

◆ readByte() [1/2]

uint8 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 client code can check by calling err() and eos() ).

Definition at line 190 of file stream.h.

◆ readByte() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 318 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 534 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 518 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 501 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 485 of file stream.h.

◆ readPascalString()

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

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

Parameters
transformCRif set (default), then transform \r into

Definition at line 55 of file stream.cpp.

◆ readSByte() [1/2]

FORCEINLINE sint8 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 client code can check by calling err() and eos() ).

Definition at line 202 of file stream.h.

◆ readSByte() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 330 of file stream.h.

◆ readSint16BE() [1/2]

FORCEINLINE sint16 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 client code can check by calling err() and eos() ).

Definition at line 287 of file stream.h.

◆ readSint16BE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 452 of file stream.h.

◆ readSint16LE() [1/2]

FORCEINLINE sint16 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 client code can check by calling err() and eos() ).

Definition at line 265 of file stream.h.

◆ readSint16LE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 419 of file stream.h.

◆ readSint32BE() [1/2]

FORCEINLINE sint32 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 client code can check by calling err() and eos() ).

Definition at line 298 of file stream.h.

◆ readSint32BE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 463 of file stream.h.

◆ readSint32LE() [1/2]

FORCEINLINE sint32 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 client code can check by calling err() and eos() ).

Definition at line 276 of file stream.h.

◆ readSint32LE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 430 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 474 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 441 of file stream.h.

◆ readStream() [1/2]

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

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

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

◆ readStream() [2/2]

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

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

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

Definition at line 48 of file stream.cpp.

◆ readUint16BE() [1/2]

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 client code can check by calling err() and eos() ).

Definition at line 239 of file stream.h.

◆ readUint16BE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 380 of file stream.h.

◆ readUint16LE() [1/2]

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 client code can check by calling err() and eos() ).

Definition at line 213 of file stream.h.

◆ readUint16LE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 341 of file stream.h.

◆ readUint32BE() [1/2]

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 client code can check by calling err() and eos() ).

Definition at line 252 of file stream.h.

◆ readUint32BE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 393 of file stream.h.

◆ readUint32LE() [1/2]

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 client code can check by calling err() and eos() ).

Definition at line 226 of file stream.h.

◆ readUint32LE() [2/2]

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 client code can check by calling err() and eos() ).

Definition at line 354 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 406 of file stream.h.

◆ 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 client code can check by calling err() and eos() ).

Definition at line 367 of file stream.h.


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