dsfml.system.inputstream

This class 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:

1  // custom stream class that reads from inside a zip file
2  class ZipStream : InputStream
3  {
4  public:
5 *
6      ZipStream(string archive);
7 *
8      bool open(string filename);
9 *
10      long read(void[] data);
11 *
12      long seek(long position);
13 *
14      long tell();
15 *
16      long getSize();
17 *
18  private:
19 *
20      ...
21  };
22 *
23  // now you can load textures...
24  auto texture = new Texture();
25  auto stream = new ZipStream("resources.zip");
26  stream.open("images/img.png");
27  texture.loadFromStream(stream);
28 *
29  // musics...
30  auto music = new Music();
31  auto stream = new ZipStream("resources.zip");
32  stream.open("musics/msc.ogg");
33  music.openFromStream(stream);
34 *
35  // etc.

Members

Interfaces

InputStream
interface InputStream

Interface for custom file input streams.

Meta