Loading [MathJax]/extensions/tex2jax.js
A reimplementation of Mario Kart Wii's physics engine in C++
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages Concepts
EGG::RamStream Class Reference

#include <Stream.hh>

Description

A stream of data stored in memory.

RamStream solves two problems:

  1. Inconsistent endianness across Kinoko clients.
  2. Having to maintain pointer arithmetic while reading in various data types. We specify the endianness of the data in the stream, and the stream will handle the rest.

Definition at line 64 of file Stream.hh.

Inheritance diagram for EGG::RamStream:

Public Member Functions

 RamStream (const void *buffer, u32 size)
 
void read (void *output, u32 size) override
 
void write (void *input, u32 size) override
 
bool eof () const override
 
bool safe (u32 size) const override
 
bool bad () const override
 
std::string read_string ()
 
RamStream split (u32 size)
 Splits the current stream into two.
 
void setBufferAndSize (void *buffer, u32 size)
 
u8 * data ()
 
u8 * dataAtIndex ()
 
- Public Member Functions inherited from EGG::Stream
void skip (u32 count)
 
void jump (u32 index)
 
void setEndian (std::endian endian)
 
u32 index () const
 
u8 read_u8 ()
 
u16 read_u16 ()
 
u32 read_u32 ()
 
u64 read_u64 ()
 
s8 read_s8 ()
 
s16 read_s16 ()
 
s32 read_s32 ()
 
s64 read_s64 ()
 
f32 read_f32 ()
 
f64 read_f64 ()
 

Private Attributes

u8 * m_buffer
 
u32 m_size
 

Additional Inherited Members

- Protected Attributes inherited from EGG::Stream
std::endian m_endian
 
u32 m_index
 

Constructor & Destructor Documentation

◆ RamStream() [1/2]

EGG::RamStream::RamStream ( )

Definition at line 59 of file Stream.cc.

◆ RamStream() [2/2]

EGG::RamStream::RamStream ( const void * buffer,
u32 size )

Definition at line 61 of file Stream.cc.

Member Function Documentation

◆ bad()

bool EGG::RamStream::bad ( ) const
inlinenodiscardoverridevirtual

Implements EGG::Stream.

Definition at line 81 of file Stream.hh.

◆ data()

u8 * EGG::RamStream::data ( )
inlinenodiscard

Definition at line 89 of file Stream.hh.

◆ dataAtIndex()

u8 * EGG::RamStream::dataAtIndex ( )
inlinenodiscard

Definition at line 93 of file Stream.hh.

◆ eof()

bool EGG::RamStream::eof ( ) const
inlinenodiscardoverridevirtual

Implements EGG::Stream.

Definition at line 73 of file Stream.hh.

◆ read()

void EGG::RamStream::read ( void * output,
u32 size )
overridevirtual

Implements EGG::Stream.

Definition at line 65 of file Stream.cc.

◆ read_string()

std::string EGG::RamStream::read_string ( )
nodiscard

Definition at line 80 of file Stream.cc.

◆ safe()

bool EGG::RamStream::safe ( u32 size) const
inlinenodiscardoverridevirtual

Implements EGG::Stream.

Definition at line 77 of file Stream.hh.

◆ setBufferAndSize()

void EGG::RamStream::setBufferAndSize ( void * buffer,
u32 size )

Definition at line 87 of file Stream.cc.

◆ split()

RamStream EGG::RamStream::split ( u32 size)
nodiscard

Splits the current stream into two.

Segments the current stream at the current index. The returned stream is the data from the current index to size bytes after. The current stream is then moved to size bytes after the current index.

Definition at line 96 of file Stream.cc.

◆ write()

void EGG::RamStream::write ( void * input,
u32 size )
overridevirtual

Implements EGG::Stream.

Definition at line 72 of file Stream.cc.

Member Data Documentation

◆ m_buffer

u8* EGG::RamStream::m_buffer
private

Definition at line 98 of file Stream.hh.

◆ m_size

u32 EGG::RamStream::m_size
private

Definition at line 99 of file Stream.hh.