resonance 1.0.1
Loading...
Searching...
No Matches
HxStream Class Reference

Seekable data source interface, unrelated to IBStream and OBStream. More...

#include <hxstream.h>

Inheritance diagram for HxStream:

Public Member Functions

virtual ~HxStream ()
 Close the stream.
virtual void SetMarker (int nOffset, int nWhence)
 Move the read position.
virtual int GetMarker ()
 Report the read position.
virtual int Size ()
 Report the length of the data.
virtual HxStream & Write (const void *pSrc, int nSize)
 Move nSize bytes out of pSrc.
virtual HxStream & ReadData (void *pDest, int nSize)
 Move nSize bytes into pDest.
virtual HxStream * UnderlyingStream ()
 Report the stream this one reads through, if any.
HxStream & ReadNum (void *pDest, int nSize)
 Move nSize bytes into pDest, reversing their order when the stream swaps bytes.
HxStream & WriteNum (const void *pSrc, int nSize)
 Move nSize bytes out of pSrc, reversing their order when the stream swaps bytes.
HxStream & ReadStr (char *pszDest, int nDestSize)
 Read a string with a variable-length size prefix into a fixed buffer.
HxStream & ReadString (HxStr &str)
 Read a string with a variable-length size prefix into an HxStr.
HxStream * GetRootStream ()
 Follow UnderlyingStream() from this stream until a stream reports none, and report that stream.

Public Attributes

int mSwapBytes
 Non-zero when multi-byte values on the stream are in the opposite byte order.

Static Public Attributes

static const int goodbit
 Status value of a stream with nothing wrong.
static const int kStatusEnd
 Status value of a stream whose read position arrived at the end of its data.
static const int failbit
 Status bit a seek outside a chunk's bounds would set.
static const int badbit
 Second status bit GetMarker() and SetMarker() of HxIDataChunk test.

Protected Member Functions

 HxStream ()
 Construct a stream with a zeroed state.

Protected Attributes

int mStatus
int mFatalOnEnd

Detailed Description

Seekable data source interface, unrelated to IBStream and OBStream.

Its RTTI descriptor is at 0x0086f6c8. It has no base. The class has three data words and stores its vtable pointer after them at +0x0c, the position for a class with no base. The object is 0x10 bytes. Its vtable is at 0x00816d60, emitted once per translation unit that needs it, and the seven slots below are the whole interface.

Every slot has a body here, and each does nothing beyond producing a neutral result, so the class is an interface with defaults rather than an abstract one. Two subclasses are attested, HxMemStream and HxIDataChunk. HxIDataChunk is a RIFF chunk reader and belongs to a different subsystem.

Only HxIDataChunk's two constructors write mFatalOnEnd, each setting it on the chunk itself. No HxMemStream ever has it set. The diagnostic HxMemStream::ReadData() guards on it is therefore unreachable in the shipped build.

Constructor & Destructor Documentation

◆ ~HxStream()

virtual HxStream::~HxStream ( )
virtual

Close the stream.

Vtable slot 1, which is the first of the interface, because the destructor is declared ahead of the transfer virtuals.

Ghidra address:
NTSC-U/C: 0x00145ee8
Ghidra address:
PAL: 0x00146a00

◆ HxStream()

HxStream::HxStream ( )
protected

Construct a stream with a zeroed state.

Ghidra address:
NTSC-U/C: 0x004057a8
Ghidra address:
PAL: 0x0043f098

Member Function Documentation

◆ SetMarker()

virtual void HxStream::SetMarker ( int nOffset,
int nWhence )
virtual

Move the read position.

Vtable slot 2. The return type is void rather than a stream reference, which the two instruction body here and HxMemStream's override both establish.

Parameters
nOffsetThe signed distance to move.
nWhenceThe origin, one of the HxStreamSeekOrigin values.
Ghidra address:
NTSC-U/C: 0x00145f18
Ghidra address:
PAL: 0x00146a30

Reimplemented in HxIDataChunk, and HxMemStream.

◆ GetMarker()

virtual int HxStream::GetMarker ( )
virtual

Report the read position.

Vtable slot 3. The default reports 0.

Returns
The position in bytes from the start.
Ghidra address:
NTSC-U/C: 0x00145f20
Ghidra address:
PAL: 0x00146a38

Reimplemented in HxIDataChunk, and HxMemStream.

◆ Size()

virtual int HxStream::Size ( )
virtual

Report the length of the data.

Vtable slot 4. The default reports 0.

Returns
The length in bytes.
Ghidra address:
NTSC-U/C: 0x00145f28
Ghidra address:
PAL: 0x00146a40

Reimplemented in HxIDataChunk, and HxMemStream.

◆ Write()

virtual HxStream & HxStream::Write ( const void * pSrc,
int nSize )
virtual

Move nSize bytes out of pSrc.

Vtable slot 5. The default discards the request.

Parameters
pSrcThe source buffer.
nSizeThe number of bytes to move.
Returns
This stream.
Ghidra address:
NTSC-U/C: 0x00145f30
Ghidra address:
PAL: 0x00146a48

Reimplemented in HxMemStream.

◆ ReadData()

virtual HxStream & HxStream::ReadData ( void * pDest,
int nSize )
virtual

Move nSize bytes into pDest.

Vtable slot 6. The default discards the request.

Parameters
pDestThe destination buffer.
nSizeThe number of bytes to move.
Returns
This stream.
Ghidra address:
NTSC-U/C: 0x00145f38
Ghidra address:
PAL: 0x00146a50

Reimplemented in HxIDataChunk, and HxMemStream.

◆ UnderlyingStream()

virtual HxStream * HxStream::UnderlyingStream ( )
virtual

Report the stream this one reads through, if any.

Vtable slot 7. The default reports null and HxMemStream retains it. HxIDataChunk overrides it at 0x00145fd8 and reports the stream its chunk lies in.

Returns
The underlying stream, or null by default.
Ghidra address:
NTSC-U/C: 0x00145f40
Ghidra address:
PAL: 0x00146a58

Reimplemented in HxIDataChunk.

◆ ReadNum()

HxStream & HxStream::ReadNum ( void * pDest,
int nSize )

Move nSize bytes into pDest, reversing their order when the stream swaps bytes.

With mSwapBytes clear, or for a single byte, this is one ReadData(). Otherwise it reads one byte at a time from the last position of pDest to the first. Mid::Reader reads every header and track field through it, and HxChunkHeader reads chunk sizes through it.

Parameters
pDestThe destination buffer.
nSizeThe number of bytes to move.
Returns
This stream.
Ghidra address:
NTSC-U/C: 0x004059f8
Ghidra address:
PAL: 0x0043f2e8

◆ WriteNum()

HxStream & HxStream::WriteNum ( const void * pSrc,
int nSize )

Move nSize bytes out of pSrc, reversing their order when the stream swaps bytes.

The writing counterpart of ReadNum(). With mSwapBytes clear, or for a single byte, this is one Write(). Otherwise it writes one byte at a time from the last position of pSrc to the first. The shipped program calls it only from HxVarLenNumber::Write().

Parameters
pSrcThe source buffer.
nSizeThe number of bytes to move.
Returns
This stream.
Ghidra address:
NTSC-U/C: 0x00405958
Ghidra address:
PAL: 0x0043f248

◆ ReadStr()

HxStream & HxStream::ReadStr ( char * pszDest,
int nDestSize )

Read a string with a variable-length size prefix into a fixed buffer.

The length comes from HxVarLenNumber::Read(). A string shorter than nDestSize is read whole and terminated. A longer one is cut to nDestSize - 1 bytes and terminated, and the read position then skips the rest of the string. The shipped program does not call it.

Parameters
pszDestThe destination buffer.
nDestSizeThe size of pszDest in bytes, terminator included.
Returns
This stream.
Ghidra address:
NTSC-U/C: 0x004057c8
Ghidra address:
PAL: 0x0043f0b8

◆ ReadString()

HxStream & HxStream::ReadString ( HxStr & str)

Read a string with a variable-length size prefix into an HxStr.

The bytes are read into a temporary untagged block one byte longer than the string, which is terminated, assigned to str, and released. The shipped program does not call it. The title is inferred.

Parameters
strReceives the string.
Returns
This stream.
Ghidra address:
NTSC-U/C: 0x004058a8
Ghidra address:
PAL: 0x0043f198

◆ GetRootStream()

HxStream * HxStream::GetRootStream ( )

Follow UnderlyingStream() from this stream until a stream reports none, and report that stream.

The shipped program does not call it.

Returns
The innermost stream, which is this stream when it reads through no other.
Ghidra address:
NTSC-U/C: 0x00405a98
Ghidra address:
PAL: 0x0043f388

Member Data Documentation

◆ goodbit

const int HxStream::goodbit
static

Status value of a stream with nothing wrong.

HxIDataChunk loads the four status values from memory rather than as immediates. The memory loads place them as class constants defined in this class's translation unit. HxMemStream writes the same two values, 0 and 1, as immediates. The name of kStatusEnd is inferred.

Ghidra address:
NTSC-U/C: 0x00816d40
Ghidra address:
PAL: 0x00859cb8

◆ kStatusEnd

const int HxStream::kStatusEnd
static

Status value of a stream whose read position arrived at the end of its data.

Ghidra address:
NTSC-U/C: 0x00816d44
Ghidra address:
PAL: 0x00859cbc

◆ failbit

const int HxStream::failbit
static

Status bit a seek outside a chunk's bounds would set.

GetMarker() reports -1 while it is set.

Ghidra address:
NTSC-U/C: 0x00816d48
Ghidra address:
PAL: 0x00859cc0

◆ badbit

const int HxStream::badbit
static

Second status bit GetMarker() and SetMarker() of HxIDataChunk test.

No writer is recovered.

Ghidra address:
NTSC-U/C: 0x00816d4c
Ghidra address:
PAL: 0x00859cc4

◆ mSwapBytes

int HxStream::mSwapBytes

Non-zero when multi-byte values on the stream are in the opposite byte order.

ReadNum() tests it and the constructor clears it. Public because HxIDataChunk copies it from another stream object and the image exposes no accessor.

+0x00

◆ mStatus

int HxStream::mStatus
protected

◆ mFatalOnEnd

int HxStream::mFatalOnEnd
protected

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