wavelength 1.0.0
Loading...
Searching...
No Matches
BinStream Class Referenceabstract

Stream of raw bytes, the base of the memory, file, and network streams. More...

#include <binstream.h>

Inheritance diagram for BinStream:

Public Types

enum  SeekType {
  kSeekBegin = 0 , kSeekCurrent = 1 , kSeekEnd = 2 , kSeekBegin = 0 ,
  kSeekCurrent = 1 , kSeekEnd = 2
}
 Origins of Seek(). More...
enum  SeekType {
  kSeekBegin = 0 , kSeekCurrent = 1 , kSeekEnd = 2 , kSeekBegin = 0 ,
  kSeekCurrent = 1 , kSeekEnd = 2
}
 The origin of Seek(). More...

Public Member Functions

 BinStream (bool bLittleEndian)
 Construct a stream.
virtual ~BinStream ()
 Release the stream.
virtual void Read (void *pData, int nBytes)=0
 Read bytes.
virtual void Write (const void *pData, int nBytes)=0
 Write bytes.
virtual void Flush ()=0
 Write out buffered data.
virtual void Seek (int nOffset, SeekType eFrom)=0
 Move the position.
virtual int Tell ()=0
 Report the position.
virtual bool Eof ()=0
 Report whether the position is at the end.
virtual bool Fail ()=0
 Report whether a transfer failed.
virtual void Mark (const char *pszMark)
 Receive a named mark in the data, such as the end of a chunk.
void ReadString (char *pszBuffer, int nSize)
 Read a length-prefixed string into a buffer and terminate it.
void ReadString (String &text)
 Read a length-prefixed string.
BinStream & WriteString (const char *pszText)
 Write a string with its length first.
void ReadEndian (void *pData, int nBytes)
 Read a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
void WriteEndian (const void *pData, int nBytes)
 Write a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.
 BinStream (bool littleEndian)
 Set the byte order.
virtual ~BinStream ()
 Destroy the stream.
virtual void Read (void *data, int bytes)=0
 Read bytes.
virtual void Write (const void *data, int bytes)=0
 Write bytes.
virtual void Flush ()=0
 Write out buffered data.
virtual void Seek (int offset, SeekType type)=0
 Move the position.
virtual int Tell ()=0
virtual bool Eof ()=0
virtual bool Fail ()=0
virtual void NoOp (int)
 Do nothing.
void ReadEndian (void *data, int bytes)
 Read a value, swapping its bytes into the host order.
void WriteEndian (const void *data, int bytes)
 Write a value, swapping its bytes into the stream order.
BinStream & operator<< (const char *str)
 Write text as its length followed by its characters, without a terminator.
BinStream & operator>> (String &str)
 Read text written by operator<<(const char *).
void ReadString (char *buffer, int bufSize)
 Read text written by operator<<(const char *) into a buffer, and terminate it.
BinStream & operator<< (char c)
BinStream & operator<< (unsigned char c)
BinStream & operator<< (short s)
BinStream & operator<< (unsigned short s)
BinStream & operator<< (int i)
BinStream & operator<< (unsigned int i)
BinStream & operator<< (float f)
BinStream & operator>> (char &c)
BinStream & operator>> (unsigned char &c)
BinStream & operator>> (short &s)
BinStream & operator>> (unsigned short &s)
BinStream & operator>> (int &i)
BinStream & operator>> (unsigned int &i)
BinStream & operator>> (float &f)

Detailed Description

Stream of raw bytes, the base of the memory, file, and network streams.

Base of the streams that read and write binary data.

The RTTI includes the class name. One data word precedes the vptr at +0x04. Read() and Write() are pure in this class. Only the members its callers here use are declared.

In the European release the decryption generator follows that word and the vptr is at +0x08. Read(), Write(), and Seek() there are plain members that call the virtual ReadImpl(), WriteImpl(), and SeekImpl(). In the binary those take the vtable slots of the originals, with SeekImpl() before Flush(). Here they are protected and declared after the public members, and the vtable order differs from the binary's.

The object is 8 bytes. Values wider than a byte are stored least significant byte first when the stream is little-endian, and are byte-swapped otherwise.

Member Enumeration Documentation

◆ SeekType [1/2]

Origins of Seek().

Enumerator
kSeekBegin 

From the start of the stream.

kSeekCurrent 

From the current position.

From the position.

kSeekEnd 

From the end of the stream.

kSeekBegin 

From the start of the stream.

kSeekCurrent 

From the current position.

From the position.

kSeekEnd 

From the end of the stream.

◆ SeekType [2/2]

The origin of Seek().

Enumerator
kSeekBegin 

From the start of the stream.

kSeekCurrent 

From the current position.

From the position.

kSeekEnd 

From the end of the stream.

kSeekBegin 

From the start of the stream.

kSeekCurrent 

From the current position.

From the position.

kSeekEnd 

From the end of the stream.

Constructor & Destructor Documentation

◆ BinStream() [1/2]

BinStream::BinStream ( bool bLittleEndian)
inlineexplicit

Construct a stream.

Parameters
bLittleEndianWhether values are stored in the console's byte order.
Ghidra address:
NTSC-U/C: 0x00293f10
Ghidra address:
PAL: 0x0029d8c8

◆ ~BinStream() [1/2]

virtual BinStream::~BinStream ( )
inlinevirtual

Release the stream.

Ghidra address:
NTSC-U/C: 0x00339f10

◆ BinStream() [2/2]

BinStream::BinStream ( bool littleEndian)

Set the byte order.

Parameters
littleEndianWhether values are stored least significant byte first.
Ghidra address:
0x10019590

◆ ~BinStream() [2/2]

virtual BinStream::~BinStream ( )
inlinevirtual

Destroy the stream.

Ghidra address:
0x10011e40

Member Function Documentation

◆ Read() [1/2]

virtual void BinStream::Read ( void * pData,
int nBytes )
pure virtual

Read bytes.

Parameters
pDataThe destination.
nBytesThe number of bytes.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Write() [1/2]

virtual void BinStream::Write ( const void * pData,
int nBytes )
pure virtual

Write bytes.

Parameters
pDataThe source.
nBytesThe number of bytes.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Flush() [1/2]

virtual void BinStream::Flush ( )
pure virtual

Write out buffered data.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Seek() [1/2]

virtual void BinStream::Seek ( int nOffset,
SeekType eFrom )
pure virtual

Move the position.

Parameters
nOffsetThe offset in bytes.
eFromThe origin of the offset.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Tell() [1/2]

virtual int BinStream::Tell ( )
pure virtual

Report the position.

Returns
The position in bytes.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Eof() [1/2]

virtual bool BinStream::Eof ( )
pure virtual

Report whether the position is at the end.

Returns
Whether no byte is left.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Fail() [1/2]

virtual bool BinStream::Fail ( )
pure virtual

Report whether a transfer failed.

Returns
Whether a transfer failed.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Mark()

virtual void BinStream::Mark ( const char * pszMark)
inlinevirtual

Receive a named mark in the data, such as the end of a chunk.

The base ignores the mark. ChunkStream ends its block at a mark of g_szChunkMark.

Parameters
pszMarkThe mark.
Ghidra address:
NTSC-U/C: 0x00339f40
Ghidra address:
PAL: 0x004177d8

Reimplemented in ChunkStream.

◆ ReadString() [1/3]

void BinStream::ReadString ( char * pszBuffer,
int nSize )

Read a length-prefixed string into a buffer and terminate it.

The length is not checked against the size of the buffer.

Parameters
pszBufferReceives the text. The caller provides room for it.
nSizeThe size of the buffer.
Ghidra address:
NTSC-U/C: 0x00294468
Ghidra address:
PAL: 0x0029e098

◆ ReadString() [2/3]

void BinStream::ReadString ( String & text)

Read a length-prefixed string.

Parameters
textReceives the text.
Ghidra address:
NTSC-U/C: 0x00294408
Ghidra address:
PAL: 0x0029e040

◆ WriteString()

BinStream & BinStream::WriteString ( const char * pszText)

Write a string with its length first.

Parameters
pszTextThe text.
Returns
This stream.
Ghidra address:
NTSC-U/C: 0x00294390
Ghidra address:
PAL: 0x0029dfd8

◆ ReadEndian() [1/2]

void BinStream::ReadEndian ( void * pData,
int nBytes )

Read a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.

Parameters
pDataThe destination.
nBytesThe size of the value.
Ghidra address:
NTSC-U/C: 0x00293f28
Ghidra address:
PAL: 0x0029db90

◆ WriteEndian() [1/2]

void BinStream::WriteEndian ( const void * pData,
int nBytes )

Write a value of 2, 4, 8, or 16 bytes, reversing its bytes unless the stream is little endian.

Parameters
pDataThe source.
nBytesThe size of the value.
Ghidra address:
NTSC-U/C: 0x00294158
Ghidra address:
PAL: 0x0029ddb0

◆ Read() [2/2]

virtual void BinStream::Read ( void * data,
int bytes )
pure virtual

Read bytes.

Parameters
dataReceives the bytes.
bytesThe number of bytes.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Write() [2/2]

virtual void BinStream::Write ( const void * data,
int bytes )
pure virtual

Write bytes.

Parameters
dataThe bytes.
bytesThe number of bytes.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Flush() [2/2]

virtual void BinStream::Flush ( )
pure virtual

Write out buffered data.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Seek() [2/2]

virtual void BinStream::Seek ( int offset,
SeekType type )
pure virtual

Move the position.

Parameters
offsetThe offset in bytes.
typeThe origin of the offset.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Tell() [2/2]

virtual int BinStream::Tell ( )
pure virtual
Returns
The position in bytes.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Eof() [2/2]

virtual bool BinStream::Eof ( )
pure virtual
Returns
Whether the position is at the end.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ Fail() [2/2]

virtual bool BinStream::Fail ( )
pure virtual
Returns
Whether a transfer failed.

Implemented in AsyncStream, BufStream, BufStream, ChunkStream, FileStream, FileStream, and MemStream.

◆ NoOp()

virtual void BinStream::NoOp ( int )
inlinevirtual

Do nothing.

No stream of the control overrides or calls this, and its purpose is not known.

Ghidra address:
0x10011e30

◆ ReadEndian() [2/2]

void BinStream::ReadEndian ( void * data,
int bytes )

Read a value, swapping its bytes into the host order.

Parameters
dataReceives the value.
bytesThe size of the value: 2, 4, or 8.
Ghidra address:
0x100195b0

◆ WriteEndian() [2/2]

void BinStream::WriteEndian ( const void * data,
int bytes )

Write a value, swapping its bytes into the stream order.

Parameters
dataThe value.
bytesThe size of the value: 2, 4, or 8.
Ghidra address:
0x10019750

◆ operator<<() [1/8]

BinStream & BinStream::operator<< ( const char * str)

Write text as its length followed by its characters, without a terminator.

Parameters
strThe text.
Returns
The stream.
Ghidra address:
0x10019900

◆ operator>>() [1/8]

BinStream & BinStream::operator>> ( String & str)

Read text written by operator<<(const char *).

Parameters
strReceives the text.
Returns
The stream.
Ghidra address:
0x10019940

◆ ReadString() [3/3]

void BinStream::ReadString ( char * buffer,
int bufSize )

Read text written by operator<<(const char *) into a buffer, and terminate it.

Parameters
bufferReceives the text.
bufSizeThe size of the buffer, which must exceed the length of the text.
Ghidra address:
0x10019980

◆ operator<<() [2/8]

BinStream & BinStream::operator<< ( char c)
inline

◆ operator<<() [3/8]

BinStream & BinStream::operator<< ( unsigned char c)
inline

◆ operator<<() [4/8]

BinStream & BinStream::operator<< ( short s)
inline

◆ operator<<() [5/8]

BinStream & BinStream::operator<< ( unsigned short s)
inline

◆ operator<<() [6/8]

BinStream & BinStream::operator<< ( int i)
inline

◆ operator<<() [7/8]

BinStream & BinStream::operator<< ( unsigned int i)
inline

◆ operator<<() [8/8]

BinStream & BinStream::operator<< ( float f)
inline

◆ operator>>() [2/8]

BinStream & BinStream::operator>> ( char & c)
inline

◆ operator>>() [3/8]

BinStream & BinStream::operator>> ( unsigned char & c)
inline

◆ operator>>() [4/8]

BinStream & BinStream::operator>> ( short & s)
inline

◆ operator>>() [5/8]

BinStream & BinStream::operator>> ( unsigned short & s)
inline

◆ operator>>() [6/8]

BinStream & BinStream::operator>> ( int & i)
inline

◆ operator>>() [7/8]

BinStream & BinStream::operator>> ( unsigned int & i)
inline

◆ operator>>() [8/8]

BinStream & BinStream::operator>> ( float & f)
inline

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