Gamedev Framework (gf)  0.17.0
A C++14 framework for 2D games
Public Member Functions | List of all members
gf::MemoryInputStream Class Reference

Memory based input stream. More...

#include <gf/Streams.h>

Inheritance diagram for gf::MemoryInputStream:
Inheritance graph
[legend]

Public Member Functions

 MemoryInputStream (ArrayRef< uint8_t > memory)
 Constructor. More...
 
std::size_t read (BufferRef< uint8_t > buffer) override
 Read data from the stream. More...
 
void seek (std::ptrdiff_t position) override
 Change the current reading position. More...
 
void skip (std::ptrdiff_t position) override
 Change the current reading position. More...
 
bool isFinished () override
 Tell if the stream is at the end. More...
 
- Public Member Functions inherited from gf::InputStream
 InputStream ()=default
 Default constructor. More...
 
 InputStream (const InputStream &)=delete
 Deleted copy constructor. More...
 
InputStreamoperator= (const InputStream &)=delete
 Deleted copy assignment. More...
 
virtual ~InputStream ()
 Destructor. More...
 
std::size_t read (uint8_t &byte)
 Read a single byte from the stream. More...
 

Detailed Description

Memory based input stream.

Constructor & Destructor Documentation

◆ MemoryInputStream()

gf::MemoryInputStream::MemoryInputStream ( ArrayRef< uint8_t >  memory)
explicit

Constructor.

This class does not own the memory. The user must keep the memory available when the stream is active.

Parameters
memoryThe source memory

Member Function Documentation

◆ isFinished()

bool gf::MemoryInputStream::isFinished ( )
overridevirtual

Tell if the stream is at the end.

Returns
A boolean indicating the end of the stream

Implements gf::InputStream.

◆ read()

std::size_t gf::MemoryInputStream::read ( BufferRef< uint8_t >  buffer)
overridevirtual

Read data from the stream.

After reading, the stream's reading position must be advanced by the amount of bytes read.

Parameters
bufferThe buffer where to copy the read data
Returns
The number of bytes actually read

Implements gf::InputStream.

◆ seek()

void gf::MemoryInputStream::seek ( std::ptrdiff_t  position)
overridevirtual

Change the current reading position.

Parameters
positionThe position to seek to, from the beginning

Implements gf::InputStream.

◆ skip()

void gf::MemoryInputStream::skip ( std::ptrdiff_t  position)
overridevirtual

Change the current reading position.

Parameters
positionThe position to seek to, from the current position

Implements gf::InputStream.