- cpp3ds
- MemoryInputStream
Implementation of input stream based on a memory chunk. More...
#include <MemoryInputStream.hpp>
Public Member Functions | |
MemoryInputStream () | |
Default constructor. More... | |
void | open (const void *data, std::size_t sizeInBytes) |
Open the stream from its data. More... | |
virtual Int64 | read (void *data, Int64 size) |
Read data from the stream. More... | |
virtual Int64 | seek (Int64 position) |
Change the current reading position. More... | |
virtual Int64 | tell () |
Get the current reading position in the stream. More... | |
virtual Int64 | getSize () |
Return the size of the stream. More... | |
Implementation of input stream based on a memory chunk.
This class is a specialization of cpp3ds::InputStream that reads from data in memory.
It wraps a memory chunk in the common cpp3ds::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 cpp3ds::InputStream, cpp3ds::MemoryInputStream adds a function to specify the pointer and size of the data in memory.
cpp3ds 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 a cpp3ds::InputStream.
Usage example:
cpp3ds::InputStream, cpp3ds::FileStream
Definition at line 42 of file MemoryInputStream.hpp.
cpp3ds::MemoryInputStream::MemoryInputStream | ( | ) |
Default constructor.
|
virtual |
Return the size of the stream.
Implements cpp3ds::InputStream.
void cpp3ds::MemoryInputStream::open | ( | const void * | data, |
std::size_t | sizeInBytes | ||
) |
Open the stream from its data.
data | Pointer to the data in memory |
sizeInBytes | Size of the data, in bytes |
|
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 |
Implements cpp3ds::InputStream.
|
virtual |
Change the current reading position.
position | The position to seek to, from the beginning |
Implements cpp3ds::InputStream.
|
virtual |
Get the current reading position in the stream.
Implements cpp3ds::InputStream.