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

Memory based input stream. More...

#include <gf/InputStreams.h>

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

Public Member Functions

 MemoryInputStream (const void *data, std::size_t size)
 Constructor. More...
 
virtual std::size_t read (void *data, std::size_t size) override
 Read data from the stream. More...
 
virtual long seek (long position) override
 Change the current reading position. More...
 
virtual long tell () override
 Get the current reading position in the stream. More...
 
virtual std::size_t getSize () override
 Return the size of the stream. 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...
 

Detailed Description

Memory based input stream.

Constructor & Destructor Documentation

◆ MemoryInputStream()

gf::MemoryInputStream::MemoryInputStream ( const void *  data,
std::size_t  size 
)

Constructor.

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

Parameters
dataPointer to the data
sizeSize of the data

Member Function Documentation

◆ getSize()

virtual std::size_t gf::MemoryInputStream::getSize ( )
overridevirtual

Return the size of the stream.

Returns
The total number of bytes available in the stream

Implements gf::InputStream.

◆ read()

virtual std::size_t gf::MemoryInputStream::read ( void *  data,
std::size_t  size 
)
overridevirtual

Read data from the stream.

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

Parameters
dataBuffer where to copy the read data
sizeDesired number of bytes to read
Returns
The number of bytes actually read

Implements gf::InputStream.

◆ seek()

virtual long gf::MemoryInputStream::seek ( long  position)
overridevirtual

Change the current reading position.

Parameters
positionThe position to seek to, from the beginning
Returns
The position actually sought to

Implements gf::InputStream.

◆ tell()

virtual long gf::MemoryInputStream::tell ( )
overridevirtual

Get the current reading position in the stream.

Returns
The current position

Implements gf::InputStream.