xoreos  0.0.5
Public Member Functions | Protected Attributes | List of all members
Common::SubReadStream Class Reference

SubReadStream provides access to a ReadStream restricted to the range [currentPosition, currentPosition+end). More...

#include <readstream.h>

Inheritance diagram for Common::SubReadStream:
Inheritance graph
[legend]
Collaboration diagram for Common::SubReadStream:
Collaboration graph
[legend]

Public Member Functions

 SubReadStream (ReadStream *parentStream, size_t end, bool disposeParentStream=false)
 
 ~SubReadStream ()
 
bool eos () const
 Returns true if a read failed because the stream has been reached. More...
 
size_t read (void *dataPtr, size_t dataSize)
 Read data from the stream. More...
 
- Public Member Functions inherited from Common::ReadStream
 ReadStream ()
 
virtual ~ReadStream ()
 
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...
 
uint32 readChar ()
 Reads the next character from stream and returns it as an unsigned char cast to an uint32, or kEOF on end of file or error. 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 readIEEEFloatLE ()
 Read a 32-bit IEEE float stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE float readIEEEFloatBE ()
 Read a 32-bit IEEE float stored in big endian (MSB first) order from the stream and return it. More...
 
FORCEINLINE double readIEEEDoubleLE ()
 Read a 64-bit IEEE double stored in little endian (LSB first) order from the stream and return it. More...
 
FORCEINLINE double readIEEEDoubleBE ()
 Read a 64-bit IEEE double stored in big endian (MSB first) order from the stream and return it. More...
 
MemoryReadStreamreadStream (size_t dataSize)
 Read the specified amount of data into a new[]'ed buffer which then is wrapped into a MemoryReadStream. More...
 

Protected Attributes

DisposablePtr< ReadStream_parentStream
 
size_t _pos
 
size_t _end
 
bool _eos
 

Additional Inherited Members

- Static Public Attributes inherited from Common::ReadStream
static const uint32 kEOF = 0xFFFFFFFF
 Return value for end-of-file. More...
 
static const size_t kSizeInvalid = SIZE_MAX
 
static const size_t kPositionInvalid = SIZE_MAX
 

Detailed Description

SubReadStream provides access to a ReadStream restricted to the range [currentPosition, currentPosition+end).

Manipulating the parent stream directly /will/ mess up a substream. Likewise, manipulating two substreams of a parent stream will cause them to step on each others toes.

Definition at line 333 of file readstream.h.

Constructor & Destructor Documentation

◆ SubReadStream()

Common::SubReadStream::SubReadStream ( ReadStream parentStream,
size_t  end,
bool  disposeParentStream = false 
)

Definition at line 101 of file readstream.cpp.

◆ ~SubReadStream()

Common::SubReadStream::~SubReadStream ( )

Definition at line 107 of file readstream.cpp.

Member Function Documentation

◆ eos()

bool Common::SubReadStream::eos ( ) const
virtual

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

For a SeekableReadStream, it is cleared by a successful seek.

Implements Common::ReadStream.

Definition at line 110 of file readstream.cpp.

References _eos, and _parentStream.

◆ read()

size_t Common::SubReadStream::read ( void *  dataPtr,
size_t  dataSize 
)
virtual

Read data from the stream.

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

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.

Implements Common::ReadStream.

Definition at line 114 of file readstream.cpp.

References _end, _eos, _parentStream, and _pos.

Referenced by Graphics::Aurora::Model_Sonic::readPolygonCommands().

Here is the caller graph for this function:

Member Data Documentation

◆ _end

size_t Common::SubReadStream::_end
protected

◆ _eos

bool Common::SubReadStream::_eos
protected

Definition at line 348 of file readstream.h.

Referenced by eos(), read(), and Common::SeekableSubReadStream::seek().

◆ _parentStream

DisposablePtr<ReadStream> Common::SubReadStream::_parentStream
protected

Definition at line 343 of file readstream.h.

Referenced by eos(), and read().

◆ _pos

size_t Common::SubReadStream::_pos
protected

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