SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
Classes | Typedefs | Functions | Variables

SDL provides an abstract interface for reading and writing data streams. More...

Classes

struct  SDL::IOStreamRef
 The read/write operation structure. More...
 
struct  SDL::IOStream
 Handle to an owned iOStream. More...
 
struct  SDL::IOStreamUnsafe
 Unsafe Handle to iOStream. More...
 

Typedefs

using SDL::IOStreamShared = ResourceShared< IOStream >
 Handle to a shared iOStream.
 
using SDL::IOStreamWeak = ResourceWeak< IOStream >
 Weak handle to a shared iOStream.
 
using SDL::IOStatus = SDL_IOStatus
 IOStream status, set by a read or write operation.
 
using SDL::IOWhence = SDL_IOWhence
 Possible whence values for IOStream seeking.
 
using SDL::IOStreamInterface = SDL_IOStreamInterface
 The function pointers that drive an IOStream.
 

Functions

StringResult SDL::LoadFile (StringParam file)
 Load all the data from a file path.
 
template<class T >
OwnArray< T > SDL::LoadFileAs (StringParam file)
 Load all the data from a file path.
 
void SDL::SaveFile (StringParam file, SourceBytes data)
 Save all the data into a file path.
 
IOStreamShared SDL::IOStream::share ()
 Move this iOStream into a IOStreamShared.
 

Variables

constexpr IOStatus SDL::IO_STATUS_READY
 Everything is ready (no errors and not EOF).
 
constexpr IOStatus SDL::IO_STATUS_ERROR
 Read or write I/O error.
 
constexpr IOStatus SDL::IO_STATUS_EOF = SDL_IO_STATUS_EOF
 End of file.
 
constexpr IOStatus SDL::IO_STATUS_NOT_READY
 Non blocking I/O, not ready.
 
constexpr IOStatus SDL::IO_STATUS_READONLY
 Tried to write a read-only buffer.
 
constexpr IOStatus SDL::IO_STATUS_WRITEONLY
 Tried to read a write-only buffer.
 
constexpr IOWhence SDL::IO_SEEK_SET
 Seek from the beginning of data.
 
constexpr IOWhence SDL::IO_SEEK_CUR
 Seek relative to current read point.
 
constexpr IOWhence SDL::IO_SEEK_END
 Seek relative to the end of data.
 

Detailed Description

It offers implementations for files, memory, etc, and the app can provide their own implementations, too.

IOStream is not related to the standard C++ iostream class, other than both are abstract interfaces to read/write data.

Typedef Documentation

◆ IOStatus

using SDL::IOStatus = typedef SDL_IOStatus
Since
This enum is available since SDL 3.2.0.

◆ IOStreamInterface

using SDL::IOStreamInterface = typedef SDL_IOStreamInterface

Applications can provide this struct to IOStream.Open() to create their own implementation of IOStream. This is not necessarily required, as SDL already offers several common types of I/O streams, via functions like IOStream.FromFile() and IOStream.FromMem().

This structure should be initialized using SDL_INIT_INTERFACE()

Since
This struct is available since SDL 3.2.0.
See also
SDL_INIT_INTERFACE

◆ IOStreamShared

Category:
Resource
See also
IOStreamRef
IOStream

◆ IOStreamWeak

◆ IOWhence

using SDL::IOWhence = typedef SDL_IOWhence

These map to the same "whence" concept that fseek or lseek use in the standard C runtime.

Since
This enum is available since SDL 3.2.0.

Function Documentation

◆ LoadFile()

StringResult SDL::LoadFile ( StringParam  file)
inline

The data is allocated with a zero byte at the end (null terminated) for convenience. This extra byte is not included in the value reported via datasize.

Parameters
filethe path to read all available data from.
Returns
the data.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
IOStreamRef.LoadFile
SaveFile

◆ LoadFileAs()

template<class T >
OwnArray< T > SDL::LoadFileAs ( StringParam  file)
inline

The data is allocated with a zero byte at the end (null terminated) for convenience. This extra byte is not included in the value reported via datasize.

Parameters
filethe path to read all available data from.
Returns
the data.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
IOStreamRef.LoadFile
SaveFile

◆ SaveFile()

void SDL::SaveFile ( StringParam  file,
SourceBytes  data 
)
inline
Parameters
filethe path to write all available data into.
datathe data to be written. If datasize is 0, may be nullptr or a invalid pointer.
Exceptions
Erroron failure.
Thread safety:
This function is not thread safe.
Since
This function is available since SDL 3.2.0.
See also
IOStreamRef.SaveFile
LoadFile

Variable Documentation

◆ IO_SEEK_CUR

constexpr IOWhence SDL::IO_SEEK_CUR
constexpr
Initial value:
=
SDL_IO_SEEK_CUR

◆ IO_SEEK_END

constexpr IOWhence SDL::IO_SEEK_END
constexpr
Initial value:
=
SDL_IO_SEEK_END

◆ IO_SEEK_SET

constexpr IOWhence SDL::IO_SEEK_SET
constexpr
Initial value:
=
SDL_IO_SEEK_SET

◆ IO_STATUS_ERROR

constexpr IOStatus SDL::IO_STATUS_ERROR
constexpr
Initial value:
=
SDL_IO_STATUS_ERROR

◆ IO_STATUS_NOT_READY

constexpr IOStatus SDL::IO_STATUS_NOT_READY
constexpr
Initial value:
=
SDL_IO_STATUS_NOT_READY

◆ IO_STATUS_READONLY

constexpr IOStatus SDL::IO_STATUS_READONLY
constexpr
Initial value:
=
SDL_IO_STATUS_READONLY

◆ IO_STATUS_READY

constexpr IOStatus SDL::IO_STATUS_READY
constexpr
Initial value:
=
SDL_IO_STATUS_READY

◆ IO_STATUS_WRITEONLY

constexpr IOStatus SDL::IO_STATUS_WRITEONLY
constexpr
Initial value:
=
SDL_IO_STATUS_WRITEONLY