wavelength 1.0.0
Loading...
Searching...
No Matches
BufStream Class Reference

BinStream over a buffer the caller provides. More...

#include <bufstream.h>

Inheritance diagram for BufStream:
Collaboration diagram for BufStream:

Public Member Functions

 BufStream (char *pBuffer, int nSize, bool bLittleEndian)
 Construct a stream at the start of a buffer.
 ~BufStream () override=default
 Release the stream.
void Read (void *pData, int nBytes) override
 Read bytes.
void Write (const void *pData, int nBytes) override
 Write bytes.
void Flush () override
 Do nothing.
void Seek (int nOffset, SeekType eFrom) override
 Move the position, failing the stream when it would leave the buffer.
int Tell () override
 Report the position.
bool Eof () override
 Report whether the position is at the end of the buffer.
bool Fail () override
 Report whether a transfer ran past the end.
 BufStream (char *buffer, int size, bool littleEndian)
 Start a stream at the beginning of a buffer.
virtual ~BufStream ()
 Destroy the stream.
virtual void Read (void *data, int bytes)
 Copy bytes out of the buffer.
virtual void Write (const void *data, int bytes)
 Copy bytes into the buffer.
virtual void Flush ()
 Do nothing; the buffer holds every byte written.
virtual void Seek (int offset, SeekType type)
 Move the position, failing the stream when it would leave the buffer.
virtual int Tell ()
virtual bool Eof ()
virtual bool Fail ()
Public Member Functions inherited from BinStream
 BinStream (bool bLittleEndian)
 Construct a stream.
virtual ~BinStream ()
 Release the stream.
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 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)

Additional Inherited Members

Public Types inherited from BinStream
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...

Detailed Description

BinStream over a buffer the caller provides.

Stream over a buffer the caller provides.

The RTTI includes the class name and records BinStream as the base. A read past the end of the buffer is shortened to the bytes left and marks the stream failed. Only the members its callers here use are declared.

The RTTI records the class as deriving from BinStream. The object is 0x18 bytes. A transfer that would pass the end is cut to the bytes that remain and marks the stream failed.

Constructor & Destructor Documentation

◆ BufStream() [1/2]

BufStream::BufStream ( char * pBuffer,
int nSize,
bool bLittleEndian )

Construct a stream at the start of a buffer.

A null buffer starts the stream failed.

Parameters
pBufferThe buffer. The caller retains it.
nSizeThe size of the buffer in bytes.
bLittleEndianWhether values are stored in the console's byte order.
Ghidra address:
NTSC-U/C: 0x002944c8
Ghidra address:
PAL: 0x0029e0f0

◆ ~BufStream() [1/2]

BufStream::~BufStream ( )
overridedefault

Release the stream.

The buffer is not released.

Ghidra address:
NTSC-U/C: 0x003a8ae0
Ghidra address:
PAL: 0x004178b0

◆ BufStream() [2/2]

BufStream::BufStream ( char * buffer,
int size,
bool littleEndian )

Start a stream at the beginning of a buffer.

A null buffer makes a failed stream.

Parameters
bufferThe buffer, or null.
sizeThe size of the buffer in bytes.
littleEndianWhether values are stored least significant byte first.
Ghidra address:
0x1002df70

◆ ~BufStream() [2/2]

virtual BufStream::~BufStream ( )
virtual

Destroy the stream.

The buffer is not released.

Ghidra address:
0x1002e010

Member Function Documentation

◆ Read() [1/2]

void BufStream::Read ( void * pData,
int nBytes )
overridevirtual

Read bytes.

Parameters
pDataThe destination.
nBytesThe number of bytes.
Ghidra address:
NTSC-U/C: 0x00294530
Ghidra address:
PAL: 0x0029e158

Implements BinStream.

◆ Write() [1/2]

void BufStream::Write ( const void * pData,
int nBytes )
overridevirtual

Write bytes.

Parameters
pDataThe source.
nBytesThe number of bytes.
Ghidra address:
NTSC-U/C: 0x002945a0
Ghidra address:
PAL: 0x0029e1c8

Implements BinStream.

◆ Flush() [1/2]

void BufStream::Flush ( )
inlineoverridevirtual

Do nothing.

Ghidra address:
NTSC-U/C: 0x003a8b60
Ghidra address:
PAL: 0x00417920

Implements BinStream.

◆ Seek() [1/2]

void BufStream::Seek ( int nOffset,
SeekType eFrom )
overridevirtual

Move the position, failing the stream when it would leave the buffer.

Parameters
nOffsetThe offset in bytes.
eFromThe origin of the offset.
Ghidra address:
NTSC-U/C: 0x00294610
Ghidra address:
PAL: 0x0029e238

Implements BinStream.

◆ Tell() [1/2]

int BufStream::Tell ( )
inlineoverridevirtual

Report the position.

Returns
The position in bytes.
Ghidra address:
NTSC-U/C: 0x003a8b68
Ghidra address:
PAL: 0x00417928

Implements BinStream.

◆ Eof() [1/2]

bool BufStream::Eof ( )
inlineoverridevirtual

Report whether the position is at the end of the buffer.

Returns
Whether no byte is left.
Ghidra address:
NTSC-U/C: 0x003a8b70
Ghidra address:
PAL: 0x00417930

Implements BinStream.

◆ Fail() [1/2]

bool BufStream::Fail ( )
inlineoverridevirtual

Report whether a transfer ran past the end.

Returns
Whether a transfer failed.
Ghidra address:
NTSC-U/C: 0x003a8b88
Ghidra address:
PAL: 0x00417948

Implements BinStream.

◆ Read() [2/2]

virtual void BufStream::Read ( void * data,
int bytes )
virtual

Copy bytes out of the buffer.

Parameters
dataReceives the bytes.
bytesThe number of bytes.
Ghidra address:
0x1002e020

Implements BinStream.

◆ Write() [2/2]

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

Copy bytes into the buffer.

Parameters
dataThe bytes.
bytesThe number of bytes.
Ghidra address:
0x1002e070

Implements BinStream.

◆ Flush() [2/2]

virtual void BufStream::Flush ( )
inlinevirtual

Do nothing; the buffer holds every byte written.

Implements BinStream.

◆ Seek() [2/2]

virtual void BufStream::Seek ( int offset,
SeekType type )
virtual

Move the position, failing the stream when it would leave the buffer.

Parameters
offsetThe offset in bytes.
typeThe origin of the offset. Another value leaves the position unchanged.
Ghidra address:
0x1002e0c0

Implements BinStream.

◆ Tell() [2/2]

virtual int BufStream::Tell ( )
virtual
Returns
The position in bytes.
Ghidra address:
0x1002dfb0

Implements BinStream.

◆ Eof() [2/2]

virtual bool BufStream::Eof ( )
virtual
Returns
Whether the position is at the end of the buffer.
Ghidra address:
0x1002dfc0

Implements BinStream.

◆ Fail() [2/2]

virtual bool BufStream::Fail ( )
virtual
Returns
Whether a transfer ran past the end, or the buffer is null.
Ghidra address:
0x1002dfe0

Implements BinStream.


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