SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches

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

Namespaces

namespace  SDL::prop
 Constants for Properties keys.
namespace  SDL::prop::IOStream
 Properties for IOStream.

Classes

struct  SDL::IOStream
 The read/write operation structure. More...

Typedefs

using SDL::IOStreamRaw = SDL_IOStream*
 Alias to raw representation for IOStream.
using SDL::IOStreamRef = ResourceRef<IOStream>
 Reference for 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

IOStream SDL::IOFromFile (StringParam file, StringParam mode)
 Use this function to create a new IOStream structure for reading from and/or writing to a named file.
IOStream SDL::IOFromMem (TargetBytes mem)
 Use this function to prepare a read-write memory buffer for use with IOStream.
IOStream SDL::IOFromConstMem (SourceBytes mem)
 Use this function to prepare a read-only memory buffer for use with IOStream.
IOStream SDL::IOFromDynamicMem ()
 Use this function to create an IOStream that is backed by dynamically allocated memory.
IOStream SDL::OpenIO (const IOStreamInterface &iface, void *userdata)
 Create a custom IOStream.
void SDL::CloseIO (IOStreamRaw context)
 Close and free an allocated IOStream structure.
PropertiesRef SDL::GetIOProperties (IOStreamRef context)
 Get the properties associated with an IOStream.
IOStatus SDL::GetIOStatus (IOStreamRef context)
 Query the stream status of an IOStream.
Sint64 SDL::GetIOSize (IOStreamRef context)
 Use this function to get the size of the data stream in an IOStream.
Sint64 SDL::SeekIO (IOStreamRef context, Sint64 offset, IOWhence whence)
 Seek within an IOStream data stream.
Sint64 SDL::TellIO (IOStreamRef context)
 Determine the current read/write offset in an IOStream data stream.
size_t SDL::ReadIO (IOStreamRef context, TargetBytes buf)
 Read from a data source.
size_t SDL::WriteIO (IOStreamRef context, SourceBytes buf)
 Write to an IOStream data stream.
size_t SDL::IOprintf (IOStreamRef context, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
 Print to an IOStream data stream.
size_t SDL::IOvprintf (IOStreamRef context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
 Print to an IOStream data stream.
void SDL::FlushIO (IOStreamRef context)
 Flush any buffered data in the stream.
StringResult SDL::LoadFile_IO (IOStreamRef src, bool closeio=true)
 Load all the data from an SDL data stream.
template<class T>
OwnArray< T > SDL::LoadFileAs (StringParam file)
 Load all the data from a file path.
StringResult SDL::LoadFile (StringParam file)
 Load all the data from a file path.
void SDL::SaveFile_IO (IOStreamRef src, SourceBytes data, bool closeio=true)
 Save all the data into an SDL data stream.
void SDL::SaveFile (StringParam file, SourceBytes data)
 Save all the data into a file path.
Uint8 SDL::ReadU8 (IOStreamRef src)
 Use this function to read a byte from an IOStream.
Sint8 SDL::ReadS8 (IOStreamRef src)
 Use this function to read a signed byte from an IOStream.
Uint16 SDL::ReadU16LE (IOStreamRef src)
 Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Sint16 SDL::ReadS16LE (IOStreamRef src)
 Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Uint16 SDL::ReadU16BE (IOStreamRef src)
 Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Sint16 SDL::ReadS16BE (IOStreamRef src)
 Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Uint32 SDL::ReadU32LE (IOStreamRef src)
 Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Sint32 SDL::ReadS32LE (IOStreamRef src)
 Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Uint32 SDL::ReadU32BE (IOStreamRef src)
 Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Sint32 SDL::ReadS32BE (IOStreamRef src)
 Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Uint64 SDL::ReadU64LE (IOStreamRef src)
 Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Sint64 SDL::ReadS64LE (IOStreamRef src)
 Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Uint64 SDL::ReadU64BE (IOStreamRef src)
 Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
Sint64 SDL::ReadS64BE (IOStreamRef src)
 Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
void SDL::WriteU8 (IOStreamRef dst, Uint8 value)
 Use this function to write a byte to an IOStream.
void SDL::WriteS8 (IOStreamRef dst, Sint8 value)
 Use this function to write a signed byte to an IOStream.
void SDL::WriteU16LE (IOStreamRef dst, Uint16 value)
 Use this function to write 16 bits in native format to an IOStream as little-endian data.
void SDL::WriteS16LE (IOStreamRef dst, Sint16 value)
 Use this function to write 16 bits in native format to an IOStream as little-endian data.
void SDL::WriteU16BE (IOStreamRef dst, Uint16 value)
 Use this function to write 16 bits in native format to an IOStream as big-endian data.
void SDL::WriteS16BE (IOStreamRef dst, Sint16 value)
 Use this function to write 16 bits in native format to an IOStream as big-endian data.
void SDL::WriteU32LE (IOStreamRef dst, Uint32 value)
 Use this function to write 32 bits in native format to an IOStream as little-endian data.
void SDL::WriteS32LE (IOStreamRef dst, Sint32 value)
 Use this function to write 32 bits in native format to an IOStream as little-endian data.
void SDL::WriteU32BE (IOStreamRef dst, Uint32 value)
 Use this function to write 32 bits in native format to an IOStream as big-endian data.
void SDL::WriteS32BE (IOStreamRef dst, Sint32 value)
 Use this function to write 32 bits in native format to an IOStream as big-endian data.
void SDL::WriteU64LE (IOStreamRef dst, Uint64 value)
 Use this function to write 64 bits in native format to an IOStream as little-endian data.
void SDL::WriteS64LE (IOStreamRef dst, Sint64 value)
 Use this function to write 64 bits in native format to an IOStream as little-endian data.
void SDL::WriteU64BE (IOStreamRef dst, Uint64 value)
 Use this function to write 64 bits in native format to an IOStream as big-endian data.
void SDL::WriteS64BE (IOStreamRef dst, Sint64 value)
 Use this function to write 64 bits in native format to an IOStream as big-endian data.
static IOStream SDL::IOStream::FromFile (StringParam file, StringParam mode)
 Use this function to create a new IOStream structure for reading from and/or writing to a named file.
static IOStream SDL::IOStream::FromMem (TargetBytes mem)
 Use this function to prepare a read-write memory buffer for use with IOStream.
static IOStream SDL::IOStream::FromConstMem (SourceBytes mem)
 Use this function to prepare a read-only memory buffer for use with IOStream.
static IOStream SDL::IOStream::FromDynamicMem ()
 Use this function to create an IOStream that is backed by dynamically allocated memory.
static IOStream SDL::IOStream::Open (const IOStreamInterface &iface, void *userdata)
 Create a custom IOStream.
void SDL::IOStream::Close ()
 Close and free an allocated IOStream structure.
PropertiesRef SDL::IOStream::GetProperties () const
 Get the properties associated with an IOStream.
IOStatus SDL::IOStream::GetStatus () const
 Query the stream status of an IOStream.
Sint64 SDL::IOStream::GetSize () const
 Use this function to get the size of the data stream in an IOStream.
Sint64 SDL::IOStream::Seek (Sint64 offset, IOWhence whence)
 Seek within an IOStream data stream.
Sint64 SDL::IOStream::Tell () const
 Determine the current read/write offset in an IOStream data stream.
size_t SDL::IOStream::Read (TargetBytes buf)
 Read from a data source.
size_t SDL::IOStream::Write (SourceBytes buf)
 Write to an IOStream data stream.
size_t SDL::IOStream::vprintf (SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
 Print to an IOStream data stream.
void SDL::IOStream::Flush ()
 Flush any buffered data in the stream.
StringResult SDL::IOStream::LoadFile ()
 Load all the data from an SDL data stream.
void SDL::IOStream::SaveFile (SourceBytes data)
 Save all the data into an SDL data stream.
Uint8 SDL::IOStream::ReadU8 ()
 Use this function to read a byte from an IOStream.
Sint8 SDL::IOStream::ReadS8 ()
 Use this function to read a signed byte from an IOStream.
Uint16 SDL::IOStream::ReadU16LE ()
 Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Sint16 SDL::IOStream::ReadS16LE ()
 Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Uint16 SDL::IOStream::ReadU16BE ()
 Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Sint16 SDL::IOStream::ReadS16BE ()
 Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Uint32 SDL::IOStream::ReadU32LE ()
 Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Sint32 SDL::IOStream::ReadS32LE ()
 Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Uint32 SDL::IOStream::ReadU32BE ()
 Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Sint32 SDL::IOStream::ReadS32BE ()
 Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Uint64 SDL::IOStream::ReadU64LE ()
 Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Sint64 SDL::IOStream::ReadS64LE ()
 Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Uint64 SDL::IOStream::ReadU64BE ()
 Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
Sint64 SDL::IOStream::ReadS64BE ()
 Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
void SDL::IOStream::WriteU8 (Uint8 value)
 Use this function to write a byte to an IOStream.
void SDL::IOStream::WriteS8 (Sint8 value)
 Use this function to write a signed byte to an IOStream.
void SDL::IOStream::WriteU16LE (Uint16 value)
 Use this function to write 16 bits in native format to an IOStream as little-endian data.
void SDL::IOStream::WriteS16LE (Sint16 value)
 Use this function to write 16 bits in native format to an IOStream as little-endian data.
void SDL::IOStream::WriteU16BE (Uint16 value)
 Use this function to write 16 bits in native format to an IOStream as big-endian data.
void SDL::IOStream::WriteS16BE (Sint16 value)
 Use this function to write 16 bits in native format to an IOStream as big-endian data.
void SDL::IOStream::WriteU32LE (Uint32 value)
 Use this function to write 32 bits in native format to an IOStream as little-endian data.
void SDL::IOStream::WriteS32LE (Sint32 value)
 Use this function to write 32 bits in native format to an IOStream as little-endian data.
void SDL::IOStream::WriteU32BE (Uint32 value)
 Use this function to write 32 bits in native format to an IOStream as big-endian data.
void SDL::IOStream::WriteS32BE (Sint32 value)
 Use this function to write 32 bits in native format to an IOStream as big-endian data.
void SDL::IOStream::WriteU64LE (Uint64 value)
 Use this function to write 64 bits in native format to an IOStream as little-endian data.
void SDL::IOStream::WriteS64LE (Sint64 value)
 Use this function to write 64 bits in native format to an IOStream as little-endian data.
void SDL::IOStream::WriteU64BE (Uint64 value)
 Use this function to write 64 bits in native format to an IOStream as big-endian data.
void SDL::IOStream::WriteS64BE (Sint64 value)
 Use this function to write 64 bits in native format to an IOStream as big-endian data.

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

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

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 = SDL_IOStatus

IOStream status, set by a read or write operation.

Since
This enum is available since SDL 3.2.0.

◆ IOStreamInterface

using SDL::IOStreamInterface = SDL_IOStreamInterface

The function pointers that drive an IOStream.

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 InitInterface()

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

◆ IOStreamRef

Reference for IOStream.

This does not take ownership!

◆ IOWhence

using SDL::IOWhence = SDL_IOWhence

Possible whence values for IOStream seeking.

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

◆ Close()

void SDL::IOStream::Close ( )
inline

Close and free an allocated IOStream structure.

IOStream.Close() closes and cleans up the IOStream stream. It releases any resources used by the stream and frees the IOStream itself. This returns true on success, or false if the stream failed to flush to its output (e.g. to disk).

Note that if this fails to flush the stream for any reason, this function reports an error, but the IOStream is still invalid once this function returns.

This call flushes any buffered writes to the operating system, but there are no guarantees that those writes have gone to physical media; they might be in the OS's file cache, waiting to go to disk later. If it's absolutely crucial that writes go to disk immediately, so they are definitely stored even if the power fails before the file cache would have caught up, one should call IOStream.Flush() before closing. Note that flushing takes time and makes the system and your app operate less efficiently, so do so sparingly.

Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Open

◆ CloseIO()

void SDL::CloseIO ( IOStreamRaw context)
inline

Close and free an allocated IOStream structure.

IOStream.Close() closes and cleans up the IOStream stream. It releases any resources used by the stream and frees the IOStream itself. This returns true on success, or false if the stream failed to flush to its output (e.g. to disk).

Note that if this fails to flush the stream for any reason, this function reports an error, but the IOStream is still invalid once this function returns.

This call flushes any buffered writes to the operating system, but there are no guarantees that those writes have gone to physical media; they might be in the OS's file cache, waiting to go to disk later. If it's absolutely crucial that writes go to disk immediately, so they are definitely stored even if the power fails before the file cache would have caught up, one should call IOStream.Flush() before closing. Note that flushing takes time and makes the system and your app operate less efficiently, so do so sparingly.

Parameters
contextIOStream structure to close.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Open

◆ Flush()

void SDL::IOStream::Flush ( )
inline

Flush any buffered data in the stream.

This function makes sure that any buffered data is written to the stream. Normally this isn't necessary but if the stream is a pipe or socket it guarantees that any pending data is sent.

Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Open
IOStream.Write

◆ FlushIO()

void SDL::FlushIO ( IOStreamRef context)
inline

Flush any buffered data in the stream.

This function makes sure that any buffered data is written to the stream. Normally this isn't necessary but if the stream is a pipe or socket it guarantees that any pending data is sent.

Parameters
contextIOStream structure to flush.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Open
IOStream.Write

◆ FromConstMem()

IOStream SDL::IOStream::FromConstMem ( SourceBytes mem)
inlinestatic

Use this function to prepare a read-only memory buffer for use with IOStream.

This function sets up an IOStream struct based on a memory area of a certain size. It assumes the memory area is not writable.

Attempting to write to this IOStream stream will report an error without writing to the memory buffer.

This memory buffer is not copied by the IOStream; the pointer you provide must remain valid until you close the stream.

If you need to write to a memory buffer, you should use IOStream.FromMem() with a writable buffer of memory instead.

The following properties will be set at creation time by SDL:

  • prop::IOStream.MEMORY_POINTER: this will be the mem parameter that was passed to this function.
  • prop::IOStream.MEMORY_SIZE_NUMBER: this will be the size parameter that was passed to this function.

Additionally, the following properties are recognized:

  • prop::IOStream.MEMORY_FREE_FUNC_POINTER: if this property is set to a non-nullptr value it will be interpreted as a function of free_func type and called with the passed mem pointer when closing the stream. By default it is unset, i.e., the memory will not be freed.
Parameters
mema read-only buffer to feed an IOStreamRef stream.
Returns
a valid IOStream on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.FromMem
IOStream.Close
IOStream.Read
IOStream.Seek
IOStream.Tell

◆ FromDynamicMem()

IOStream SDL::IOStream::FromDynamicMem ( )
inlinestatic

Use this function to create an IOStream that is backed by dynamically allocated memory.

This supports the following properties to provide access to the memory and control over allocations:

  • prop::IOStream.DYNAMIC_MEMORY_POINTER: a pointer to the internal memory of the stream. This can be set to nullptr to transfer ownership of the memory to the application, which should free the memory with free(). If this is done, the next operation on the stream must be IOStream.Close().
  • prop::IOStream.DYNAMIC_CHUNKSIZE_NUMBER: memory will be allocated in multiples of this size, defaulting to 1024.
Returns
a valid IOStream on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Close
IOStream.Read
IOStream.Seek
IOStream.Tell
IOStream.Write

◆ FromFile()

IOStream SDL::IOStream::FromFile ( StringParam file,
StringParam mode )
inlinestatic

Use this function to create a new IOStream structure for reading from and/or writing to a named file.

The mode string is treated roughly the same as in a call to the C library's fopen(), even if SDL doesn't happen to use fopen() behind the scenes.

Available mode strings:

  • "r": Open a file for reading. The file must exist.
  • "w": Create an empty file for writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
  • "wx": Create an empty file for writing. If a file with the same name already exists, the call fails. (Supported since SDL 3.4.0)
  • "a": Append to a file. Writing operations append data at the end of the file. The file is created if it does not exist.
  • "r+": Open a file for update both reading and writing. The file must exist.
  • "w+": Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
  • "w+x": Create an empty file for both reading and writing. If a file with the same name already exists, the call fails. (Supported since SDL 3.4.0)
  • "a+": Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.

NOTE: In order to open a file as a binary file, a "b" character has to be included in the mode string. This additional "b" character can either be appended at the end of the string (thus making the following compound modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+"). Additional characters may follow the sequence, although they should have no effect. For example, "t" is sometimes appended to make explicit the file is a text file.

This function supports Unicode filenames, but they must be encoded in UTF-8 format, regardless of the underlying operating system.

In Android, IOStream.FromFile() can be used to open content:// URIs. As a fallback, IOStream.FromFile() will transparently open a matching filename in the app's assets.

Closing the IOStream will close SDL's internal file handle.

The following properties may be set at creation time by SDL:

  • prop::IOStream.WINDOWS_HANDLE_POINTER: a pointer, that can be cast to a win32 HANDLE, that this IOStream is using to access the filesystem. If the program isn't running on Windows, or SDL used some other method to access the filesystem, this property will not be set.
  • prop::IOStream.STDIO_FILE_POINTER: a pointer, that can be cast to a stdio FILE *, that this IOStream is using to access the filesystem. If SDL used some other method to access the filesystem, this property will not be set. PLEASE NOTE that if SDL is using a different C runtime than your app, trying to use this pointer will almost certainly result in a crash! This is mostly a problem on Windows; make sure you build SDL and your app with the same compiler and settings to avoid it.
  • prop::IOStream.FILE_DESCRIPTOR_NUMBER: a file descriptor that this IOStream is using to access the filesystem.
  • prop::IOStream.ANDROID_AASSET_POINTER: a pointer, that can be cast to an Android NDK AAsset *, that this IOStream is using to access the filesystem. If SDL used some other method to access the filesystem, this property will not be set.
Parameters
filea UTF-8 string representing the filename to open.
modean ASCII string representing the mode to be used for opening the file.
Returns
a pointer to the IOStream structure that is created or nullptr on failure; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Close
IOStream.Flush
IOStream.Read
IOStream.Seek
IOStream.Tell
IOStream.Write

◆ FromMem()

IOStream SDL::IOStream::FromMem ( TargetBytes mem)
inlinestatic

Use this function to prepare a read-write memory buffer for use with IOStream.

This function sets up an IOStream struct based on a memory area of a certain size, for both read and write access.

This memory buffer is not copied by the IOStream; the pointer you provide must remain valid until you close the stream.

If you need to make sure the IOStream never writes to the memory buffer, you should use IOStream.FromConstMem() with a read-only buffer of memory instead.

The following properties will be set at creation time by SDL:

  • prop::IOStream.MEMORY_POINTER: this will be the mem parameter that was passed to this function.
  • prop::IOStream.MEMORY_SIZE_NUMBER: this will be the size parameter that was passed to this function.

Additionally, the following properties are recognized:

  • prop::IOStream.MEMORY_FREE_FUNC_POINTER: if this property is set to a non-nullptr value it will be interpreted as a function of free_func type and called with the passed mem pointer when closing the stream. By default it is unset, i.e., the memory will not be freed.
Parameters
mema buffer to feed an IOStream stream.
Returns
a valid IOStream on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.FromConstMem
IOStream.Close
IOStream.Flush
IOStream.Read
IOStream.Seek
IOStream.Tell
IOStream.Write

◆ GetIOProperties()

PropertiesRef SDL::GetIOProperties ( IOStreamRef context)
inline

Get the properties associated with an IOStream.

Parameters
contexta pointer to an IOStream structure.
Returns
a valid property ID on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ GetIOSize()

Sint64 SDL::GetIOSize ( IOStreamRef context)
inline

Use this function to get the size of the data stream in an IOStream.

Parameters
contextthe IOStream to get the size of the data stream from.
Returns
the size of the data stream in the IOStream on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ GetIOStatus()

IOStatus SDL::GetIOStatus ( IOStreamRef context)
inline

Query the stream status of an IOStream.

This information can be useful to decide if a short read or write was due to an error, an EOF, or a non-blocking operation that isn't yet ready to complete.

An IOStream's status is only expected to change after a IOStream.Read or IOStream.Write call; don't expect it to change if you just call this query function in a tight loop.

Parameters
contextthe IOStream to query.
Returns
an IOStatus enum with the current state.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ GetProperties()

PropertiesRef SDL::IOStream::GetProperties ( ) const
inline

Get the properties associated with an IOStream.

Returns
a valid property ID on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ GetSize()

Sint64 SDL::IOStream::GetSize ( ) const
inline

Use this function to get the size of the data stream in an IOStream.

Returns
the size of the data stream in the IOStream on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ GetStatus()

IOStatus SDL::IOStream::GetStatus ( ) const
inline

Query the stream status of an IOStream.

This information can be useful to decide if a short read or write was due to an error, an EOF, or a non-blocking operation that isn't yet ready to complete.

An IOStream's status is only expected to change after a IOStream.Read or IOStream.Write call; don't expect it to change if you just call this query function in a tight loop.

Returns
an IOStatus enum with the current state.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ IOFromConstMem()

IOStream SDL::IOFromConstMem ( SourceBytes mem)
inline

Use this function to prepare a read-only memory buffer for use with IOStream.

This function sets up an IOStream struct based on a memory area of a certain size. It assumes the memory area is not writable.

Attempting to write to this IOStream stream will report an error without writing to the memory buffer.

This memory buffer is not copied by the IOStream; the pointer you provide must remain valid until you close the stream.

If you need to write to a memory buffer, you should use IOStream.FromMem() with a writable buffer of memory instead.

The following properties will be set at creation time by SDL:

  • prop::IOStream.MEMORY_POINTER: this will be the mem parameter that was passed to this function.
  • prop::IOStream.MEMORY_SIZE_NUMBER: this will be the size parameter that was passed to this function.

Additionally, the following properties are recognized:

  • prop::IOStream.MEMORY_FREE_FUNC_POINTER: if this property is set to a non-nullptr value it will be interpreted as a function of free_func type and called with the passed mem pointer when closing the stream. By default it is unset, i.e., the memory will not be freed.
Parameters
mema read-only buffer to feed an IOStreamRef stream.
Returns
a valid IOStream on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.FromMem
IOStream.Close
IOStream.Read
IOStream.Seek
IOStream.Tell

◆ IOFromDynamicMem()

IOStream SDL::IOFromDynamicMem ( )
inline

Use this function to create an IOStream that is backed by dynamically allocated memory.

This supports the following properties to provide access to the memory and control over allocations:

  • prop::IOStream.DYNAMIC_MEMORY_POINTER: a pointer to the internal memory of the stream. This can be set to nullptr to transfer ownership of the memory to the application, which should free the memory with free(). If this is done, the next operation on the stream must be IOStream.Close().
  • prop::IOStream.DYNAMIC_CHUNKSIZE_NUMBER: memory will be allocated in multiples of this size, defaulting to 1024.
Returns
a pointer to a new IOStream structure or nullptr on failure; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Close
IOStream.Read
IOStream.Seek
IOStream.Tell
IOStream.Write

◆ IOFromFile()

IOStream SDL::IOFromFile ( StringParam file,
StringParam mode )
inline

Use this function to create a new IOStream structure for reading from and/or writing to a named file.

The mode string is treated roughly the same as in a call to the C library's fopen(), even if SDL doesn't happen to use fopen() behind the scenes.

Available mode strings:

  • "r": Open a file for reading. The file must exist.
  • "w": Create an empty file for writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
  • "wx": Create an empty file for writing. If a file with the same name already exists, the call fails. (Supported since SDL 3.4.0)
  • "a": Append to a file. Writing operations append data at the end of the file. The file is created if it does not exist.
  • "r+": Open a file for update both reading and writing. The file must exist.
  • "w+": Create an empty file for both reading and writing. If a file with the same name already exists its content is erased and the file is treated as a new empty file.
  • "w+x": Create an empty file for both reading and writing. If a file with the same name already exists, the call fails. (Supported since SDL 3.4.0)
  • "a+": Open a file for reading and appending. All writing operations are performed at the end of the file, protecting the previous content to be overwritten. You can reposition (fseek, rewind) the internal pointer to anywhere in the file for reading, but writing operations will move it back to the end of file. The file is created if it does not exist.

NOTE: In order to open a file as a binary file, a "b" character has to be included in the mode string. This additional "b" character can either be appended at the end of the string (thus making the following compound modes: "rb", "wb", "ab", "r+b", "w+b", "a+b") or be inserted between the letter and the "+" sign for the mixed modes ("rb+", "wb+", "ab+"). Additional characters may follow the sequence, although they should have no effect. For example, "t" is sometimes appended to make explicit the file is a text file.

This function supports Unicode filenames, but they must be encoded in UTF-8 format, regardless of the underlying operating system.

In Android, IOStream.FromFile() can be used to open content:// URIs. As a fallback, IOStream.FromFile() will transparently open a matching filename in the app's assets.

Closing the IOStream will close SDL's internal file handle.

The following properties may be set at creation time by SDL:

  • prop::IOStream.WINDOWS_HANDLE_POINTER: a pointer, that can be cast to a win32 HANDLE, that this IOStream is using to access the filesystem. If the program isn't running on Windows, or SDL used some other method to access the filesystem, this property will not be set.
  • prop::IOStream.STDIO_FILE_POINTER: a pointer, that can be cast to a stdio FILE *, that this IOStream is using to access the filesystem. If SDL used some other method to access the filesystem, this property will not be set. PLEASE NOTE that if SDL is using a different C runtime than your app, trying to use this pointer will almost certainly result in a crash! This is mostly a problem on Windows; make sure you build SDL and your app with the same compiler and settings to avoid it.
  • prop::IOStream.FILE_DESCRIPTOR_NUMBER: a file descriptor that this IOStream is using to access the filesystem.
  • prop::IOStream.ANDROID_AASSET_POINTER: a pointer, that can be cast to an Android NDK AAsset *, that this IOStream is using to access the filesystem. If SDL used some other method to access the filesystem, this property will not be set.
Parameters
filea UTF-8 string representing the filename to open.
modean ASCII string representing the mode to be used for opening the file.
Returns
a pointer to the IOStream structure that is created or nullptr on failure; call GetError() for more information.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Close
IOStream.Flush
IOStream.Read
IOStream.Seek
IOStream.Tell
IOStream.Write

◆ IOFromMem()

IOStream SDL::IOFromMem ( TargetBytes mem)
inline

Use this function to prepare a read-write memory buffer for use with IOStream.

This function sets up an IOStream struct based on a memory area of a certain size, for both read and write access.

This memory buffer is not copied by the IOStream; the pointer you provide must remain valid until you close the stream.

If you need to make sure the IOStream never writes to the memory buffer, you should use IOStream.FromConstMem() with a read-only buffer of memory instead.

The following properties will be set at creation time by SDL:

  • prop::IOStream.MEMORY_POINTER: this will be the mem parameter that was passed to this function.
  • prop::IOStream.MEMORY_SIZE_NUMBER: this will be the size parameter that was passed to this function.

Additionally, the following properties are recognized:

  • prop::IOStream.MEMORY_FREE_FUNC_POINTER: if this property is set to a non-nullptr value it will be interpreted as a function of free_func type and called with the passed mem pointer when closing the stream. By default it is unset, i.e., the memory will not be freed.
Parameters
mema buffer to feed an IOStream stream.
Returns
a valid IOStream on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.FromConstMem
IOStream.Close
IOStream.Flush
IOStream.Read
IOStream.Seek
IOStream.Tell
IOStream.Write

◆ IOprintf()

size_t SDL::IOprintf ( IOStreamRef context,
SDL_PRINTF_FORMAT_STRING const char * fmt,
... )
inline

Print to an IOStream data stream.

Warning
this is not typesafe! Prefer using print() and println()

This function does formatted printing to the stream.

Parameters
contexta pointer to an IOStream structure.
fmta printf() style format string.
...additional parameters matching % tokens in the fmt string, if any.
Returns
the number of bytes written or 0 on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.vprintf
IOStream.Write

◆ IOvprintf()

size_t SDL::IOvprintf ( IOStreamRef context,
SDL_PRINTF_FORMAT_STRING const char * fmt,
va_list ap )
inline

Print to an IOStream data stream.

This function does formatted printing to the stream.

Parameters
contexta pointer to an IOStream structure.
fmta printf() style format string.
apa variable argument list.
Returns
the number of bytes written or 0 on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.printf
IOStream.Write

◆ LoadFile() [1/2]

StringResult SDL::IOStream::LoadFile ( )
inline

Load all the data from an SDL data stream.

The data is allocated with a zero byte at the end (null terminated) for convenience.

Returns
the data in bytes
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
LoadFile
IOStream.SaveFile

◆ LoadFile() [2/2]

StringResult SDL::LoadFile ( StringParam file)
inline

Load all the data from a file path.

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 on the returned string.

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

◆ LoadFile_IO()

StringResult SDL::LoadFile_IO ( IOStreamRef src,
bool closeio = true )
inline

Load all the data from an SDL data stream.

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 on the returned string.

The data should be freed with free().

Parameters
srcthe IOStream to read all available data from.
closeioif true, calls IOStream.Close() on src before returning, even in the case of an error.
Returns
the data or nullptr on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
LoadFile
IOStream.SaveFile

◆ LoadFileAs()

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

Load all the data from a file path.

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 on the returned string.

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

◆ Open()

IOStream SDL::IOStream::Open ( const IOStreamInterface & iface,
void * userdata )
inlinestatic

Create a custom IOStream.

Applications do not need to use this function unless they are providing their own IOStream implementation. If you just need an IOStream to read/write a common data source, you should use the built-in implementations in SDL, like IOStream.FromFile() or IOStream.FromMem(), etc.

This function makes a copy of iface and the caller does not need to keep it around after this call.

Parameters
ifacethe interface that implements this IOStream, initialized using InitInterface().
userdatathe pointer that will be passed to the interface functions.
Returns
a valid stream on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Close
InitInterface
IOStream.FromConstMem
IOStream.FromFile
IOStream.FromMem

◆ OpenIO()

IOStream SDL::OpenIO ( const IOStreamInterface & iface,
void * userdata )
inline

Create a custom IOStream.

Applications do not need to use this function unless they are providing their own IOStream implementation. If you just need an IOStream to read/write a common data source, you should use the built-in implementations in SDL, like IOStream.FromFile() or IOStream.FromMem(), etc.

This function makes a copy of iface and the caller does not need to keep it around after this call.

Parameters
ifacethe interface that implements this IOStream, initialized using InitInterface().
userdatathe pointer that will be passed to the interface functions.
Returns
a pointer to the allocated memory on success.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Close
InitInterface
IOStream.FromConstMem
IOStream.FromFile
IOStream.FromMem

◆ Read()

size_t SDL::IOStream::Read ( TargetBytes buf)
inline

Read from a data source.

This function reads up size bytes from the data source to the area pointed at by ptr. This function may read less bytes than requested.

This function will return zero when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If zero is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

A request for zero bytes on a valid stream will return zero immediately without accessing the stream, so the stream status (EOF, err, etc) will not change.

Parameters
bufa pointer to a buffer to read data into.
Returns
the number of bytes read, or 0 on end of file or other failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Write
IOStream.GetStatus

◆ ReadIO()

size_t SDL::ReadIO ( IOStreamRef context,
TargetBytes buf )
inline

Read from a data source.

This function reads up size bytes from the data source to the area pointed at by ptr. This function may read less bytes than requested.

This function will return zero when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If zero is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

A request for zero bytes on a valid stream will return zero immediately without accessing the stream, so the stream status (EOF, err, etc) will not change.

Parameters
contexta pointer to an IOStream structure.
bufa pointer to a buffer to read data into.
Returns
the number of bytes read, or 0 on end of file or other failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Write
IOStream.GetStatus

◆ ReadS16BE() [1/2]

Sint16 SDL::IOStream::ReadS16BE ( )
inline

Use this function to read 16 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS16BE() [2/2]

Sint16 SDL::ReadS16BE ( IOStreamRef src)
inline

Use this function to read 16 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS16LE() [1/2]

Sint16 SDL::IOStream::ReadS16LE ( )
inline

Use this function to read 16 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS16LE() [2/2]

Sint16 SDL::ReadS16LE ( IOStreamRef src)
inline

Use this function to read 16 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS32BE() [1/2]

Sint32 SDL::IOStream::ReadS32BE ( )
inline

Use this function to read 32 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS32BE() [2/2]

Sint32 SDL::ReadS32BE ( IOStreamRef src)
inline

Use this function to read 32 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS32LE() [1/2]

Sint32 SDL::IOStream::ReadS32LE ( )
inline

Use this function to read 32 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS32LE() [2/2]

Sint32 SDL::ReadS32LE ( IOStreamRef src)
inline

Use this function to read 32 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS64BE() [1/2]

Sint64 SDL::IOStream::ReadS64BE ( )
inline

Use this function to read 64 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS64BE() [2/2]

Sint64 SDL::ReadS64BE ( IOStreamRef src)
inline

Use this function to read 64 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS64LE() [1/2]

Sint64 SDL::IOStream::ReadS64LE ( )
inline

Use this function to read 64 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS64LE() [2/2]

Sint64 SDL::ReadS64LE ( IOStreamRef src)
inline

Use this function to read 64 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS8() [1/2]

Sint8 SDL::IOStream::ReadS8 ( )
inline

Use this function to read a signed byte from an IOStream.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadS8() [2/2]

Sint8 SDL::ReadS8 ( IOStreamRef src)
inline

Use this function to read a signed byte from an IOStream.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe IOStream to read from.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU16BE() [1/2]

Uint16 SDL::IOStream::ReadU16BE ( )
inline

Use this function to read 16 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU16BE() [2/2]

Uint16 SDL::ReadU16BE ( IOStreamRef src)
inline

Use this function to read 16 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU16LE() [1/2]

Uint16 SDL::IOStream::ReadU16LE ( )
inline

Use this function to read 16 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU16LE() [2/2]

Uint16 SDL::ReadU16LE ( IOStreamRef src)
inline

Use this function to read 16 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU32BE() [1/2]

Uint32 SDL::IOStream::ReadU32BE ( )
inline

Use this function to read 32 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU32BE() [2/2]

Uint32 SDL::ReadU32BE ( IOStreamRef src)
inline

Use this function to read 32 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU32LE() [1/2]

Uint32 SDL::IOStream::ReadU32LE ( )
inline

Use this function to read 32 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU32LE() [2/2]

Uint32 SDL::ReadU32LE ( IOStreamRef src)
inline

Use this function to read 32 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU64BE() [1/2]

Uint64 SDL::IOStream::ReadU64BE ( )
inline

Use this function to read 64 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU64BE() [2/2]

Uint64 SDL::ReadU64BE ( IOStreamRef src)
inline

Use this function to read 64 bits of big-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU64LE() [1/2]

Uint64 SDL::IOStream::ReadU64LE ( )
inline

Use this function to read 64 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU64LE() [2/2]

Uint64 SDL::ReadU64LE ( IOStreamRef src)
inline

Use this function to read 64 bits of little-endian data from an IOStream and return in native format.

SDL byteswaps the data only if necessary, so the data returned will be in the native byte order.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe stream from which to read data.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU8() [1/2]

Uint8 SDL::IOStream::ReadU8 ( )
inline

Use this function to read a byte from an IOStream.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Returns
the data read on success.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ ReadU8() [2/2]

Uint8 SDL::ReadU8 ( IOStreamRef src)
inline

Use this function to read a byte from an IOStream.

This function will return false when the data stream is completely read, and IOStream.GetStatus() will return IO_STATUS_EOF. If false is returned and the stream is not at EOF, IOStream.GetStatus() will return a different error value and GetError() will offer a human-readable message.

Parameters
srcthe IOStream to read from.
Returns
the data read.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ SaveFile() [1/2]

void SDL::IOStream::SaveFile ( SourceBytes data)
inline

Save all the data into an SDL data stream.

Parameters
datathe data to be written. If datasize is 0, may be nullptr or a invalid pointer.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
SaveFile
IOStream.LoadFile

◆ SaveFile() [2/2]

void SDL::SaveFile ( StringParam file,
SourceBytes data )
inline

Save all the data into a file path.

Parameters
filethe path to write all available data into.
datathe data to be written.
Exceptions
Erroron failure.
Thread safety:
It is safe to call this function from any thread.
Since
This function is available since SDL 3.2.0.
See also
IOStream.SaveFile
LoadFile

◆ SaveFile_IO()

void SDL::SaveFile_IO ( IOStreamRef src,
SourceBytes data,
bool closeio = true )
inline

Save all the data into an SDL data stream.

Parameters
srcthe IOStream to write all data to.
datathe data to be written.
closeioif true, calls IOStream.Close() on src before returning, even in the case of an error.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
SaveFile
IOStream.LoadFile

◆ Seek()

Sint64 SDL::IOStream::Seek ( Sint64 offset,
IOWhence whence )
inline

Seek within an IOStream data stream.

This function seeks to byte offset, relative to whence.

whence may be any of the following values:

If this stream can not seek, it will return -1.

Parameters
offsetan offset in bytes, relative to whence location; can be negative.
whenceany of IO_SEEK_SET, IO_SEEK_CUR, IO_SEEK_END.
Returns
the final offset in the data stream after the seek or -1 on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Tell

◆ SeekIO()

Sint64 SDL::SeekIO ( IOStreamRef context,
Sint64 offset,
IOWhence whence )
inline

Seek within an IOStream data stream.

This function seeks to byte offset, relative to whence.

whence may be any of the following values:

If this stream can not seek, it will return -1.

Parameters
contexta pointer to an IOStream structure.
offsetan offset in bytes, relative to whence location; can be negative.
whenceany of IO_SEEK_SET, IO_SEEK_CUR, IO_SEEK_END.
Returns
the final offset in the data stream after the seek or -1 on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Tell

◆ Tell()

Sint64 SDL::IOStream::Tell ( ) const
inline

Determine the current read/write offset in an IOStream data stream.

IOStream.Tell is actually a wrapper function that calls the IOStream's seek method, with an offset of 0 bytes from IO_SEEK_CUR, to simplify application development.

Returns
the current offset in the stream, or -1 if the information can not be determined.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Seek

◆ TellIO()

Sint64 SDL::TellIO ( IOStreamRef context)
inline

Determine the current read/write offset in an IOStream data stream.

IOStream.Tell is actually a wrapper function that calls the IOStream's seek method, with an offset of 0 bytes from IO_SEEK_CUR, to simplify application development.

Parameters
contextan IOStream data stream object from which to get the current offset.
Returns
the current offset in the stream, or -1 if the information can not be determined.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.Seek

◆ vprintf()

size_t SDL::IOStream::vprintf ( SDL_PRINTF_FORMAT_STRING const char * fmt,
va_list ap )
inline

Print to an IOStream data stream.

Warning
this is not typesafe! Prefer using print() and println()

This function does formatted printing to the stream.

Parameters
fmta printf() style format string.
apa variable argument list.
Returns
the number of bytes written or 0 on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.printf
IOStream.Write

◆ Write()

size_t SDL::IOStream::Write ( SourceBytes buf)
inline

Write to an IOStream data stream.

This function writes exactly size bytes from the area pointed at by ptr to the stream. If this fails for any reason, it'll return less than size to demonstrate how far the write progressed. On success, it returns size.

On error, this function still attempts to write as much as possible, so it might return a positive value less than the requested write size.

The caller can use IOStream.GetStatus() to determine if the problem is recoverable, such as a non-blocking write that can simply be retried later, or a fatal error.

A request for zero bytes on a valid stream will return zero immediately without accessing the stream, so the stream status (EOF, err, etc) will not change.

Parameters
bufthe bytes to write to
Returns
the number of bytes written, which will be less than size on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.printf
IOStream.Read
IOStream.Seek
IOStream.Flush
IOStream.GetStatus

◆ WriteIO()

size_t SDL::WriteIO ( IOStreamRef context,
SourceBytes buf )
inline

Write to an IOStream data stream.

This function writes exactly size bytes from the area pointed at by ptr to the stream. If this fails for any reason, it'll return less than size to demonstrate how far the write progressed. On success, it returns size.

On error, this function still attempts to write as much as possible, so it might return a positive value less than the requested write size.

The caller can use IOStream.GetStatus() to determine if the problem is recoverable, such as a non-blocking write that can simply be retried later, or a fatal error.

A request for zero bytes on a valid stream will return zero immediately without accessing the stream, so the stream status (EOF, err, etc) will not change.

Parameters
contexta pointer to an IOStream structure.
bufa pointer to a buffer containing data to write.
Returns
the number of bytes written, which will be less than size on failure; call GetError() for more information.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.
See also
IOStream.printf
IOStream.Read
IOStream.Seek
IOStream.Flush
IOStream.GetStatus

◆ WriteS16BE() [1/2]

void SDL::IOStream::WriteS16BE ( Sint16 value)
inline

Use this function to write 16 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS16BE() [2/2]

void SDL::WriteS16BE ( IOStreamRef dst,
Sint16 value )
inline

Use this function to write 16 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS16LE() [1/2]

void SDL::IOStream::WriteS16LE ( Sint16 value)
inline

Use this function to write 16 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS16LE() [2/2]

void SDL::WriteS16LE ( IOStreamRef dst,
Sint16 value )
inline

Use this function to write 16 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS32BE() [1/2]

void SDL::IOStream::WriteS32BE ( Sint32 value)
inline

Use this function to write 32 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS32BE() [2/2]

void SDL::WriteS32BE ( IOStreamRef dst,
Sint32 value )
inline

Use this function to write 32 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS32LE() [1/2]

void SDL::IOStream::WriteS32LE ( Sint32 value)
inline

Use this function to write 32 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS32LE() [2/2]

void SDL::WriteS32LE ( IOStreamRef dst,
Sint32 value )
inline

Use this function to write 32 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS64BE() [1/2]

void SDL::IOStream::WriteS64BE ( Sint64 value)
inline

Use this function to write 64 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS64BE() [2/2]

void SDL::WriteS64BE ( IOStreamRef dst,
Sint64 value )
inline

Use this function to write 64 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS64LE() [1/2]

void SDL::IOStream::WriteS64LE ( Sint64 value)
inline

Use this function to write 64 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS64LE() [2/2]

void SDL::WriteS64LE ( IOStreamRef dst,
Sint64 value )
inline

Use this function to write 64 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS8() [1/2]

void SDL::IOStream::WriteS8 ( Sint8 value)
inline

Use this function to write a signed byte to an IOStream.

Parameters
valuethe byte value to write.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteS8() [2/2]

void SDL::WriteS8 ( IOStreamRef dst,
Sint8 value )
inline

Use this function to write a signed byte to an IOStream.

Parameters
dstthe IOStream to write to.
valuethe byte value to write.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU16BE() [1/2]

void SDL::IOStream::WriteU16BE ( Uint16 value)
inline

Use this function to write 16 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU16BE() [2/2]

void SDL::WriteU16BE ( IOStreamRef dst,
Uint16 value )
inline

Use this function to write 16 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU16LE() [1/2]

void SDL::IOStream::WriteU16LE ( Uint16 value)
inline

Use this function to write 16 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU16LE() [2/2]

void SDL::WriteU16LE ( IOStreamRef dst,
Uint16 value )
inline

Use this function to write 16 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU32BE() [1/2]

void SDL::IOStream::WriteU32BE ( Uint32 value)
inline

Use this function to write 32 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU32BE() [2/2]

void SDL::WriteU32BE ( IOStreamRef dst,
Uint32 value )
inline

Use this function to write 32 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU32LE() [1/2]

void SDL::IOStream::WriteU32LE ( Uint32 value)
inline

Use this function to write 32 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU32LE() [2/2]

void SDL::WriteU32LE ( IOStreamRef dst,
Uint32 value )
inline

Use this function to write 32 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU64BE() [1/2]

void SDL::IOStream::WriteU64BE ( Uint64 value)
inline

Use this function to write 64 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU64BE() [2/2]

void SDL::WriteU64BE ( IOStreamRef dst,
Uint64 value )
inline

Use this function to write 64 bits in native format to an IOStream as big-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in big-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU64LE() [1/2]

void SDL::IOStream::WriteU64LE ( Uint64 value)
inline

Use this function to write 64 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU64LE() [2/2]

void SDL::WriteU64LE ( IOStreamRef dst,
Uint64 value )
inline

Use this function to write 64 bits in native format to an IOStream as little-endian data.

SDL byteswaps the data only if necessary, so the application always specifies native format, and the data written will be in little-endian format.

Parameters
dstthe stream to which data will be written.
valuethe data to be written, in native format.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU8() [1/2]

void SDL::IOStream::WriteU8 ( Uint8 value)
inline

Use this function to write a byte to an IOStream.

Parameters
valuethe byte value to write.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

◆ WriteU8() [2/2]

void SDL::WriteU8 ( IOStreamRef dst,
Uint8 value )
inline

Use this function to write a byte to an IOStream.

Parameters
dstthe IOStream to write to.
valuethe byte value to write.
Exceptions
Erroron failure.
Thread safety:
Do not use the same IOStream from two threads at once.
Since
This function is available since SDL 3.2.0.

Variable Documentation

◆ IO_SEEK_CUR

IOWhence SDL::IO_SEEK_CUR
constexpr
Initial value:
=
SDL_IO_SEEK_CUR

Seek relative to current read point.

◆ IO_SEEK_END

IOWhence SDL::IO_SEEK_END
constexpr
Initial value:
=
SDL_IO_SEEK_END

Seek relative to the end of data.

◆ IO_SEEK_SET

IOWhence SDL::IO_SEEK_SET
constexpr
Initial value:
=
SDL_IO_SEEK_SET

Seek from the beginning of data.

◆ IO_STATUS_ERROR

IOStatus SDL::IO_STATUS_ERROR
constexpr
Initial value:
=
SDL_IO_STATUS_ERROR

Read or write I/O error.

◆ IO_STATUS_NOT_READY

IOStatus SDL::IO_STATUS_NOT_READY
constexpr
Initial value:
=
SDL_IO_STATUS_NOT_READY

Non blocking I/O, not ready.

◆ IO_STATUS_READONLY

IOStatus SDL::IO_STATUS_READONLY
constexpr
Initial value:
=
SDL_IO_STATUS_READONLY

Tried to write a read-only buffer.

◆ IO_STATUS_READY

IOStatus SDL::IO_STATUS_READY
constexpr
Initial value:
=
SDL_IO_STATUS_READY

Everything is ready (no errors and not EOF).

◆ IO_STATUS_WRITEONLY

IOStatus SDL::IO_STATUS_WRITEONLY
constexpr
Initial value:
=
SDL_IO_STATUS_WRITEONLY

Tried to read a write-only buffer.