xoreos
0.0.5
|
Interface for a seekable & readable data stream. More...
#include <readstream.h>
Public Types | |
enum | Origin { kOriginBegin = 0, kOriginCurrent = 1, kOriginEnd = 2, kOriginMAX } |
The position a seeking offset takes as a base. More... | |
Public Member Functions | |
SeekableReadStream () | |
~SeekableReadStream () | |
virtual size_t | pos () const =0 |
Obtains the current value of the stream position indicator of the stream. More... | |
virtual size_t | size () const =0 |
Obtains the total size of the stream, measured in bytes. More... | |
virtual size_t | seek (ptrdiff_t offset, Origin whence=kOriginBegin)=0 |
Sets the stream position indicator for the stream. More... | |
virtual size_t | skip (ptrdiff_t offset) |
Skip the specified number of bytes, adding that offset to the current position in the stream. More... | |
Public Member Functions inherited from Common::ReadStream | |
ReadStream () | |
virtual | ~ReadStream () |
virtual bool | eos () const =0 |
Returns true if a read failed because the stream has been reached. More... | |
virtual size_t | read (void *dataPtr, size_t 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... | |
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... | |
MemoryReadStream * | readStream (size_t dataSize) |
Read the specified amount of data into a new[]'ed buffer which then is wrapped into a MemoryReadStream. More... | |
Static Public Member Functions | |
static size_t | evalSeek (ptrdiff_t offset, Origin whence, size_t pos, size_t begin, size_t size) |
Evaluate the seek offset relative to whence into a position from the beginning. More... | |
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 |
Interface for a seekable & readable data stream.
Definition at line 265 of file readstream.h.
The position a seeking offset takes as a base.
Enumerator | |
---|---|
kOriginBegin | Seek from the begin of the stream. |
kOriginCurrent | Seek from the current position of the stream. |
kOriginEnd | Seek from the end of the stream. |
kOriginMAX | For range checks. |
Definition at line 268 of file readstream.h.
Common::SeekableReadStream::SeekableReadStream | ( | ) |
Definition at line 77 of file readstream.cpp.
Common::SeekableReadStream::~SeekableReadStream | ( | ) |
Definition at line 80 of file readstream.cpp.
|
static |
Evaluate the seek offset relative to whence into a position from the beginning.
Definition at line 83 of file readstream.cpp.
References kOriginBegin, kOriginCurrent, kOriginEnd, pos(), size(), and XOREOS_FALLTHROUGH.
Referenced by Common::MemoryReadStream::seek(), and Common::SeekableSubReadStream::seek().
|
pure virtual |
Obtains the current value of the stream position indicator of the stream.
Implemented in Common::SeekableSubReadStream, Common::MemoryReadStream, and Common::ReadFile.
Referenced by Aurora::ActionScript::ASBuffer::actionDefineFunction2(), Common::blowfishEBC(), Aurora::Small::compress00(), Aurora::Small::compress10(), Graphics::Aurora::ModelNode_DragonAge::createVertexBuffer(), Video::Bink::BinkAudioTrack::decodeAudio(), Common::decompressDeflateChunk(), Aurora::ERFFile::decrypt(), Aurora::ERFFile::decryptNWNPremiumHeader(), Engines::dumpStream(), evalSeek(), Aurora::ActionScript::ASBuffer::execute(), Aurora::ERFFile::findNWNPremiumKey(), Aurora::GFF3Struct::getLocString(), Aurora::SACFile::load(), Aurora::VISFile::load(), Graphics::Aurora::PLTFile::load(), Engines::NWN2::TRXFile::load(), Sound::WwiseSoundBank::load(), Graphics::Aurora::Model_NWN::loadASCII(), Graphics::Aurora::ModelNode_NWN_Binary::loadName(), Engines::NWN2::TRXFile::loadPackets(), Engines::NWN2::TRXFile::loadTRRN(), Engines::NWN2::TRXFile::loadWATR(), Sound::SoundManager::makeAudioStream(), Sound::makeWAVStream(), Aurora::NitroFile::open(), Sound::PacketizedVorbisStream::parseExtraData(), Common::PEResources::parseResourceLevel(), Common::printDataHex(), Aurora::GFF4File::Header::read(), Graphics::DDS::readBioWareHeader(), Aurora::readCells(), Graphics::CBGT::readCells(), Graphics::Aurora::ModelNode_Jade::readChunkedIndices(), Aurora::HERFFile::readDictionary(), Aurora::ERFFile::readERFHeader(), Graphics::Aurora::ModelNode_NWN_Binary::readMesh(), Graphics::Aurora::ModelNode_KotOR::readMesh(), Aurora::NDSFile::readNames(), Graphics::Aurora::ModelNode_Jade::readPlainIndices(), Aurora::TwoDAFile::readRows2b(), Graphics::Aurora::Model_KotOR::readStrings(), Graphics::Aurora::Model_Jade::readStrings(), Graphics::TPC::readTXI(), Graphics::TXB::readTXI(), Aurora::HERFFile::searchDictionary(), Sound::seek_stream_wrap(), and Sound::tell_stream_wrap().
|
pure virtual |
Sets the stream position indicator for the stream.
The new position, measured in bytes, is obtained by adding offset bytes to the position specified by whence. If whence is set to kOriginBegin, kOriginCurrent, or kOriginEnd, the offset is relative to the start of the file, the current position indicator, or end-of-file, respectively. A successful call to the seek() method clears the end-of-file indicator for the stream.
On error, or when trying to seek outside the stream, a kSeekError exception is thrown.
offset | the relative offset in bytes. |
whence | the seek reference: kOriginBegin, kOriginCurrent or kOriginEnd. |
Implemented in Common::SeekableSubReadStream, Common::MemoryReadStream, and Common::ReadFile.
Referenced by Sound::AACDecoder::AACDecoder(), Aurora::ActionScript::ASBuffer::actionDefineFunction2(), Aurora::ActionScript::ASBuffer::actionIf(), Aurora::ActionScript::ASBuffer::actionJump(), Engines::KotOR::Walkmesh::appendFaceTypes(), Engines::KotOR::Walkmesh::appendFromStream(), Engines::KotOR::Walkmesh::appendIndices(), Engines::KotOR::Walkmesh::appendVertices(), Sound::CodebookLibrary::CodebookLibrary(), Graphics::Aurora::ModelNode_DragonAge::createVertexBuffer(), Video::Bink::BinkAudioTrack::decodeAudio(), Sound::WMACodec::decodeSuperFrame(), Common::decompressDeflateChunk(), Graphics::Aurora::NFTRFont::drawGlyph(), Engines::dumpStream(), Sound::WMACodec::evalFlags(), Aurora::ActionScript::ASBuffer::execute(), Common::StreamTokenizer::findFirstToken(), Aurora::ERFFile::findNWNPremiumKey(), Sound::CodebookLibrary::getCodebook(), Common::ZipFile::getFileProperties(), Sound::WMACodec::getFlags(), Common::StreamTokenizer::getToken(), Common::StreamTokenizer::isChunkEnd(), Aurora::NDSFile::isNDS(), Graphics::TXB::load(), Aurora::VISFile::load(), Graphics::Aurora::Model_Witcher::load(), Common::ZipFile::load(), Graphics::Aurora::Model_KotOR::load(), Common::FoxPro::load(), Graphics::Aurora::Model_NWN2::load(), Graphics::Aurora::Model_Jade::load(), Graphics::Aurora::ModelNode_Witcher::load(), Aurora::NDSFile::load(), Graphics::Aurora::ModelNode_Jade::load(), Graphics::Aurora::ModelNode_KotOR::load(), Sound::FMODSampleBank::load(), Graphics::Aurora::ModelNode_NWN_Binary::load(), Sound::XACTWaveBank_Binary::load(), Sound::WwiseSoundBank::load(), Graphics::Aurora::Model_NWN::loadASCII(), Graphics::Aurora::Model_NWN::loadBinary(), Common::FoxPro::loadFields(), Common::PEResources::loadFromEXE(), Graphics::Aurora::ModelNode_NWN_Binary::loadName(), Engines::NWN2::TRXFile::loadPackets(), Sound::SoundManager::makeAudioStream(), Common::StreamTokenizer::nextChunk(), Sound::Packet::Packet(), Sound::PacketizedVorbisStream::parseExtraData(), Graphics::Aurora::Model_NWN::ParserContext::ParserContext(), Common::PEResources::parseResourceLevel(), Common::printDataHex(), Aurora::GFF4File::Header::read(), Graphics::Aurora::Model_KotOR::readAnim(), Graphics::Aurora::Model_NWN::readAnimBinary(), Graphics::Aurora::Model::readArray(), Aurora::KEYFile::readBIFList(), Graphics::DDS::readBioWareHeader(), Aurora::readCells(), Graphics::CBGT::readCells(), Graphics::Aurora::ModelNode_Jade::readChunkedIndices(), Graphics::WinIconImage::readData(), Aurora::ERFFile::readDescription(), Aurora::HERFFile::readDictionary(), Aurora::SSFFile::readEntries(), Aurora::SSFFile::readEntriesNWN(), Aurora::ERFFile::readERFHeader(), Aurora::NDSFile::readFAT(), Aurora::GFF3Struct::readField(), Aurora::GFF3Struct::readFields(), Graphics::WinIconImage::readHeader(), Graphics::TGA::readHeader(), Aurora::GFF3Struct::readLabel(), Graphics::Aurora::ModelNode_DragonAge::readMAO(), Graphics::Aurora::ModelNode_Witcher::readMesh(), Graphics::Aurora::ModelNode_NWN_Binary::readMesh(), Graphics::Aurora::ModelNode_KotOR::readMesh(), Graphics::Aurora::ModelNode_Jade::readMesh(), Aurora::NDSFile::readNames(), Graphics::Aurora::ModelNode_Witcher::readNodeControllers(), Graphics::Aurora::ModelNode_KotOR::readNodeControllers(), Graphics::Aurora::ModelNode_NWN_Binary::readNodeControllers(), Graphics::CBGT::readPalettes(), Graphics::Aurora::ModelNode_Jade::readPlainIndices(), Aurora::RIMFile::readResList(), Aurora::KEYFile::readResList(), Aurora::TwoDAFile::readRows2b(), Graphics::Aurora::ModelNode_KotOR::readSkin(), Graphics::Aurora::Model_KotOR::readStrings(), Graphics::Aurora::Model_Jade::readStrings(), Graphics::Aurora::ModelNode_Witcher::readTexturePaint(), Graphics::Aurora::ModelNode_Witcher::readTextures(), Aurora::ERFFile::readV10KeyList(), Aurora::ERFFile::readV10ResList(), Aurora::ERFFile::readV11KeyList(), Aurora::ERFFile::readV20ResList(), Aurora::ERFFile::readV21ResList(), Aurora::ERFFile::readV22ResList(), Aurora::ERFFile::readV30ResList(), Aurora::BZFFile::readVarResTable(), Aurora::BIFFile::readVarResTable(), Aurora::ActionScript::ASBuffer::run(), Common::searchBackwards(), Aurora::HERFFile::searchDictionary(), Common::SeekableSubReadStream::seek(), Sound::seek_stream_wrap(), Common::SeekableSubReadStream::SeekableSubReadStream(), Common::FoxPro::setMemo(), skip(), and Common::StreamTokenizer::skipChunk().
|
pure virtual |
Obtains the total size of the stream, measured in bytes.
If this value is unknown or can not be computed, kSizeInvalid is returned.
Implemented in Common::SeekableSubReadStream, Common::MemoryReadStream, and Common::ReadFile.
Referenced by Sound::AACDecoder::AACDecoder(), Common::blowfishEBC(), Sound::CodebookLibrary::CodebookLibrary(), Aurora::Small::compress00(), Aurora::Small::compress10(), Video::VPXDecoder::decodeFrame(), Sound::AACDecoder::decodeFrame(), Sound::WMACodec::decodeSuperFrame(), Common::decompressDeflateChunk(), Common::decryptBlowfishEBC(), Aurora::ERFFile::decryptNWNPremiumHeader(), Sound::WMACodec::evalFlags(), evalSeek(), Aurora::ActionScript::ASBuffer::execute(), Sound::WMACodec::getFlags(), Aurora::OBBFile::getIndex(), Aurora::NDSFile::isNDS(), Graphics::NBFS::load(), Aurora::SACFile::load(), Graphics::Aurora::PLTFile::load(), Engines::NWN2::TRXFile::load(), Sound::WwiseSoundBank::load(), Aurora::GFXFile::load(), Engines::NWN2::TRXFile::loadDirectory(), Common::PEResources::loadFromEXE(), Engines::NWN2::TRXFile::loadPackets(), Sound::SoundManager::makeAudioStream(), Sound::PacketizedADPCMStream::makeStream(), Aurora::NitroFile::open(), Video::XMVWMV2Codec::parseExtraData(), Sound::PacketizedVorbisStream::parseExtraData(), Sound::PCMStream< is16Bit, isUnsigned, isLE >::PCMStream(), Aurora::LanguageManager::preParseColorCodes(), Common::printDataHex(), Aurora::GFF4File::Header::read(), Graphics::DDS::readBioWareHeader(), Graphics::SBM::readData(), Graphics::TPC::readHeader(), Graphics::NBFS::readPalette(), Graphics::CBGT::readPalettes(), Aurora::HERFFile::readResList(), Aurora::SSFFile::readSSFHeader(), Graphics::TPC::readTXI(), Graphics::TXB::readTXI(), Aurora::BZFFile::readVarResTable(), Common::searchBackwards(), Common::FoxPro::setMemo(), and Graphics::TTFRenderer::TTFRenderer().
|
inlinevirtual |
Skip the specified number of bytes, adding that offset to the current position in the stream.
A successful call to the skip() method clears the end-of-file indicator for the stream.
On error, or when trying to skip outside the stream, a kSeekError exception is thrown.
offset | the number of bytes to skip. |
Definition at line 317 of file readstream.h.
References kOriginCurrent, and seek().
Referenced by Engines::KotOR::Walkmesh::appendFromStream(), Graphics::Aurora::ModelNode_DragonAge::createIndexBuffer(), Video::Bink::BinkAudioTrack::decodeAudio(), Aurora::GFF3Struct::getData(), Common::ZipFile::getFileProperties(), Aurora::isBigEndian(), Aurora::SACFile::load(), Graphics::Aurora::PLTFile::load(), Graphics::Aurora::Model_Witcher::load(), Common::ZipFile::load(), Graphics::Aurora::Model_KotOR::load(), Graphics::Aurora::Model_Jade::load(), Graphics::Aurora::ModelNode_Witcher::load(), Aurora::RIMFile::load(), Aurora::KEYFile::load(), Graphics::Aurora::ModelNode_Jade::load(), Sound::FMODSampleBank::load(), Graphics::Aurora::ModelNode_KotOR::load(), Graphics::Aurora::ModelNode_NWN_Binary::load(), Sound::XACTWaveBank_Binary::load(), Sound::WwiseSoundBank::load(), Aurora::FEVFile::load(), Aurora::GFXFile::load(), Graphics::Aurora::Model_NWN::loadBinary(), Common::FoxPro::loadFields(), Common::PEResources::loadFromEXE(), Common::FoxPro::loadHeader(), Common::FoxPro::loadMemos(), Graphics::Aurora::ModelNode_NWN_Binary::loadName(), Graphics::Aurora::ModelNode_NWN2::loadRigid(), Graphics::Aurora::ModelNode_NWN2::loadSkin(), Sound::SoundManager::makeAudioStream(), Sound::makeWAVStream(), Graphics::Aurora::Model_KotOR::readAnim(), Graphics::Aurora::Model_NWN::readAnimBinary(), Aurora::KEYFile::readBIFList(), Graphics::DDS::readBioWareHeader(), Graphics::Aurora::Model_Sonic::readBoneCommands(), Aurora::FEVFile::readCategory(), Graphics::NCGR::readChar(), Graphics::Aurora::ModelNode_Jade::readChunkedIndices(), Graphics::WinIconImage::readData(), Aurora::FEVFile::readEvent(), Graphics::Aurora::NFTRFont::readGlyphs(), Graphics::TPC::readHeader(), Graphics::TXB::readHeader(), Graphics::TGA::readHeader(), Graphics::Aurora::NFTRFont::readHeader(), Graphics::Aurora::NFTRFont::readInfo(), Aurora::NSBTXFile::readInfoHeader(), Graphics::Aurora::Model_Sonic::readInfoOffset(), Graphics::Aurora::Model_Sonic::readInfoOffsetCount(), Graphics::Aurora::Model_Sonic::readMaterialDefinition(), Graphics::Aurora::ModelNode_Jade::readMaterialTextures(), Graphics::Aurora::ModelNode_Witcher::readMesh(), Graphics::Aurora::ModelNode_NWN_Binary::readMesh(), Graphics::Aurora::ModelNode_KotOR::readMesh(), Graphics::Aurora::ModelNode_Jade::readMesh(), Graphics::Aurora::Model_Sonic::readModel(), Graphics::Aurora::Model_Sonic::readModelHeader(), Graphics::Aurora::ModelNode_Witcher::readNodeControllers(), Graphics::Aurora::ModelNode_KotOR::readNodeControllers(), Graphics::Aurora::ModelNode_NWN_Binary::readNodeControllers(), Graphics::NCLR::readPalette(), Aurora::NSBTXFile::readPalettes(), Graphics::Aurora::Model_Sonic::readPolygon(), Aurora::OBBFile::readResList(), Aurora::RIMFile::readResList(), Aurora::TwoDAFile::readRows2b(), Graphics::Aurora::ModelNode_KotOR::readSkin(), Graphics::DDS::readStandardHeader(), Graphics::Aurora::ModelNode_Witcher::readTexturePaint(), Graphics::Aurora::ModelNode_Witcher::readTextures(), Aurora::NSBTXFile::readTextures(), Aurora::ERFFile::readV10Header(), Aurora::ERFFile::readV10KeyList(), Aurora::ERFFile::readV11Header(), Aurora::ERFFile::readV11KeyList(), Aurora::ERFFile::readV20Header(), Aurora::ERFFile::readV21Header(), Aurora::ERFFile::readV22Header(), Aurora::BZFFile::readVarResTable(), Aurora::BIFFile::readVarResTable(), Graphics::Aurora::NFTRFont::readWidths(), and Aurora::HERFFile::searchDictionary().