libSDL2pp
C++ bindings/wrapper for SDL2
Loading...
Searching...
No Matches
Public Member Functions | Protected Attributes | List of all members
SDL2pp::ContainerRWops< C > Class Template Reference

RWops adaptor for random access STL containers. More...

#include <SDL2pp/ContainerRWops.hh>

Inheritance diagram for SDL2pp::ContainerRWops< C >:
SDL2pp::CustomRWops

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.
 

Detailed Description

template<class C>
class SDL2pp::ContainerRWops< C >

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.

Constructor & Destructor Documentation

◆ ContainerRWops()

template<class C >
SDL2pp::ContainerRWops< C >::ContainerRWops ( C &  container)
inline

Construct ContainerRWops for specified container.

Parameters
[in]containerContainer to use

Member Function Documentation

◆ Close()

template<class C >
virtual int SDL2pp::ContainerRWops< C >::Close ( )
inlineoverridevirtual

Close data source.

Returns
Always returns 0

This function is a no-op: there's nothing to be done to "close" the container

See also
SDL2pp::RWops::Close
http://wiki.libsdl.org/SDL_RWclose

Implements SDL2pp::CustomRWops.

◆ Read()

template<class C >
virtual size_t SDL2pp::ContainerRWops< C >::Read ( void *  ptr,
size_t  size,
size_t  maxnum 
)
inlineoverridevirtual

Read from a container.

Parameters
[in]ptrPointer to a buffer to read data into
[in]sizeSize of each object to read, in bytes
[in]maxnumMaximum number of objects to be read
Returns
Number of objects read, or 0 at end of file
See also
SDL2pp::RWops::Read
http://wiki.libsdl.org/SDL_RWread

Implements SDL2pp::CustomRWops.

◆ Seek()

template<class C >
virtual Sint64 SDL2pp::ContainerRWops< C >::Seek ( Sint64  offset,
int  whence 
)
inlineoverridevirtual

Seek within the container.

Parameters
[in]offsetOffset in bytes, relative to whence location; can be negative
[in]whenceAny of RW_SEEK_SET, RW_SEEK_CUR, RW_SEEK_END
Returns
Final offset in the container after the seek or -1 on error
See also
SDL2pp::RWops::Seek
http://wiki.libsdl.org/SDL_RWseek

Implements SDL2pp::CustomRWops.

◆ Size()

template<class C >
virtual Sint64 SDL2pp::ContainerRWops< C >::Size ( )
inlineoverridevirtual

Get the size of the data stream.

Returns
Size of the data stream on success, -1 if unknown
See also
SDL2pp::RWops::Size
http://wiki.libsdl.org/SDL_RWsize

Implements SDL2pp::CustomRWops.

◆ Write()

template<class C >
virtual size_t SDL2pp::ContainerRWops< C >::Write ( const void *  ptr,
size_t  size,
size_t  num 
)
inlineoverridevirtual

Write to container.

Parameters
[in]ptrPointer to a buffer containing data to write
[in]sizeSize of each object to write, in bytes
[in]numNumber of objects to be write
Returns
Number of objects written
See also
SDL2pp::RWops::Write
http://wiki.libsdl.org/SDL_RWwrite

Implements SDL2pp::CustomRWops.


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