CorsixTH engine (the C++ part)
Open source implementation of Theme Hospital
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
memory_reader Class Reference

Public Member Functions

 memory_reader (const uint8_t *pData, const size_t iLength)
 
bool are_bytes_available (size_t iSize) const
 Can iSize bytes be read from the file?
 
bool is_at_end_of_file () const
 Is EOF reached?
 
uint8_t read_uint8 ()
 Get an 8 bit value from the file.
 
uint16_t read_uint16 ()
 Get a 16 bit value from the file.
 
int read_int16 ()
 Get a signed 16 bit value from the file.
 
uint32_t read_uint32 ()
 Get a 32 bit value from the file.
 
bool read_string (std::string *pStr)
 Load string from the memory_reader.
 

Public Attributes

const uint8_t * data
 Pointer to the remaining data.
 
size_t remaining_bytes
 Remaining number of bytes.
 

Detailed Description

Data retrieval class, simulating sequential access to the data, keeping track of available length.

Constructor & Destructor Documentation

◆ memory_reader()

memory_reader::memory_reader ( const uint8_t *  pData,
const size_t  iLength 
)
inline

Member Function Documentation

◆ are_bytes_available()

bool memory_reader::are_bytes_available ( size_t  iSize) const
inline

Can iSize bytes be read from the file?

Parameters
iSizeNumber of bytes that are queried.
Returns
Whether the requested number of bytes is still available.

◆ is_at_end_of_file()

bool memory_reader::is_at_end_of_file ( ) const
inline

Is EOF reached?

Returns
Whether EOF has been reached.

◆ read_int16()

int memory_reader::read_int16 ( )
inline

Get a signed 16 bit value from the file.

Returns
The read signed 16 bit value.
Precondition
There should be at least 2 bytes available for reading.

◆ read_string()

bool memory_reader::read_string ( std::string *  pStr)
inline

Load string from the memory_reader.

Parameters
[out]pStrString to load.
Returns
Whether the string could be loaded.

◆ read_uint16()

uint16_t memory_reader::read_uint16 ( )
inline

Get a 16 bit value from the file.

Returns
Read 16 bit value.
Precondition
There should be at least 2 bytes available for reading.

◆ read_uint32()

uint32_t memory_reader::read_uint32 ( )
inline

Get a 32 bit value from the file.

Returns
Read 32 bit value.
Precondition
There should be at least 4 bytes available for reading.

◆ read_uint8()

uint8_t memory_reader::read_uint8 ( )
inline

Get an 8 bit value from the file.

Returns
Read 8 bit value.
Precondition
There should be at least a byte available for reading.

Member Data Documentation

◆ data

const uint8_t* memory_reader::data

Pointer to the remaining data.

◆ remaining_bytes

size_t memory_reader::remaining_bytes

Remaining number of bytes.


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