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

Read-only HxStream over a caller-supplied byte range. More...

#include <hxmemstream.h>

Inheritance diagram for HxMemStream:
Collaboration diagram for HxMemStream:

Public Member Functions

 HxMemStream (const char *pszName, char *pData, int nSize)
 Open a stream over a caller-owned byte range.
virtual ~HxMemStream ()
 Close the stream and release the title.
virtual void SetMarker (int nOffset, int nWhence)
 Move the read position, clamping to the range.
virtual int GetMarker ()
virtual int Size ()
virtual HxStream & Write (const void *pSrc, int nSize)
 Report a fatal error, since the stream is read-only.
virtual HxStream & ReadData (void *pDest, int nSize)
 Move up to nSize bytes into pDest.
Public Member Functions inherited from HxStream
virtual ~HxStream ()
 Close the stream.
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.

Additional Inherited Members

Public Attributes inherited from HxStream
int mSwapBytes
 Non-zero when multi-byte values on the stream are in the opposite byte order.
Static Public Attributes inherited from HxStream
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 inherited from HxStream
 HxStream ()
 Construct a stream with a zeroed state.
Protected Attributes inherited from HxStream
int mStatus
int mFatalOnEnd

Detailed Description

Read-only HxStream over a caller-supplied byte range.

Its RTTI descriptor is at 0x008f00c0. It has single inheritance from HxStream at offset 0. The type function is at 0x00405c80 and its vtable is at 0x00816e08. The object is 0x24 bytes: the HxStream subobject occupies +0x00 through +0x0f, the name occupies +0x10 and +0x14, and the three pointers follow at +0x18, +0x1c, and +0x20.

The class adds no virtual of its own and overrides six of HxStream's seven, retaining only UnderlyingStream(). The range belongs to the caller, and the destructor releases only the name.

Write() always reports a fatal error, which is what makes the stream read-only. One call site constructs one, at 0x001e676c.

Constructor & Destructor Documentation

◆ HxMemStream()

HxMemStream::HxMemStream ( const char * pszName,
char * pData,
int nSize )

Open a stream over a caller-owned byte range.

Parameters
pszNameThe stream title, which appears in the diagnostic ReadData() produces at the end of the data. A copy is stored.
pDataThe first byte of the range. The stream does not take ownership.
nSizeThe range length in bytes.
Ghidra address:
NTSC-U/C: 0x00405cf8
Ghidra address:
PAL: 0x0043f5e8

◆ ~HxMemStream()

virtual HxMemStream::~HxMemStream ( )
virtual

Close the stream and release the title.

Ghidra address:
NTSC-U/C: 0x00405d98
Ghidra address:
PAL: 0x0043f688

Member Function Documentation

◆ SetMarker()

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

Move the read position, clamping to the range.

The status word is cleared on every call, and a target past the end then clamps to the end and sets it to 1. A target below the start clamps to the start.

Parameters
nOffsetThe signed distance to move.
nWhenceThe origin, one of the HxStreamSeekOrigin values. An origin outside 0 to 2 is treated as the start.
Ghidra address:
NTSC-U/C: 0x00405e00
Ghidra address:
PAL: 0x0043f700

Reimplemented from HxStream.

◆ GetMarker()

virtual int HxMemStream::GetMarker ( )
virtual
Ghidra address:
NTSC-U/C: 0x00405e80
Ghidra address:
PAL: 0x0043f780

Reimplemented from HxStream.

◆ Size()

virtual int HxMemStream::Size ( )
virtual
Ghidra address:
NTSC-U/C: 0x00405e90
Ghidra address:
PAL: 0x0043f790

Reimplemented from HxStream.

◆ Write()

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

Report a fatal error, since the stream is read-only.

Both arguments are discarded.

Parameters
pSrcThe source buffer.
nSizeThe number of bytes to move.
Returns
This stream, which the routine never arrives at.
Ghidra address:
NTSC-U/C: 0x00405ea0
Ghidra address:
PAL: 0x0043f7a0

Reimplemented from HxStream.

◆ ReadData()

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

Move up to nSize bytes into pDest.

A short read is clamped rather than reported. Once the read position is at the end of the range, the status word becomes 1, and when the inherited fatal flag is set the routine also reports a fatal error.

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

Reimplemented from HxStream.


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