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

BinStream over a file read into a buffer in the background. More...

#include <asyncstream.h>

Inheritance diagram for AsyncStream:
Collaboration diagram for AsyncStream:

Public Member Functions

 AsyncStream (const char *pszFile, bool bLittleEndian)
 Open a file and start reading it.
 ~AsyncStream () override
 Release the buffer and the file.
bool Ready (int nBytes)
 Report whether enough of the file has been read.
void Read (void *pData, int nBytes) override
 Read bytes, waiting for them to arrive.
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.
int Tell () override
 Report the position.
const char * GetFileName () const
 Report the file.
bool Eof () override
 Report whether the position is at the end of the file.
bool Fail () override
 Report whether a transfer failed.
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 file read into a buffer in the background.

The RTTI includes the class name and records BinStream as the base. The constructor opens the file and starts reading all of it into a buffer from the pool, billed to the tag "AsyncStream buf". Only the members its callers here use are declared.

Constructor & Destructor Documentation

◆ AsyncStream()

AsyncStream::AsyncStream ( const char * pszFile,
bool bLittleEndian )

Open a file and start reading it.

Parameters
pszFileThe file.
bLittleEndianWhether values are stored in the console's byte order.
Ghidra address:
NTSC-U/C: 0x00293ac0
Ghidra address:
PAL: 0x0029d488

◆ ~AsyncStream()

AsyncStream::~AsyncStream ( )
override

Release the buffer and the file.

Ghidra address:
NTSC-U/C: 0x00293ba0
Ghidra address:
PAL: 0x0029d568

Member Function Documentation

◆ Ready()

bool AsyncStream::Ready ( int nBytes)

Report whether enough of the file has been read.

Once the whole file has been read, the file is closed and every later call reports true.

Parameters
nBytesThe bytes needed.
Returns
Whether the read has finished or at least nBytes have arrived.
Ghidra address:
NTSC-U/C: 0x00293c38
Ghidra address:
PAL: 0x0029d5f0

◆ Read()

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

Read bytes, waiting for them to arrive.

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

Implements BinStream.

◆ Write()

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

Write bytes.

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

Implements BinStream.

◆ Flush()

void AsyncStream::Flush ( )
inlineoverridevirtual

Do nothing.

Ghidra address:
NTSC-U/C: 0x003a8a70
Ghidra address:
PAL: 0x00417728

Implements BinStream.

◆ Seek()

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

Move the position.

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

Implements BinStream.

◆ Tell()

int AsyncStream::Tell ( )
inlineoverridevirtual

Report the position.

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

Implements BinStream.

◆ GetFileName()

const char * AsyncStream::GetFileName ( ) const
inline

Report the file.

GfxManager::FindPreload() reads the name in place, and the image has no accessor.

Returns
The name of the file.

◆ Eof()

bool AsyncStream::Eof ( )
inlineoverridevirtual

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

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

Implements BinStream.

◆ Fail()

bool AsyncStream::Fail ( )
inlineoverridevirtual

Report whether a transfer failed.

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

Implements BinStream.


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