resonance 1.0.1
Loading...
Searching...
No Matches
Rnd::Stream Class Referenceabstract

Byte stream that every renderer object serialises itself through. More...

#include <stream.h>

Inheritance diagram for Rnd::Stream:

Public Member Functions

virtual Stream & Read (void *pDest, int nSize)=0
 Move nSize bytes into pDest with no conversion.
virtual Stream & Write (const void *pSrc, int nSize)=0
 Move nSize bytes out of pSrc with no conversion.
virtual Stream & Flush ()=0
 Service the underlying transport.
virtual Stream & Seek (int nOffset, int nWhence)=0
 Move the read and write position.
virtual int Tell ()=0
 Report the current position.
virtual int Eof ()=0
 Test whether the position has arrived at the end.
virtual int Fail ()=0
 Test whether a transfer has failed.
virtual Stream & ReadLE (void *pDest, int nSize)
 Move nSize bytes into pDest, correcting the byte order for the host.
virtual Stream & WriteLE (const void *pSrc, int nSize)
 Move nSize bytes out of pSrc, correcting the byte order for the file.
virtual ~Stream ()
 Close the stream.
Stream & ReadString (HxStr &name)
 Read a NUL-terminated name and append it to a string.

Detailed Description

Byte stream that every renderer object serialises itself through.

Its RTTI descriptor is at 0x0086f670. It is a leaf class with no base and no data member. A stream stores its vtable pointer at offset 0 and every field belongs to a subclass. The class does not emit a standalone GetTypeInfo accessor, because each subclass accessor initialises this descriptor inline before its own.

The four subclasses attested by RTTI are Rnd::FileStream, Rnd::MemStream, Rnd::BufStream, and Rnd::ToolStream, all single inheritance at offset 0. Every vtable in the family is eleven entries, and the declaration order below reproduces that order, so the recovery is complete rather than partial.

Read() through Fail() are pure, since all four subclasses supply a distinct body for each. ReadLE() and WriteLE() are the exception: one shared base body appears at slot 8 and slot 9 of all four tables and does nothing beyond forwarding to Read() and Write(). Both pairs are therefore interchangeable on this target, and a caller that wants byte-order correction for a multi-byte scalar still uses the second pair because the file format is big-endian like the EE.

Constructor & Destructor Documentation

◆ ~Stream()

virtual Rnd::Stream::~Stream ( )
virtual

Close the stream.

Vtable slot 10, which is the last slot rather than the first, because the destructor is declared after the transfer virtuals. Rnd::BufStream stores a null there, so a BufStream destroyed through a base pointer jumps to zero; every other subclass supplies a body.

Member Function Documentation

◆ Read()

virtual Stream & Rnd::Stream::Read ( void * pDest,
int nSize )
pure virtual

Move nSize bytes into pDest with no conversion.

Vtable slot 1.

Parameters
pDestThe destination buffer.
nSizeThe number of bytes to move.
Returns
This stream.

Implemented in Rnd::BufStream, Rnd::FileStream, Rnd::MemStream, and Rnd::ToolStream.

◆ Write()

virtual Stream & Rnd::Stream::Write ( const void * pSrc,
int nSize )
pure virtual

Move nSize bytes out of pSrc with no conversion.

Vtable slot 2.

Parameters
pSrcThe source buffer.
nSizeThe number of bytes to move.
Returns
This stream.

Implemented in Rnd::BufStream, Rnd::FileStream, Rnd::MemStream, and Rnd::ToolStream.

◆ Flush()

virtual Stream & Rnd::Stream::Flush ( )
pure virtual

Service the underlying transport.

Vtable slot 3. Rnd::FileStream passes the request to its FILE, Rnd::MemStream and Rnd::BufStream do nothing, and Rnd::ToolStream::Read() invokes this whenever it has drained its buffer, which makes it the refill point for a streamed source.

Returns
This stream.

Implemented in Rnd::BufStream, Rnd::FileStream, Rnd::MemStream, and Rnd::ToolStream.

◆ Seek()

virtual Stream & Rnd::Stream::Seek ( int nOffset,
int nWhence )
pure virtual

Move the read and write position.

Vtable slot 4. An offset that would pass either end is clamped rather than reported.

Parameters
nOffsetThe signed distance to move.
nWhenceThe origin, one of the SeekOrigin values.
Returns
This stream.

Implemented in Rnd::BufStream, Rnd::FileStream, Rnd::MemStream, and Rnd::ToolStream.

◆ Tell()

virtual int Rnd::Stream::Tell ( )
pure virtual

Report the current position.

Vtable slot 5. Rnd::ToolStream always reports 0.

Returns
The position in bytes from the start.

Implemented in Rnd::BufStream, Rnd::FileStream, Rnd::MemStream, and Rnd::ToolStream.

◆ Eof()

virtual int Rnd::Stream::Eof ( )
pure virtual

Test whether the position has arrived at the end.

Vtable slot 6.

Returns
Non-zero at the end.

Implemented in Rnd::BufStream, Rnd::FileStream, Rnd::MemStream, and Rnd::ToolStream.

◆ Fail()

virtual int Rnd::Stream::Fail ( )
pure virtual

Test whether a transfer has failed.

Vtable slot 7. A short read sets this on the memory streams. Rnd::ToolStream never fails.

Returns
Non-zero once a transfer has failed.

Implemented in Rnd::BufStream, Rnd::FileStream, Rnd::MemStream, and Rnd::ToolStream.

◆ ReadLE()

virtual Stream & Rnd::Stream::ReadLE ( void * pDest,
int nSize )
virtual

Move nSize bytes into pDest, correcting the byte order for the host.

Vtable slot 8. The one shared implementation forwards to Read(), and no subclass overrides it.

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

◆ WriteLE()

virtual Stream & Rnd::Stream::WriteLE ( const void * pSrc,
int nSize )
virtual

Move nSize bytes out of pSrc, correcting the byte order for the file.

Vtable slot 9. The one shared implementation forwards to Write(), and no subclass overrides it.

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

◆ ReadString()

Stream & Rnd::Stream::ReadString ( HxStr & name)

Read a NUL-terminated name and append it to a string.

The name arrives one byte at a time through Read() into a 256-byte static buffer at 0x008952e0. The string is emptied through HxStr::Clear() first, so the argument need not start empty. A name of 256 characters or more fills the buffer with no terminator before the flush, and the flush then measures it with strlen, which reads past the buffer.

Parameters
nameThe string to append the name to.
Returns
This stream, which Rnd::Manager's reader at 0x0051b450 chains into a second read.
Ghidra address:
NTSC-U/C: 0x0050f140
Ghidra address:
PAL: 0x0054e6e8

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