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...
 
- 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...
 

Detailed Description

Generic interface for a readable data stream.

Definition at line 272 of file stream.h.

Member Function Documentation

◆ eos()

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, Common::GZipReadStream, Common::PackBitsReadStream, InVMSave, Common::IFFParser::IFFChunkNav, DS::DSFileStream, Sci::MemoryDynamicRWStream, Common::File, Scumm::ScummDiskImage, BladeRunner::SaveFileReadStream, LastExpress::SavegameStream, Networking::NetworkReadStream, PS2FileStream, Scumm::ScummNESFile, Fullpipe::MfcArchive, PspIoStream, Tinsel::TinselFile, Scumm::ScummFile, Common::MemoryReadStream, Gob::SaveConverter, TizenFileStream, Titanic::y222, ZVision::LzssReadStream, Common::SubReadStream, InFRAMSave, InPAKSave, RomfsStream, StdioStream, SymbianStdioStream, Kyra::EndianAwareStreamWrapper, and Groovie::LzssReadStream.

◆ 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 are supposed to match those 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 which were actually read.

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

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

Definition at line 310 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 526 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 510 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 493 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 477 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 into

Definition at line 42 of file stream.cpp.

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

Definition at line 322 of file stream.h.

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

Definition at line 444 of file stream.h.

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

Definition at line 411 of file stream.h.

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

Definition at line 455 of file stream.h.

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

Definition at line 422 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 466 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 433 of file stream.h.

◆ readStream()

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 35 of file stream.cpp.

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

Definition at line 372 of file stream.h.

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

Definition at line 333 of file stream.h.

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

Definition at line 385 of file stream.h.

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

Definition at line 346 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 398 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 359 of file stream.h.


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