libSDL2pp
C++ bindings/wrapper for SDL2
|
RWops adaptor for random access STL containers. More...
#include <SDL2pp/ContainerRWops.hh>
Public Member Functions | |
ContainerRWops (C &container) | |
Construct ContainerRWops for specified container. | |
virtual Sint64 | Size () override |
Get the size of the data stream. | |
virtual Sint64 | Seek (Sint64 offset, int whence) override |
Seek within the container. | |
virtual size_t | Read (void *ptr, size_t size, size_t maxnum) override |
Read from a container. | |
virtual size_t | Write (const void *ptr, size_t size, size_t num) override |
Write to container. | |
virtual int | Close () override |
Close data source. | |
Public Member Functions inherited from SDL2pp::CustomRWops | |
virtual | ~CustomRWops () |
Destructor. | |
virtual Sint64 | Size ()=0 |
Get the size of the data stream. | |
virtual Sint64 | Seek (Sint64 offset, int whence)=0 |
Seek within the data stream. | |
virtual size_t | Read (void *ptr, size_t size, size_t maxnum)=0 |
Read from a data stream. | |
virtual size_t | Write (const void *ptr, size_t size, size_t num)=0 |
Write to a data stream. | |
virtual int | Close ()=0 |
Close data source. | |
Protected Attributes | |
C & | container_ |
Reference to container. | |
size_t | position_ |
Virtual file pointer position. | |
RWops adaptor for random access STL containers.
This class extends functionality of RWops concept onto random access STL containers such as std::vector. With ContainerRWops, you may read from / write to a container with SDL functions as if it were a plain file.
Note that this template supports both const and mutable containers. Writes to const containers always return 0, writes to mutable containers extend them as needed.
|
inline |
Construct ContainerRWops for specified container.
[in] | container | Container to use |
|
inlineoverridevirtual |
Close data source.
This function is a no-op: there's nothing to be done to "close" the container
Implements SDL2pp::CustomRWops.
|
inlineoverridevirtual |
Read from a container.
[in] | ptr | Pointer to a buffer to read data into |
[in] | size | Size of each object to read, in bytes |
[in] | maxnum | Maximum number of objects to be read |
Implements SDL2pp::CustomRWops.
|
inlineoverridevirtual |
Seek within the container.
[in] | offset | Offset in bytes, relative to whence location; can be negative |
[in] | whence | Any of RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END |
Implements SDL2pp::CustomRWops.
|
inlineoverridevirtual |
Get the size of the data stream.
Implements SDL2pp::CustomRWops.
|
inlineoverridevirtual |
Write to container.
[in] | ptr | Pointer to a buffer containing data to write |
[in] | size | Size of each object to write, in bytes |
[in] | num | Number of objects to be write |
Implements SDL2pp::CustomRWops.