1#ifndef SDL3PP_IOSTREAM_H_
2#define SDL3PP_IOSTREAM_H_
4#include <SDL3/SDL_iostream.h>
5#include "SDL3pp_properties.h"
6#include "SDL3pp_stdinc.h"
48 SDL_IO_STATUS_NOT_READY;
51 SDL_IO_STATUS_READONLY;
54 SDL_IO_STATUS_WRITEONLY;
109 constexpr IOStream(std::nullptr_t =
nullptr) noexcept
122 : m_resource(resource)
386 std::swap(m_resource, other.m_resource);
402 m_resource =
nullptr;
410 constexpr explicit operator bool() const noexcept {
return !!m_resource; }
553 std::string
Read(
size_t size = -1)
556 auto curSize = SDL_GetIOSize(
get());
557 if ((curSize < 0 || pos < 0)) {
558 if (size ==
size_t(-1))
return {};
559 }
else if (curSize - pos <= 0) {
561 }
else if (curSize - pos < size) {
562 size = curSize - pos;
564 std::string result(size, 0);
565 auto actualSize =
Read(result);
566 if (actualSize < size) result.resize(actualSize);
639 size_t print(std::string_view fmt,
auto... args)
641 return Write(std::vformat(fmt, std::make_format_args(args...)));
651 size_t println(std::string_view fmt,
auto... args)
654 std::vformat(fmt, std::make_format_args(args...)) +
"\n";
655 return Write(result);
678 size_t printf(SDL_PRINTF_FORMAT_STRING
const char* fmt, ...)
709 size_t vprintf(SDL_PRINTF_FORMAT_STRING
const char* fmt, va_list ap);
768 auto data =
static_cast<T*
>(SDL_LoadFile_IO(
get(), &datasize,
false));
1090 if (
Uint8 value; SDL_ReadU8(
get(), &value))
return value;
1110 if (
Sint8 value; SDL_ReadS8(
get(), &value))
return value;
1134 if (
Uint16 value; SDL_ReadU16LE(
get(), &value))
return value;
1158 if (
Sint16 value; SDL_ReadS16LE(
get(), &value))
return value;
1182 if (
Uint16 value; SDL_ReadU16BE(
get(), &value))
return value;
1206 if (
Sint16 value; SDL_ReadS16BE(
get(), &value))
return value;
1230 if (
Uint32 value; SDL_ReadU32LE(
get(), &value))
return value;
1254 if (
Sint32 value; SDL_ReadS32LE(
get(), &value))
return value;
1278 if (
Uint32 value; SDL_ReadU32BE(
get(), &value))
return value;
1302 if (
Sint32 value; SDL_ReadS32BE(
get(), &value))
return value;
1326 if (
Uint64 value; SDL_ReadU64LE(
get(), &value))
return value;
1350 if (
Sint64 value; SDL_ReadS64LE(
get(), &value))
return value;
1374 if (
Uint64 value; SDL_ReadU64BE(
get(), &value))
return value;
1398 if (
Sint64 value; SDL_ReadS64BE(
get(), &value))
return value;
1676 std::swap(*
this, other);
1768 return IOStream(SDL_IOFromFile(file, mode));
1776namespace prop::IOStream {
1778constexpr auto WINDOWS_HANDLE_POINTER =
1779 SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER;
1781constexpr auto STDIO_FILE_POINTER = SDL_PROP_IOSTREAM_STDIO_FILE_POINTER;
1783constexpr auto FILE_DESCRIPTOR_NUMBER =
1784 SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER;
1786constexpr auto ANDROID_AASSET_POINTER =
1787 SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER;
1789constexpr auto MEMORY_POINTER = SDL_PROP_IOSTREAM_MEMORY_POINTER;
1791constexpr auto MEMORY_SIZE_NUMBER = SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER;
1793#if SDL_VERSION_ATLEAST(3, 4, 0)
1795constexpr auto MEMORY_FREE_FUNC_POINTER =
1796 SDL_PROP_IOSTREAM_MEMORY_FREE_FUNC_POINTER;
1800constexpr auto DYNAMIC_MEMORY_POINTER =
1801 SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER;
1803constexpr auto DYNAMIC_CHUNKSIZE_NUMBER =
1804 SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER;
2028 return {
CheckError(SDL_GetIOProperties(context))};
2056 return SDL_GetIOStatus(context);
2110 return SDL_SeekIO(context, offset, whence);
2242 SDL_PRINTF_FORMAT_STRING
const char* fmt,
2249 result = SDL_IOvprintf(context, fmt, ap);
2274 SDL_PRINTF_FORMAT_STRING
const char* fmt,
2277 return SDL_IOvprintf(context, fmt, ap);
2331 size_t datasize = 0;
2332 auto data =
static_cast<char*
>(SDL_LoadFile_IO(src, &datasize, closeio));
2356 size_t datasize = 0;
2357 auto data =
static_cast<char*
>(SDL_LoadFile(file, &datasize));
2387 size_t datasize = 0;
2388 auto data =
static_cast<T*
>(SDL_LoadFile(file, &datasize));
The read/write operation structure.
Definition: SDL3pp_iostream.h:104
Sint8 ReadS8()
Use this function to read a signed byte from an IOStream.
std::optional< Sint8 > TryReadS8()
Use this function to read a byte from an IOStreamRef.
Definition: SDL3pp_iostream.h:1108
std::optional< Sint16 > TryReadS16LE()
Use this function to read 16 bits of little-endian data from an IOStreamRef and return in native form...
Definition: SDL3pp_iostream.h:1156
constexpr IOStream(const IOStream &other) noexcept=default
Copy constructor.
std::optional< Uint64 > TryReadU64BE()
Use this function to read 64 bits of big-endian data from an IOStreamRef and return in native format.
Definition: SDL3pp_iostream.h:1372
constexpr IOStreamRaw release() noexcept
Retrieves underlying IOStreamRaw and clear this.
Definition: SDL3pp_iostream.h:399
std::optional< Uint16 > TryReadU16BE()
Use this function to read 16 bits of big-endian data from an IOStreamRef and return in native format.
Definition: SDL3pp_iostream.h:1180
constexpr IOStream(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_iostream.h:109
~IOStream()
Destructor.
Definition: SDL3pp_iostream.h:381
std::optional< Sint32 > TryReadS32LE()
Use this function to read 32 bits of little-endian data from an IOStreamRef and return in native form...
Definition: SDL3pp_iostream.h:1252
std::optional< Uint16 > TryReadU16LE()
Use this function to read 16 bits of little-endian data from an IOStreamRef and return in native form...
Definition: SDL3pp_iostream.h:1132
constexpr IOStreamRaw get() const noexcept
Retrieves underlying IOStreamRaw.
Definition: SDL3pp_iostream.h:396
OwnArray< T > LoadFileAs()
Load all the data from an SDL data stream.
Definition: SDL3pp_iostream.h:765
std::optional< Sint16 > TryReadS16BE()
Use this function to read 16 bits of big-endian data from an IOStreamRef and return in native format.
Definition: SDL3pp_iostream.h:1204
size_t printf(SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Print to an IOStream data stream.
Definition: SDL3pp_iostream.h:678
constexpr IOStream & operator=(const IOStream &other) noexcept=default
Assignment operator.
Uint8 ReadU8()
Use this function to read a byte from an IOStream.
std::optional< Uint64 > TryReadU64LE()
Use this function to read 64 bits of little-endian data from an IOStreamRef and return in native form...
Definition: SDL3pp_iostream.h:1324
constexpr IOStream(IOStream &&other) noexcept
Move constructor.
Definition: SDL3pp_iostream.h:132
size_t print(std::string_view fmt, auto... args)
Prints formatted string.
Definition: SDL3pp_iostream.h:639
std::optional< Uint32 > TryReadU32LE()
Use this function to read 32 bits of little-endian data from an IOStreamRef and return in native form...
Definition: SDL3pp_iostream.h:1228
std::optional< Uint8 > TryReadU8()
Use this function to read a byte from an IOStreamRef.
Definition: SDL3pp_iostream.h:1088
constexpr IOStream & operator=(IOStream &&other) noexcept
Assignment operator.
Definition: SDL3pp_iostream.h:384
std::optional< Uint32 > TryReadU32BE()
Use this function to read 32 bits of big-endian data from an IOStreamRef and return in native format.
Definition: SDL3pp_iostream.h:1276
std::optional< Sint32 > TryReadS32BE()
Use this function to read 32 bits of big-endian data from an IOStreamRef and return in native format.
Definition: SDL3pp_iostream.h:1300
std::optional< Sint64 > TryReadS64BE()
Use this function to read 64 bits of big-endian data from an IOStreamRef and return in native format.
Definition: SDL3pp_iostream.h:1396
constexpr IOStream(const IOStreamRaw resource) noexcept
Constructs from IOStreamRef.
Definition: SDL3pp_iostream.h:121
size_t println(std::string_view fmt, auto... args)
Prints formatted string.
Definition: SDL3pp_iostream.h:651
constexpr auto operator<=>(const IOStream &other) const noexcept=default
Comparison.
std::optional< Sint64 > TryReadS64LE()
Use this function to read 64 bits of little-endian data from an IOStreamRef and return in native form...
Definition: SDL3pp_iostream.h:1348
std::string Read(size_t size=-1)
Read from a data source.
Definition: SDL3pp_iostream.h:553
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
Source byte stream.
Definition: SDL3pp_strings.h:240
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition: SDL3pp_strings.h:304
constexpr const char * data() const
Retrieves contained data.
Definition: SDL3pp_strings.h:307
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
Target byte stream.
Definition: SDL3pp_strings.h:326
constexpr char * data() const
Retrieves contained data.
Definition: SDL3pp_strings.h:412
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition: SDL3pp_strings.h:409
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:197
void WriteS16BE(IOStreamRef dst, Sint16 value)
Use this function to write 16 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:2957
Sint64 GetSize() const
Use this function to get the size of the data stream in an IOStream.
Definition: SDL3pp_iostream.h:2080
IOStream IOFromMem(TargetBytes mem)
Use this function to prepare a read-write memory buffer for use with IOStream.
Definition: SDL3pp_iostream.h:1851
size_t ReadIO(IOStreamRef context, TargetBytes buf)
Read from a data source.
Definition: SDL3pp_iostream.h:2167
void FlushIO(IOStreamRef context)
Flush any buffered data in the stream.
Definition: SDL3pp_iostream.h:2303
void WriteS64BE(IOStreamRef dst, Sint64 value)
Use this function to write 64 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3157
void WriteU32LE(Uint32 value)
Use this function to write 32 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:2987
void WriteS32BE(Sint32 value)
Use this function to write 32 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3062
void WriteS32LE(Sint32 value)
Use this function to write 32 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:3012
void WriteU64LE(IOStreamRef dst, Uint64 value)
Use this function to write 64 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:3082
void WriteU64BE(Uint64 value)
Use this function to write 64 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3137
void WriteU64BE(IOStreamRef dst, Uint64 value)
Use this function to write 64 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3132
IOStream OpenIO(const IOStreamInterface &iface, void *userdata)
Create a custom IOStream.
Definition: SDL3pp_iostream.h:1972
PropertiesRef GetIOProperties(IOStreamRef context)
Get the properties associated with an IOStream.
Definition: SDL3pp_iostream.h:2026
Uint16 ReadU16BE()
Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2568
SDL_IOStream * IOStreamRaw
Alias to raw representation for IOStream.
Definition: SDL3pp_iostream.h:27
void WriteU32BE(IOStreamRef dst, Uint32 value)
Use this function to write 32 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3032
void SaveFile(SourceBytes data)
Save all the data into an SDL data stream.
Definition: SDL3pp_iostream.h:2432
size_t WriteIO(IOStreamRef context, SourceBytes buf)
Write to an IOStream data stream.
Definition: SDL3pp_iostream.h:2210
void WriteU8(IOStreamRef dst, Uint8 value)
Use this function to write a byte to an IOStream.
Definition: SDL3pp_iostream.h:2842
void WriteU32BE(Uint32 value)
Use this function to write 32 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3037
Sint64 TellIO(IOStreamRef context)
Determine the current read/write offset in an IOStream data stream.
Definition: SDL3pp_iostream.h:2136
Sint32 ReadS32BE()
Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2713
Sint64 ReadS64BE(IOStreamRef src)
Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2822
void WriteS16LE(Sint16 value)
Use this function to write 16 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:2912
void WriteS8(Sint8 value)
Use this function to write a signed byte to an IOStream.
Definition: SDL3pp_iostream.h:2865
void WriteS32LE(IOStreamRef dst, Sint32 value)
Use this function to write 32 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:3007
size_t IOprintf(IOStreamRef context, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Print to an IOStream data stream.
Definition: SDL3pp_iostream.h:2241
Uint32 ReadU32BE(IOStreamRef src)
Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2677
void Flush()
Flush any buffered data in the stream.
Definition: SDL3pp_iostream.h:2305
IOStream IOFromConstMem(SourceBytes mem)
Use this function to prepare a read-only memory buffer for use with IOStream.
Definition: SDL3pp_iostream.h:1904
SDL_IOWhence IOWhence
Possible whence values for IOStream seeking.
Definition: SDL3pp_iostream.h:64
Sint32 ReadS32LE(IOStreamRef src)
Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2648
Sint32 ReadS32BE(IOStreamRef src)
Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2706
size_t vprintf(SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
Print to an IOStream data stream.
Definition: SDL3pp_iostream.h:2280
Uint16 ReadU16LE()
Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2510
void WriteS32BE(IOStreamRef dst, Sint32 value)
Use this function to write 32 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3057
void SaveFile(IOStreamRef src, SourceBytes data, bool closeio=false)
Save all the data into an SDL data stream.
Definition: SDL3pp_iostream.h:2408
Uint32 ReadU32LE()
Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2626
IOStream IOFromDynamicMem()
Use this function to create an IOStream that is backed by dynamically allocated memory.
Definition: SDL3pp_iostream.h:1941
void Close()
Close and free an allocated IOStream structure.
Definition: SDL3pp_iostream.h:2013
OwnArray< T > LoadFileAs(StringParam file)
Load all the data from a file path.
Definition: SDL3pp_iostream.h:2385
void WriteS64BE(Sint64 value)
Use this function to write 64 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:3162
Uint8 ReadU8(IOStreamRef src)
Use this function to read a byte from an IOStream.
Definition: SDL3pp_iostream.h:2453
constexpr IOStatus IO_STATUS_ERROR
Read or write I/O error.
Definition: SDL3pp_iostream.h:42
Uint16 ReadU16LE(IOStreamRef src)
Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2503
void WriteS16BE(Sint16 value)
Use this function to write 16 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:2962
static IOStream Open(const IOStreamInterface &iface, void *userdata)
Create a custom IOStream.
Definition: SDL3pp_iostream.h:1977
StringResult LoadFile(IOStreamRef src, bool closeio=true)
Load all the data from an SDL data stream.
Definition: SDL3pp_iostream.h:2329
void WriteS64LE(IOStreamRef dst, Sint64 value)
Use this function to write 64 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:3107
Uint32 ReadU32BE()
Use this function to read 32 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2684
IOStream IOFromFile(StringParam file, StringParam mode)
Use this function to create a new IOStream structure for reading from and/or writing to a named file.
Definition: SDL3pp_iostream.h:1766
constexpr IOStatus IO_STATUS_EOF
End of file.
Definition: SDL3pp_iostream.h:45
void WriteS16LE(IOStreamRef dst, Sint16 value)
Use this function to write 16 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:2907
IOStatus GetIOStatus(IOStreamRef context)
Query the stream status of an IOStream.
Definition: SDL3pp_iostream.h:2054
Sint64 GetIOSize(IOStreamRef context)
Use this function to get the size of the data stream in an IOStream.
Definition: SDL3pp_iostream.h:2075
Sint64 Seek(Sint64 offset, IOWhence whence)
Seek within an IOStream data stream.
Definition: SDL3pp_iostream.h:2113
Uint32 ReadU32LE(IOStreamRef src)
Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2619
size_t Write(SourceBytes buf)
Write to an IOStream data stream.
Definition: SDL3pp_iostream.h:2215
void WriteS8(IOStreamRef dst, Sint8 value)
Use this function to write a signed byte to an IOStream.
Definition: SDL3pp_iostream.h:2860
Sint64 Tell() const
Determine the current read/write offset in an IOStream data stream.
Definition: SDL3pp_iostream.h:2138
Sint64 ReadS64LE(IOStreamRef src)
Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2764
size_t IOvprintf(IOStreamRef context, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
Print to an IOStream data stream.
Definition: SDL3pp_iostream.h:2273
void WriteU16BE(Uint16 value)
Use this function to write 16 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:2937
Sint32 ReadS32LE()
Use this function to read 32 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2655
Sint16 ReadS16BE()
Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2597
constexpr IOStatus IO_STATUS_WRITEONLY
Tried to read a write-only buffer.
Definition: SDL3pp_iostream.h:53
Uint16 ReadU16BE(IOStreamRef src)
Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2561
Sint8 ReadS8(IOStreamRef src)
Use this function to read a signed byte from an IOStream.
Definition: SDL3pp_iostream.h:2476
Sint16 ReadS16BE(IOStreamRef src)
Use this function to read 16 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2590
void WriteU16LE(IOStreamRef dst, Uint16 value)
Use this function to write 16 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:2882
Sint64 SeekIO(IOStreamRef context, Sint64 offset, IOWhence whence)
Seek within an IOStream data stream.
Definition: SDL3pp_iostream.h:2108
Sint64 ReadS64BE()
Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2829
static IOStream FromDynamicMem()
Use this function to create an IOStream that is backed by dynamically allocated memory.
Definition: SDL3pp_iostream.h:1943
void WriteU32LE(IOStreamRef dst, Uint32 value)
Use this function to write 32 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:2982
static IOStream FromConstMem(SourceBytes mem)
Use this function to prepare a read-only memory buffer for use with IOStream.
Definition: SDL3pp_iostream.h:1909
StringResult LoadFile()
Load all the data from an SDL data stream.
Definition: SDL3pp_iostream.h:2361
void WriteU16LE(Uint16 value)
Use this function to write 16 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:2887
Uint64 ReadU64BE(IOStreamRef src)
Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2793
Uint64 ReadU64LE()
Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2742
Sint16 ReadS16LE(IOStreamRef src)
Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2532
constexpr IOWhence IO_SEEK_CUR
Seek relative to current read point.
Definition: SDL3pp_iostream.h:69
SDL_IOStreamInterface IOStreamInterface
The function pointers that drive an IOStream.
Definition: SDL3pp_iostream.h:89
void WriteU8(Uint8 value)
Use this function to write a byte to an IOStream.
Definition: SDL3pp_iostream.h:2847
Uint64 ReadU64BE()
Use this function to read 64 bits of big-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2800
SDL_IOStatus IOStatus
IOStream status, set by a read or write operation.
Definition: SDL3pp_iostream.h:37
Sint64 ReadS64LE()
Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2771
Uint64 ReadU64LE(IOStreamRef src)
Use this function to read 64 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2735
void WriteU16BE(IOStreamRef dst, Uint16 value)
Use this function to write 16 bits in native format to an IOStream as big-endian data.
Definition: SDL3pp_iostream.h:2932
constexpr IOStatus IO_STATUS_READONLY
Tried to write a read-only buffer.
Definition: SDL3pp_iostream.h:50
void WriteU64LE(Uint64 value)
Use this function to write 64 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:3087
constexpr IOStatus IO_STATUS_READY
Everything is ready (no errors and not EOF).
Definition: SDL3pp_iostream.h:39
constexpr IOStatus IO_STATUS_NOT_READY
Non blocking I/O, not ready.
Definition: SDL3pp_iostream.h:47
static 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.
Definition: SDL3pp_iostream.h:1771
void CloseIO(IOStreamRaw context)
Close and free an allocated IOStream structure.
Definition: SDL3pp_iostream.h:2011
void WriteS64LE(Sint64 value)
Use this function to write 64 bits in native format to an IOStream as little-endian data.
Definition: SDL3pp_iostream.h:3112
Sint16 ReadS16LE()
Use this function to read 16 bits of little-endian data from an IOStream and return in native format.
Definition: SDL3pp_iostream.h:2539
IOStatus GetStatus() const
Query the stream status of an IOStream.
Definition: SDL3pp_iostream.h:2059
static IOStream FromMem(TargetBytes mem)
Use this function to prepare a read-write memory buffer for use with IOStream.
Definition: SDL3pp_iostream.h:1856
constexpr IOWhence IO_SEEK_SET
Seek from the beginning of data.
Definition: SDL3pp_iostream.h:66
constexpr IOWhence IO_SEEK_END
Seek relative to the end of data.
Definition: SDL3pp_iostream.h:72
PropertiesRef GetProperties() const
Get the properties associated with an IOStream.
Definition: SDL3pp_iostream.h:2031
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:280
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition: SDL3pp_stdinc.h:310
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:228
::Sint8 Sint8
A signed 8-bit integer type.
Definition: SDL3pp_stdinc.h:215
::Sint64 Sint64
A signed 64-bit integer type.
Definition: SDL3pp_stdinc.h:295
::Sint32 Sint32
A signed 32-bit integer type.
Definition: SDL3pp_stdinc.h:267
::Sint16 Sint16
A signed 16-bit integer type.
Definition: SDL3pp_stdinc.h:241
::Uint16 Uint16
An unsigned 16-bit integer type.
Definition: SDL3pp_stdinc.h:254
Main include header for the SDL3pp library.
Reference for IOStream.
Definition: SDL3pp_iostream.h:1631
constexpr IOStreamRef(const IOStreamRef &other) noexcept
Copy constructor.
Definition: SDL3pp_iostream.h:1659
IOStreamRef(IOStreamRaw resource) noexcept
Constructs from raw IOStream.
Definition: SDL3pp_iostream.h:1641
constexpr IOStreamRef(IOStreamRef &&other) noexcept
Move constructor.
Definition: SDL3pp_iostream.h:1665
~IOStreamRef()
Destructor.
Definition: SDL3pp_iostream.h:1671
constexpr IOStreamRef(const IOStream &resource) noexcept
Constructs from IOStream.
Definition: SDL3pp_iostream.h:1653
constexpr IOStreamRef & operator=(IOStreamRef other) noexcept
Assignment operator.
Definition: SDL3pp_iostream.h:1674
Reference for Properties.
Definition: SDL3pp_properties.h:690
A simple std::string-like interface for SDL allocated strings.
Definition: SDL3pp_strings.h:153