SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_iostream.h
1#ifndef SDL3PP_IOSTREAM_H_
2#define SDL3PP_IOSTREAM_H_
3
4#include <SDL3/SDL_iostream.h>
5#include "SDL3pp_properties.h"
6#include "SDL3pp_stdinc.h"
7
8namespace SDL {
9
23// Forward decl
24struct IOStreamBase;
25
26// Forward decl
27struct IOStreamRef;
28
29// Forward decl
30struct IOStream;
31
37using IOStatus = SDL_IOStatus;
38
40 SDL_IO_STATUS_READY;
41
43 SDL_IO_STATUS_ERROR;
44
45constexpr IOStatus IO_STATUS_EOF = SDL_IO_STATUS_EOF;
46
48 SDL_IO_STATUS_NOT_READY;
49
51 SDL_IO_STATUS_READONLY;
52
54 SDL_IO_STATUS_WRITEONLY;
55
64using IOWhence = SDL_IOWhence;
65
67 SDL_IO_SEEK_SET;
68
70 SDL_IO_SEEK_CUR;
71
73 SDL_IO_SEEK_END;
74
89using IOStreamInterface = SDL_IOStreamInterface;
90
106struct IOStreamBase : Resource<SDL_IOStream*>
107{
108 using Resource::Resource;
109
193 : Resource(SDL_IOFromFile(file, mode))
194 {
195 }
196
225 IOStreamBase(const IOStreamInterface& iface, void* userdata)
226 : Resource(CheckError(SDL_OpenIO(&iface, userdata)))
227 {
228 }
229
241 {
242 return CheckError(SDL_GetIOProperties(get()));
243 }
244
262 IOStatus GetStatus() const { return SDL_GetIOStatus(get()); }
263
274 Sint64 GetSize() const
275 {
276 auto size = SDL_GetIOSize(get());
277 if (size < 0) throw Error{};
278 return size;
279 }
280
307 Sint64 Seek(Sint64 offset, IOWhence whence)
308 {
309 return SDL_SeekIO(get(), offset, whence);
310 }
311
328 Sint64 Tell() const { return SDL_TellIO(get()); }
329
352 std::string Read(size_t size = -1)
353 {
354 Sint64 pos = Tell();
355 auto curSize = SDL_GetIOSize(get());
356 if ((curSize < 0 || pos < 0)) {
357 if (size == size_t(-1)) return {};
358 } else if (curSize - pos <= 0) {
359 return {};
360 } else if (curSize - pos < size) {
361 size = curSize - pos;
362 }
363 std::string result(size, 0);
364 auto actualSize = Read(result);
365 if (actualSize < size) result.resize(actualSize);
366 return result;
367 }
368
391 size_t Read(TargetBytes buf)
392 {
393 return SDL_ReadIO(get(), buf.data, buf.size_bytes);
394 }
395
424 size_t Write(SourceBytes buf)
425 {
426 return SDL_WriteIO(get(), buf.data, buf.size_bytes);
427 }
428
432 size_t print(std::string_view fmt, auto... args)
433 {
434 return Write(std::vformat(fmt, std::make_format_args(args...)));
435 }
436
440 size_t println(std::string_view fmt, auto... args)
441 {
442 std::string result =
443 std::vformat(fmt, std::make_format_args(args...)) + "\n";
444 return Write(result);
445 }
446
467 size_t printf(SDL_PRINTF_FORMAT_STRING const char* fmt, ...)
468 {
469 va_list ap;
470 size_t result;
471
472 va_start(ap, fmt);
473 result = vprintf(fmt, ap);
474 va_end(ap);
475
476 return result;
477 }
478
498 size_t vprintf(SDL_PRINTF_FORMAT_STRING const char* fmt, va_list ap)
499 {
500 return SDL_IOvprintf(get(), fmt, ap);
501 }
502
519 void Flush() { CheckError(SDL_FlushIO(get())); }
520
539 {
540 size_t datasize = 0;
541 auto data = static_cast<char*>(SDL_LoadFile_IO(get(), &datasize, false));
542 return StringResult{CheckError(data), datasize};
543 }
544
562 template<class T>
564 {
565 size_t datasize = 0;
566 auto data = static_cast<T*>(SDL_LoadFile_IO(get(), &datasize, false));
567 return OwnArray<T>{CheckError(data), datasize / sizeof(T)};
568 }
569
585 {
586 CheckError(SDL_SaveFile_IO(get(), data.data, data.size_bytes, false));
587 }
588
604 Uint8 ReadU8()
605 {
606 Uint8 value;
607 CheckError(SDL_ReadU8(get(), &value));
608 return value;
609 }
610
626 Sint8 ReadS8()
627 {
628 Sint8 value;
629 CheckError(SDL_ReadS8(get(), &value));
630 return value;
631 }
632
652 Uint16 ReadU16LE()
653 {
654 Uint16 value;
655 CheckError(SDL_ReadU16LE(get(), &value));
656 return value;
657 }
658
678 Sint16 ReadS16LE()
679 {
680 Sint16 value;
681 CheckError(SDL_ReadS16LE(get(), &value));
682 return value;
683 }
684
704 Uint16 ReadU16BE()
705 {
706 Uint16 value;
707 CheckError(SDL_ReadU16BE(get(), &value));
708 return value;
709 }
710
730 Sint16 ReadS16BE()
731 {
732 Sint16 value;
733 CheckError(SDL_ReadS16BE(get(), &value));
734 return value;
735 }
736
756 Uint32 ReadU32LE()
757 {
758 Uint32 value;
759 CheckError(SDL_ReadU32LE(get(), &value));
760 return value;
761 }
762
782 Sint32 ReadS32LE()
783 {
784 Sint32 value;
785 CheckError(SDL_ReadS32LE(get(), &value));
786 return value;
787 }
788
808 Uint32 ReadU32BE()
809 {
810 Uint32 value;
811 CheckError(SDL_ReadU32BE(get(), &value));
812 return value;
813 }
814
834 Sint32 ReadS32BE()
835 {
836 Sint32 value;
837 CheckError(SDL_ReadS32BE(get(), &value));
838 return value;
839 }
840
860 Uint64 ReadU64LE()
861 {
862 Uint64 value;
863 CheckError(SDL_ReadU64LE(get(), &value));
864 return value;
865 }
866
886 Sint64 ReadS64LE()
887 {
888 Sint64 value;
889 CheckError(SDL_ReadS64LE(get(), &value));
890 return value;
891 }
892
912 Uint64 ReadU64BE()
913 {
914 Uint64 value;
915 CheckError(SDL_ReadU64BE(get(), &value));
916 return value;
917 }
918
938 Sint64 ReadS64BE()
939 {
940 Sint64 value;
941 CheckError(SDL_ReadS64BE(get(), &value));
942 return value;
943 }
944
955 void WriteU8(Uint8 value) { CheckError(SDL_WriteU8(get(), value)); }
956
967 void WriteS8(Sint8 value) { CheckError(SDL_WriteS8(get(), value)); }
968
984 void WriteU16LE(Uint16 value) { CheckError(SDL_WriteU16LE(get(), value)); }
985
1001 void WriteS16LE(Sint16 value) { CheckError(SDL_WriteS16LE(get(), value)); }
1002
1017 void WriteU16BE(Uint16 value) { CheckError(SDL_WriteU16BE(get(), value)); }
1018
1033 void WriteS16BE(Sint16 value) { CheckError(SDL_WriteS16BE(get(), value)); }
1034
1050 void WriteU32LE(Uint32 value) { CheckError(SDL_WriteU32LE(get(), value)); }
1051
1067 void WriteS32LE(Sint32 value) { CheckError(SDL_WriteS32LE(get(), value)); }
1068
1083 void WriteU32BE(Uint32 value) { CheckError(SDL_WriteU32BE(get(), value)); }
1084
1099 void WriteS32BE(Sint32 value) { CheckError(SDL_WriteS32BE(get(), value)); }
1100
1116 void WriteU64LE(Uint64 value) { CheckError(SDL_WriteU64LE(get(), value)); }
1117
1133 void WriteS64LE(Sint64 value) { CheckError(SDL_WriteS64LE(get(), value)); }
1134
1149 void WriteU64BE(Uint64 value) { CheckError(SDL_WriteU64BE(get(), value)); }
1150
1165 void WriteS64BE(Sint64 value) { CheckError(SDL_WriteS64BE(get(), value)); }
1166
1181 std::optional<Uint8> TryReadU8()
1182 {
1183 if (Uint8 value; SDL_ReadU8(get(), &value)) return value;
1184 return {};
1185 }
1186
1201 std::optional<Sint8> TryReadS8()
1202 {
1203 if (Sint8 value; SDL_ReadS8(get(), &value)) return value;
1204 return {};
1205 }
1206
1225 std::optional<Uint16> TryReadU16LE()
1226 {
1227 if (Uint16 value; SDL_ReadU16LE(get(), &value)) return value;
1228 return {};
1229 }
1230
1249 std::optional<Sint16> TryReadS16LE()
1250 {
1251 if (Sint16 value; SDL_ReadS16LE(get(), &value)) return value;
1252 return {};
1253 }
1254
1273 std::optional<Uint16> TryReadU16BE()
1274 {
1275 if (Uint16 value; SDL_ReadU16BE(get(), &value)) return value;
1276 return {};
1277 }
1278
1297 std::optional<Sint16> TryReadS16BE()
1298 {
1299 if (Sint16 value; SDL_ReadS16BE(get(), &value)) return value;
1300 return {};
1301 }
1302
1321 std::optional<Uint32> TryReadU32LE()
1322 {
1323 if (Uint32 value; SDL_ReadU32LE(get(), &value)) return value;
1324 return {};
1325 }
1326
1345 std::optional<Sint32> TryReadS32LE()
1346 {
1347 if (Sint32 value; SDL_ReadS32LE(get(), &value)) return value;
1348 return {};
1349 }
1350
1369 std::optional<Uint32> TryReadU32BE()
1370 {
1371 if (Uint32 value; SDL_ReadU32BE(get(), &value)) return value;
1372 return {};
1373 }
1374
1393 std::optional<Sint32> TryReadS32BE()
1394 {
1395 if (Sint32 value; SDL_ReadS32BE(get(), &value)) return value;
1396 return {};
1397 }
1398
1417 std::optional<Uint64> TryReadU64LE()
1418 {
1419 if (Uint64 value; SDL_ReadU64LE(get(), &value)) return value;
1420 return {};
1421 }
1422
1441 std::optional<Sint64> TryReadS64LE()
1442 {
1443 if (Sint64 value; SDL_ReadS64LE(get(), &value)) return value;
1444 return {};
1445 }
1446
1465 std::optional<Uint64> TryReadU64BE()
1466 {
1467 if (Uint64 value; SDL_ReadU64BE(get(), &value)) return value;
1468 return {};
1469 }
1470
1489 std::optional<Sint64> TryReadS64BE()
1490 {
1491 if (Sint64 value; SDL_ReadS64BE(get(), &value)) return value;
1492 return {};
1493 }
1494};
1495
1505{
1507
1511 constexpr IOStreamRef(const IOStreamRef& other)
1512 : IOStreamBase(other.get())
1513 {
1514 }
1515
1519 constexpr IOStreamRef(IOStreamRef&& other)
1520 : IOStreamBase(other.release())
1521 {
1522 }
1523
1527 constexpr ~IOStreamRef() = default;
1528
1533 {
1534 release(other.release());
1535 return *this;
1536 }
1537
1567 void reset(SDL_IOStream* newResource = {})
1568 {
1569 CheckError(SDL_CloseIO(release(newResource)));
1570 }
1571
1601 void Close() { reset(); }
1602};
1603
1613{
1615
1619 constexpr explicit IOStream(SDL_IOStream* resource = {})
1620 : IOStreamRef(resource)
1621 {
1622 }
1623
1624 constexpr IOStream(const IOStream& other) = delete;
1625
1629 constexpr IOStream(IOStream&& other) = default;
1630
1635
1640 {
1641 reset(other.release());
1642 return *this;
1643 }
1644};
1645
1646namespace prop::IOStream {
1647
1648constexpr auto WINDOWS_HANDLE_POINTER =
1649 SDL_PROP_IOSTREAM_WINDOWS_HANDLE_POINTER;
1650
1651constexpr auto STDIO_FILE_POINTER = SDL_PROP_IOSTREAM_STDIO_FILE_POINTER;
1652
1653constexpr auto FILE_DESCRIPTOR_NUMBER =
1654 SDL_PROP_IOSTREAM_FILE_DESCRIPTOR_NUMBER;
1655
1656constexpr auto ANDROID_AASSET_POINTER =
1657 SDL_PROP_IOSTREAM_ANDROID_AASSET_POINTER;
1658
1659constexpr auto MEMORY_POINTER = SDL_PROP_IOSTREAM_MEMORY_POINTER;
1660
1661constexpr auto MEMORY_SIZE_NUMBER = SDL_PROP_IOSTREAM_MEMORY_SIZE_NUMBER;
1662
1663constexpr auto DYNAMIC_MEMORY_POINTER =
1664 SDL_PROP_IOSTREAM_DYNAMIC_MEMORY_POINTER;
1665
1666constexpr auto DYNAMIC_CHUNKSIZE_NUMBER =
1667 SDL_PROP_IOSTREAM_DYNAMIC_CHUNKSIZE_NUMBER;
1668
1669} // namespace prop::IOStream
1670
1710{
1711 return IOStream{SDL_IOFromMem(mem.data, mem.size_bytes)};
1712}
1713
1753{
1754 return IOStream{SDL_IOFromConstMem(mem.data, mem.size_bytes)};
1755}
1756
1785inline IOStream IOFromDynamicMem() { return IOStream{SDL_IOFromDynamicMem()}; }
1786
1806{
1807 size_t datasize = 0;
1808 auto data = static_cast<char*>(SDL_LoadFile(file, &datasize));
1809 return StringResult{CheckError(data), datasize};
1810}
1811
1830template<class T>
1832{
1833 size_t datasize = 0;
1834 auto data = static_cast<T*>(SDL_LoadFile(file, &datasize));
1835 return OwnArray<T>{CheckError(data), datasize / sizeof(T)};
1836}
1837
1853inline void SaveFile(StringParam file, SourceBytes data)
1854{
1855 CheckError(SDL_SaveFile(file, data.data, data.size_bytes));
1856}
1857
1858#pragma region impl
1860
1861#pragma endregion impl
1862
1863} // namespace SDL
1864
1865#endif /* SDL3PP_IOSTREAM_H_ */
An exception that returns GetError()
Definition SDL3pp_error.h:167
Base class for SDL memory allocated array wrap.
Definition SDL3pp_ownPtr.h:43
A SDL managed resource.
Definition SDL3pp_resource.h:17
constexpr SDL_IOStream * release(SDL_IOStream * newResource={})
Return contained resource and empties or replace value.
Definition SDL3pp_resource.h:60
constexpr Resource(T resource={})
Constructs the underlying resource.
Definition SDL3pp_resource.h:22
constexpr SDL_IOStream * get() const
Return contained resource;.
Definition SDL3pp_resource.h:57
Helpers to use C++ strings parameters.
Definition SDL3pp_strings.h:43
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition SDL3pp_error.h:206
IOStream IOFromMem(TargetBytes mem)
Use this function to prepare a read-write memory buffer for use with IOStreamBase.
Definition SDL3pp_iostream.h:1709
StringResult LoadFile(StringParam file)
Load all the data from a file path.
Definition SDL3pp_iostream.h:1805
IOStream IOFromConstMem(SourceBytes mem)
Use this function to prepare a read-only memory buffer for use with IOStreamBase.
Definition SDL3pp_iostream.h:1752
SDL_IOWhence IOWhence
Possible whence values for IOStreamBase seeking.
Definition SDL3pp_iostream.h:64
IOStream IOFromDynamicMem()
Use this function to create an IOStreamBase that is backed by dynamically allocated memory.
Definition SDL3pp_iostream.h:1785
OwnArray< T > LoadFileAs(StringParam file)
Load all the data from a file path.
Definition SDL3pp_iostream.h:1831
constexpr IOStatus IO_STATUS_ERROR
Read or write I/O error.
Definition SDL3pp_iostream.h:42
constexpr IOStatus IO_STATUS_EOF
End of file.
Definition SDL3pp_iostream.h:45
constexpr IOStatus IO_STATUS_WRITEONLY
Tried to read a write-only buffer.
Definition SDL3pp_iostream.h:53
void SaveFile(StringParam file, SourceBytes data)
Save all the data into a file path.
Definition SDL3pp_iostream.h:1853
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 IOStreamBase.
Definition SDL3pp_iostream.h:89
SDL_IOStatus IOStatus
IOStreamBase status, set by a read or write operation.
Definition SDL3pp_iostream.h:37
constexpr IOStatus IO_STATUS_READONLY
Tried to write a read-only buffer.
Definition SDL3pp_iostream.h:50
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
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
the main namespace where all SDL3pp public functions and types live
Definition SDL3pp_assert.h:7
The read/write operation structure.
Definition SDL3pp_iostream.h:107
std::optional< Uint64 > TryReadU64LE()
Use this function to read 64 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:1417
void WriteS16BE(Sint16 value)
Use this function to write 16 bits in native format to an IOStreamBase as big-endian data.
Definition SDL3pp_iostream.h:1033
std::string Read(size_t size=-1)
Read from a data source.
Definition SDL3pp_iostream.h:352
Uint32 ReadU32LE()
Use this function to read 32 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:756
Uint32 ReadU32BE()
Use this function to read 32 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:808
Uint16 ReadU16LE()
Use this function to read 16 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:652
void WriteS16LE(Sint16 value)
Use this function to write 16 bits in native format to an IOStreamBase as little-endian data.
Definition SDL3pp_iostream.h:1001
Sint64 ReadS64BE()
Use this function to read 64 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:938
void WriteU32BE(Uint32 value)
Use this function to write 32 bits in native format to an IOStreamBase as big-endian data.
Definition SDL3pp_iostream.h:1083
std::optional< Sint8 > TryReadS8()
Use this function to read a byte from an IOStreamBase.
Definition SDL3pp_iostream.h:1201
Sint64 Seek(Sint64 offset, IOWhence whence)
Seek within an IOStreamBase data stream.
Definition SDL3pp_iostream.h:307
std::optional< Sint16 > TryReadS16BE()
Use this function to read 16 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:1297
std::optional< Sint32 > TryReadS32BE()
Use this function to read 32 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:1393
size_t Write(SourceBytes buf)
Write to an IOStreamBase data stream.
Definition SDL3pp_iostream.h:424
OwnArray< T > LoadFileAs()
Load all the data from an SDL data stream.
Definition SDL3pp_iostream.h:563
void WriteU16BE(Uint16 value)
Use this function to write 16 bits in native format to an IOStreamBase as big-endian data.
Definition SDL3pp_iostream.h:1017
StringResult LoadFile()
Load all the data from an SDL data stream.
Definition SDL3pp_iostream.h:538
std::optional< Uint32 > TryReadU32BE()
Use this function to read 32 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:1369
void WriteU64LE(Uint64 value)
Use this function to write 64 bits in native format to an IOStreamBase as little-endian data.
Definition SDL3pp_iostream.h:1116
IOStatus GetStatus() const
Query the stream status of an IOStreamBase.
Definition SDL3pp_iostream.h:262
size_t println(std::string_view fmt, auto... args)
Definition SDL3pp_iostream.h:440
std::optional< Sint32 > TryReadS32LE()
Use this function to read 32 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:1345
std::optional< Uint16 > TryReadU16LE()
Use this function to read 16 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:1225
PropertiesRef GetProperties() const
Get the properties associated with an IOStreamBase.
Definition SDL3pp_iostream.h:240
Uint64 ReadU64LE()
Use this function to read 64 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:860
size_t printf(SDL_PRINTF_FORMAT_STRING const char *fmt,...)
Print to an IOStreamBase data stream.
Definition SDL3pp_iostream.h:467
Sint64 GetSize() const
Use this function to get the size of the data stream in an IOStreamBase.
Definition SDL3pp_iostream.h:274
void Flush()
Flush any buffered data in the stream.
Definition SDL3pp_iostream.h:519
Sint8 ReadS8()
Use this function to read a signed byte from an IOStreamBase.
Definition SDL3pp_iostream.h:626
std::optional< Sint16 > TryReadS16LE()
Use this function to read 16 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:1249
std::optional< Uint64 > TryReadU64BE()
Use this function to read 64 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:1465
Uint16 ReadU16BE()
Use this function to read 16 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:704
std::optional< Sint64 > TryReadS64LE()
Use this function to read 64 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:1441
std::optional< Uint16 > TryReadU16BE()
Use this function to read 16 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:1273
IOStreamBase(const IOStreamInterface &iface, void *userdata)
Create a custom IOStreamBase.
Definition SDL3pp_iostream.h:225
void WriteU64BE(Uint64 value)
Use this function to write 64 bits in native format to an IOStreamBase as big-endian data.
Definition SDL3pp_iostream.h:1149
IOStreamBase(StringParam file, StringParam mode)
Use this function to create a new IOStreamBase structure for reading from and/or writing to a named f...
Definition SDL3pp_iostream.h:192
Sint16 ReadS16LE()
Use this function to read 16 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:678
size_t Read(TargetBytes buf)
Read from a data source.
Definition SDL3pp_iostream.h:391
size_t vprintf(SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
Print to an IOStreamBase data stream.
Definition SDL3pp_iostream.h:498
Sint64 ReadS64LE()
Use this function to read 64 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:886
size_t print(std::string_view fmt, auto... args)
Definition SDL3pp_iostream.h:432
Sint32 ReadS32BE()
Use this function to read 32 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:834
void WriteU32LE(Uint32 value)
Use this function to write 32 bits in native format to an IOStreamBase as little-endian data.
Definition SDL3pp_iostream.h:1050
std::optional< Sint64 > TryReadS64BE()
Use this function to read 64 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:1489
Sint32 ReadS32LE()
Use this function to read 32 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:782
Sint64 Tell() const
Determine the current read/write offset in an IOStreamBase data stream.
Definition SDL3pp_iostream.h:328
void WriteS64LE(Sint64 value)
Use this function to write 64 bits in native format to an IOStreamBase as little-endian data.
Definition SDL3pp_iostream.h:1133
Uint64 ReadU64BE()
Use this function to read 64 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:912
void WriteS64BE(Sint64 value)
Use this function to write 64 bits in native format to an IOStreamBase as big-endian data.
Definition SDL3pp_iostream.h:1165
Uint8 ReadU8()
Use this function to read a byte from an IOStreamBase.
Definition SDL3pp_iostream.h:604
void WriteU16LE(Uint16 value)
Use this function to write 16 bits in native format to an IOStreamBase as little-endian data.
Definition SDL3pp_iostream.h:984
void WriteS32BE(Sint32 value)
Use this function to write 32 bits in native format to an IOStreamBase as big-endian data.
Definition SDL3pp_iostream.h:1099
void SaveFile(SourceBytes data)
Save all the data into an SDL data stream.
Definition SDL3pp_iostream.h:584
void WriteS8(Sint8 value)
Use this function to write a signed byte to an IOStreamBase.
Definition SDL3pp_iostream.h:967
void WriteU8(Uint8 value)
Use this function to write a byte to an IOStreamBase.
Definition SDL3pp_iostream.h:955
void WriteS32LE(Sint32 value)
Use this function to write 32 bits in native format to an IOStreamBase as little-endian data.
Definition SDL3pp_iostream.h:1067
Sint16 ReadS16BE()
Use this function to read 16 bits of big-endian data from an IOStreamBase and return in native format...
Definition SDL3pp_iostream.h:730
std::optional< Uint32 > TryReadU32LE()
Use this function to read 32 bits of little-endian data from an IOStreamBase and return in native for...
Definition SDL3pp_iostream.h:1321
std::optional< Uint8 > TryReadU8()
Use this function to read a byte from an IOStreamBase.
Definition SDL3pp_iostream.h:1181
Handle to a non owned iOStream.
Definition SDL3pp_iostream.h:1505
void Close()
Close and free an allocated IOStreamBase structure.
Definition SDL3pp_iostream.h:1601
constexpr IOStreamRef(IOStreamRef &&other)
Move constructor.
Definition SDL3pp_iostream.h:1519
void reset(SDL_IOStream *newResource={})
Close and free an allocated IOStreamBase structure.
Definition SDL3pp_iostream.h:1567
constexpr IOStreamRef(const IOStreamRef &other)
Copy constructor.
Definition SDL3pp_iostream.h:1511
IOStreamRef & operator=(IOStreamRef other)
Assignment operator.
Definition SDL3pp_iostream.h:1532
constexpr ~IOStreamRef()=default
Default constructor.
Handle to an owned iOStream.
Definition SDL3pp_iostream.h:1613
~IOStream()
Frees up resource when object goes out of scope.
Definition SDL3pp_iostream.h:1634
constexpr IOStream(SDL_IOStream *resource={})
Constructs from the underlying resource.
Definition SDL3pp_iostream.h:1619
IOStream & operator=(IOStream other)
Assignment operator.
Definition SDL3pp_iostream.h:1639
constexpr IOStream(IOStream &&other)=default
Move constructor.
Handle to a non owned properties.
Definition SDL3pp_properties.h:693
Source byte stream.
Definition SDL3pp_strings.h:239
size_t size_bytes
The size in bytes.
Definition SDL3pp_strings.h:241
const void * data
The data copied from.
Definition SDL3pp_strings.h:240
A simple std::string-like interface for SDL allocated strings.
Definition SDL3pp_strings.h:153
Target byte stream.
Definition SDL3pp_strings.h:305
size_t size_bytes
The size in bytes.
Definition SDL3pp_strings.h:307
void * data
The address to have data copied to it.
Definition SDL3pp_strings.h:306