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

Abstract class for custom file input streams. More...

#include <gf/InputStream.h>

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

Public Member Functions

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

Detailed Description

Abstract class for custom file input streams.

This class allows users to define their own file input sources from which Gamedev Framework can load resources.

Gamedev Framework resource classes like gf::Texture and gf::Shader provide loadFromFile() and loadFromMemory() functions, which read data from conventional sources. However, if you have data coming from a different source (over a network, embedded, encrypted, compressed, etc) you can derive your own class from gf::InputStream and load SFML resources with their loadFromStream() function.

Constructor & Destructor Documentation

gf::InputStream::InputStream ( )
default

Default constructor.

gf::InputStream::InputStream ( const InputStream )
delete

Deleted copy constructor.

virtual gf::InputStream::~InputStream ( )
virtual

Destructor.

Member Function Documentation

virtual std::size_t gf::InputStream::getSize ( )
pure virtual

Return the size of the stream.

Returns
The total number of bytes available in the stream

Implemented in gf::MemoryInputStream, and gf::FileInputStream.

InputStream& gf::InputStream::operator= ( const InputStream )
delete

Deleted copy assignment.

virtual std::size_t gf::InputStream::read ( void *  data,
std::size_t  size 
)
pure virtual

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

Implemented in gf::MemoryInputStream, and gf::FileInputStream.

virtual long gf::InputStream::seek ( long  position)
pure virtual

Change the current reading position.

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

Implemented in gf::MemoryInputStream, and gf::FileInputStream.

virtual long gf::InputStream::tell ( )
pure virtual

Get the current reading position in the stream.

Returns
The current position

Implemented in gf::MemoryInputStream, and gf::FileInputStream.