Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Warning
This page refers to an old version of SFML. Click here to switch to the latest version.
Abstract class for custom file input streams. More...
#include <SFML/System/InputStream.hpp>
Public Member Functions | |
virtual | ~InputStream ()=default |
Virtual destructor. | |
virtual std::optional< std::size_t > | read (void *data, std::size_t size)=0 |
Read data from the stream. | |
virtual std::optional< std::size_t > | seek (std::size_t position)=0 |
Change the current reading position. | |
virtual std::optional< std::size_t > | tell ()=0 |
Get the current reading position in the stream. | |
virtual std::optional< std::size_t > | 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:
Definition at line 45 of file InputStream.hpp.
|
virtualdefault |
Virtual destructor.
|
pure virtual |
Return the size of the stream.
Implemented in sf::FileInputStream, and sf::MemoryInputStream.
|
nodiscardpure virtual |
Read data from the stream.
After reading, the stream's reading position must be advanced by the amount of bytes read.
data | Buffer where to copy the read data |
size | Desired number of bytes to read |
Implemented in sf::FileInputStream, and sf::MemoryInputStream.
|
nodiscardpure virtual |
Change the current reading position.
position | The position to seek to, from the beginning |
Implemented in sf::FileInputStream, and sf::MemoryInputStream.
|
nodiscardpure virtual |
Get the current reading position in the stream.
Implemented in sf::FileInputStream, and sf::MemoryInputStream.