dsfml.system.inputstream

This interface allows users to define their own file input sources from which DSFML can load resources.

DSFML resource classes like $(TEXTURE_LINK) and $(SOUNDBUFFER_LINK) 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 $(U InputStream) and load DSFML resources with their loadFromStream function.

Usage example:

// custom stream class that reads from inside a zip file
class ZipStream : InputStream
{
public:

    ZipStream(string archive);

    bool open(string filename);

    long read(void[] data);

    long seek(long position);

    long tell();

    long getSize();

private:

    ...
};

// now you can load textures...
auto texture = new Texture();
auto stream = new ZipStream("resources.zip");
stream.open("images/img.png");
texture.loadFromStream(stream);

// musics...
auto music = new Music();
auto stream = new ZipStream("resources.zip");
stream.open("musics/msc.ogg");
music.openFromStream(stream);

// etc.

Members

Interfaces

InputStream
interface InputStream

Interface for custom file input streams.

Meta