Documentation de SFML 2.6.0

Attention: cette page se réfère à une ancienne version de SFML. Cliquez ici pour passer à la dernière version.
Loading...
Searching...
No Matches
sf::MemoryInputStream Class Reference

Implementation of input stream based on a memory chunk. More...

#include <SFML/System/MemoryInputStream.hpp>

Inheritance diagram for sf::MemoryInputStream:
sf::InputStream

Public Member Functions

 MemoryInputStream ()
 Default constructor.
 
void open (const void *data, std::size_t sizeInBytes)
 Open the stream from its data.
 
virtual Int64 read (void *data, Int64 size)
 Read data from the stream.
 
virtual Int64 seek (Int64 position)
 Change the current reading position.
 
virtual Int64 tell ()
 Get the current reading position in the stream.
 
virtual Int64 getSize ()
 Return the size of the stream.
 

Detailed Description

Implementation of input stream based on a memory chunk.

This class is a specialization of InputStream that reads from data in memory.

It wraps a memory chunk in the common InputStream interface and therefore allows to use generic classes or functions that accept such a stream, with content already loaded in memory.

In addition to the virtual functions inherited from InputStream, MemoryInputStream adds a function to specify the pointer and size of the data in memory.

SFML resource classes can usually be loaded directly from memory, so this class shouldn't be useful to you unless you create your own algorithms that operate on an InputStream.

Usage example:

void process(InputStream& stream);
stream.open(thePtr, theSize);
process(stream);
Abstract class for custom file input streams.
Definition: InputStream.hpp:42
Implementation of input stream based on a memory chunk.
void open(const void *data, std::size_t sizeInBytes)
Open the stream from its data.

InputStream, FileInputStream

Definition at line 43 of file MemoryInputStream.hpp.

Constructor & Destructor Documentation

◆ MemoryInputStream()

sf::MemoryInputStream::MemoryInputStream ( )

Default constructor.

Member Function Documentation

◆ getSize()

virtual Int64 sf::MemoryInputStream::getSize ( )
virtual

Return the size of the stream.

Returns
The total number of bytes available in the stream, or -1 on error

Implements sf::InputStream.

◆ open()

void sf::MemoryInputStream::open ( const void *  data,
std::size_t  sizeInBytes 
)

Open the stream from its data.

Parameters
dataPointer to the data in memory
sizeInBytesSize of the data, in bytes

◆ read()

virtual Int64 sf::MemoryInputStream::read ( void *  data,
Int64  size 
)
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, or -1 on error

Implements sf::InputStream.

◆ seek()

virtual Int64 sf::MemoryInputStream::seek ( Int64  position)
virtual

Change the current reading position.

Parameters
positionThe position to seek to, from the beginning
Returns
The position actually sought to, or -1 on error

Implements sf::InputStream.

◆ tell()

virtual Int64 sf::MemoryInputStream::tell ( )
virtual

Get the current reading position in the stream.

Returns
The current position, or -1 on error.

Implements sf::InputStream.


The documentation for this class was generated from the following file: