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

RWops adaptor for STL streams. More...

#include <SDL2pp/StreamRWops.hh>

Inheritance diagram for SDL2pp::StreamRWops< S >:
SDL2pp::CustomRWops

Public Member Functions

 StreamRWops (S &stream)
 Construct StreamRWops for specified stream.
 
virtual Sint64 Size () override
 Get the size of the data stream.
 
virtual Sint64 Seek (Sint64 offset, int whence) override
 Seek within the stream.
 
virtual size_t Read (void *ptr, size_t size, size_t maxnum) override
 Read from a stream.
 
virtual size_t Write (const void *ptr, size_t size, size_t num) override
 Write to a stream.
 
virtual int Close () override
 Close stream.
 
- 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

S & stream_
 Reference to stream.
 

Detailed Description

template<class S>
class SDL2pp::StreamRWops< S >

RWops adaptor for STL streams.

This class extends functionality of RWops concept onto STL streams. With ContainerRWops, you may read from / write to STL streams with SDL functions.

This template supports both input and output streams, but not at the same time, as separate input and output pointers of streams are not compatible with RWops.

Constructor & Destructor Documentation

◆ StreamRWops()

template<class S >
SDL2pp::StreamRWops< S >::StreamRWops ( S &  stream)
inline

Construct StreamRWops for specified stream.

Parameters
[in]streamStream to use

Member Function Documentation

◆ Close()

template<class S >
virtual int SDL2pp::StreamRWops< S >::Close ( )
inlineoverridevirtual

Close stream.

Returns
0 on success or a negative error code on failure
See also
SDL2pp::RWops::Close
http://wiki.libsdl.org/SDL_RWclose

Implements SDL2pp::CustomRWops.

◆ Read()

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

Read from a stream.

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 error or end of file
See also
SDL2pp::RWops::Read
http://wiki.libsdl.org/SDL_RWread

Implements SDL2pp::CustomRWops.

◆ Seek()

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

Seek within the stream.

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 stream after the seek or -1 on error
See also
SDL2pp::RWops::Seek
http://wiki.libsdl.org/SDL_RWseek

Implements SDL2pp::CustomRWops.

◆ Size()

template<class S >
virtual Sint64 SDL2pp::StreamRWops< S >::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 S >
virtual size_t SDL2pp::StreamRWops< S >::Write ( const void *  ptr,
size_t  size,
size_t  num 
)
inlineoverridevirtual

Write to a stream.

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: