Abstract class for custom file input streams. More...
#include <InputStream.hpp>
Public Member Functions | |
virtual | ~InputStream () |
Virtual destructor. | |
virtual Int64 | Read (char *data, Int64 size)=0 |
Read data from the stream. | |
virtual Int64 | Seek (Int64 position)=0 |
Change the current reading position. | |
virtual Int64 | Tell ()=0 |
Get the current reading position in the stream. | |
virtual Int64 | GetSize ()=0 |
Return the size of the stream. |
Abstract class for custom file input streams.
This class allows users to define their own file input sources from which SFML can load resources.
SFML resource classes like sf::Texture and sf::SoundBuffer 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 sf::InputStream and load SFML resources with their LoadFromStream function.
Usage example:
// custom stream class that reads from inside a zip file class ZipStream : public sf::InputStream { public : ZipStream(std::string archive); bool Open(std::string filename); Int64 Read(char* data, Int64 size); Int64 Seek(Int64 position); Int64 Tell(); Int64 GetSize(); private : ... }; // now you can load textures... sf::Texture texture; ZipStream stream("resources.zip"); stream.Open("images/img.png"); texture.LoadFromStream(stream); // musics... sf::Music music; ZipStream stream("resources.zip"); stream.Open("musics/msc.ogg"); music.OpenFromStream(stream); // etc.
Definition at line 40 of file InputStream.hpp.
virtual sf::InputStream::~InputStream | ( | ) | [inline, virtual] |
Virtual destructor.
Definition at line 48 of file InputStream.hpp.
virtual Int64 sf::InputStream::GetSize | ( | ) | [pure virtual] |
Return the size of the stream.
virtual Int64 sf::InputStream::Read | ( | char * | data, |
Int64 | size | ||
) | [pure virtual] |
Read data from the stream.
data | Buffer where to copy the read data |
size | Desired number of bytes to read |
virtual Int64 sf::InputStream::Seek | ( | Int64 | position | ) | [pure virtual] |
Change the current reading position.
position | The position to seek to, from the beginning |
virtual Int64 sf::InputStream::Tell | ( | ) | [pure virtual] |
Get the current reading position in the stream.