SDL3pp
A slim C++ wrapper for SDL3
Loading...
Searching...
No Matches
SDL3pp_stdinc.h
1#ifndef SDL3PP_STDINC_H_
2#define SDL3PP_STDINC_H_
3
4#include <chrono>
5#include <span>
6#include <SDL3/SDL_stdinc.h>
7#include "SDL3pp_callbackWrapper.h"
8#include "SDL3pp_error.h"
9#include "SDL3pp_optionalRef.h"
10#include "SDL3pp_ownPtr.h"
11#include "SDL3pp_spanRef.h"
12#include "SDL3pp_strings.h"
13
14namespace SDL {
15
42using TimeRaw = SDL_Time;
43
44// Forward decl
45struct Time;
46
47// Forward decl
48struct Environment;
49
51using EnvironmentRaw = SDL_Environment*;
52
53// Forward decl
54struct EnvironmentRef;
55
56// Forward decl
57struct IConv;
58
60using IConvRaw = SDL_iconv_t;
61
62// Forward decl
63struct IConvRef;
64
65#ifdef SDL3PP_DOC
66
83#define SDL_NOLONGLONG 1
84
99#define SDL_SIZE_MAX SIZE_MAX
100
132#define SDL_COMPILE_TIME_ASSERT(name, x) FailToCompileIf_x_IsFalse(x)
133
134#endif // SDL3PP_DOC
135
144template<class T, std::size_t N>
145constexpr std::size_t arraysize(const T (&array)[N])
146{
147 return std::size(array);
148}
149
150#ifdef SDL3PP_DOC
151
159#define SDL_STRINGIFY_ARG(arg) #arg
160
161#endif // SDL3PP_DOC
162
176constexpr Uint32 FourCC(Uint8 a, Uint8 b, Uint8 c, Uint8 d)
177{
178 return SDL_FOURCC(a, b, c, d);
179}
180
181#ifdef SDL3PP_DOC
182
194#define SDL_SINT64_C(c) c##LL /* or whatever the current compiler uses. */
195
207#define SDL_UINT64_C(c) c##ULL /* or whatever the current compiler uses. */
208
209#endif // SDL3PP_DOC
210
217
219constexpr Sint8 MAX_SINT8 = SDL_MAX_SINT8;
220
222constexpr Sint8 MIN_SINT8 = SDL_MIN_SINT8;
223
230
232constexpr Uint8 MAX_UINT8 = SDL_MAX_UINT8;
233
235constexpr Uint8 MIN_UINT8 = SDL_MIN_UINT8;
236
243
245constexpr Sint16 MAX_SINT16 = SDL_MAX_SINT16;
246
248constexpr Sint16 MIN_SINT16 = SDL_MIN_SINT16;
249
256
258constexpr Uint16 MAX_UINT16 = SDL_MAX_UINT16;
259
261constexpr Uint16 MIN_UINT16 = SDL_MIN_UINT16;
262
269
271constexpr Sint32 MAX_SINT32 = SDL_MAX_SINT32;
272
274constexpr Sint32 MIN_SINT32 = SDL_MIN_SINT32;
275
282
284constexpr Uint32 MAX_UINT32 = SDL_MAX_UINT32;
285
287constexpr Uint8 MIN_UINT32 = SDL_MIN_UINT32;
288
297
299constexpr Sint64 MAX_SINT64 = SDL_MAX_SINT64;
300
302constexpr Sint64 MIN_SINT64 = SDL_MIN_SINT64;
303
312
314constexpr Uint64 MAX_UINT64 = SDL_MAX_UINT64;
315
317constexpr Uint8 MIN_UINT64 = SDL_MIN_UINT64;
318
320using Seconds = std::chrono::duration<float>;
321
323using Nanoseconds = std::chrono::nanoseconds;
324
326using Milliseconds = std::chrono::milliseconds;
327
329constexpr float ToSeconds(Seconds duration) { return duration.count(); }
330
332constexpr Seconds FromSeconds(float duration) { return Seconds(duration); }
333
335constexpr Sint64 ToNS(Nanoseconds duration) { return duration.count(); }
336
338constexpr Nanoseconds FromNS(Sint64 duration) { return Nanoseconds{duration}; }
339
353class Time
354{
355 Nanoseconds m_time;
356
357public:
358 constexpr Time() = default;
359
365 constexpr explicit Time(TimeRaw time) noexcept
366 : m_time(time)
367 {
368 }
369
375 constexpr Time(std::chrono::nanoseconds time) noexcept
376 : m_time(time)
377 {
378 }
379
381 constexpr explicit operator bool() const
382 {
383 return m_time != std::chrono::nanoseconds{};
384 }
385
387 constexpr operator std::chrono::nanoseconds() const { return m_time; }
388
399 static Time Current();
400
402 static constexpr Time FromNS(Sint64 time)
403 {
404 return Time{std::chrono::nanoseconds{time}};
405 }
406
408 constexpr Sint64 ToNS() const { return m_time.count(); }
409
422 static constexpr Time FromPosix(Sint64 time);
423
435 constexpr Sint64 ToPosix() const;
436
452 static Time FromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime);
453
469 void ToWindows(Uint32* dwLowDateTime, Uint32* dwHighDateTime) const;
470
472 constexpr float ToSeconds() const { return Seconds(m_time).count(); }
473
475 static constexpr Time FromSeconds(float interval)
476 {
477 return std::chrono::duration_cast<std::chrono::nanoseconds>(
478 Seconds(interval));
479 }
480
482 constexpr Time& operator+=(std::chrono::nanoseconds interval)
483 {
484 m_time += interval;
485 return *this;
486 }
487
489 constexpr Time& operator-=(std::chrono::nanoseconds interval)
490 {
491 m_time -= interval;
492 return *this;
493 }
494};
495
497constexpr Time MAX_TIME = Time::FromNS(SDL_MAX_TIME);
498
500constexpr Time MIN_TIME = Time::FromNS(SDL_MIN_TIME);
501
502#ifndef FLT_EPSILON
503
512constexpr float FLT_EPSILON = 1.1920928955078125e-07F;
513
514#endif // FLT_EPSILON
515
521template<class I>
522concept Interface = requires(I* iface) { (iface)->version = sizeof(I); };
523
562template<Interface I>
563constexpr void InitInterface(I* iface)
564{
565 SDL_INIT_INTERFACE(iface);
566}
567
593inline void* malloc(size_t size) { return SDL_malloc(size); }
594
618inline void* calloc(size_t nmemb, size_t size)
619{
620 return SDL_calloc(nmemb, size);
621}
622
659inline void* realloc(void* mem, size_t size) { return SDL_realloc(mem, size); }
660
679inline void free(void* mem) { SDL_free(mem); }
680
698using malloc_func = void*(SDLCALL*)(size_t size);
699
719using calloc_func = void*(SDLCALL*)(size_t nmemb, size_t size);
720
740using realloc_func = void*(SDLCALL*)(void* mem, size_t size);
741
758using free_func = void(SDLCALL*)(void* mem);
759
781{
782 SDL_GetOriginalMemoryFunctions(
784}
785
807{
808 SDL_GetMemoryFunctions(malloc_func, calloc_func, realloc_func, free_func);
809}
810
840{
842 SDL_SetMemoryFunctions(malloc_func, calloc_func, realloc_func, free_func));
843}
844
867inline void* aligned_alloc(size_t alignment, size_t size)
868{
869 return SDL_aligned_alloc(alignment, size);
870}
871
888inline void aligned_free(void* mem) { SDL_aligned_free(mem); }
889
899inline int GetNumAllocations() { return SDL_GetNumAllocations(); }
900
917{
918 EnvironmentRaw m_resource = nullptr;
919
920public:
922 constexpr Environment(std::nullptr_t = nullptr) noexcept
923 : m_resource(nullptr)
924 {
925 }
926
934 constexpr explicit Environment(EnvironmentRaw resource) noexcept
935 : m_resource(resource)
936 {
937 }
938
940 constexpr Environment(const Environment& other) noexcept = delete;
941
943 constexpr Environment(Environment&& other) noexcept
944 : Environment(other.release())
945 {
946 }
947
948 constexpr Environment(const EnvironmentRef& other) = delete;
949
950 constexpr Environment(EnvironmentRef&& other) = delete;
951
972 Environment(bool populated);
973
975 ~Environment() { SDL_DestroyEnvironment(m_resource); }
976
978 constexpr Environment& operator=(Environment&& other) noexcept
979 {
980 std::swap(m_resource, other.m_resource);
981 return *this;
982 }
983
985 Environment& operator=(const Environment& other) = delete;
986
988 constexpr EnvironmentRaw get() const noexcept { return m_resource; }
989
991 constexpr EnvironmentRaw release() noexcept
992 {
993 auto r = m_resource;
994 m_resource = nullptr;
995 return r;
996 }
997
999 constexpr auto operator<=>(const Environment& other) const noexcept = default;
1000
1002 constexpr explicit operator bool() const noexcept { return !!m_resource; }
1003
1014 void Destroy();
1015
1033 const char* GetVariable(StringParam name);
1034
1055
1063 Uint64 GetVariableCount() { return GetVariables().size(); }
1064
1085 void SetVariable(StringParam name, StringParam value, bool overwrite);
1086
1104 void UnsetVariable(StringParam name);
1105};
1106
1113{
1115
1123 constexpr EnvironmentRef(EnvironmentRaw resource) noexcept
1124 : Environment(resource)
1125 {
1126 }
1127
1135 constexpr EnvironmentRef(const Environment& resource) noexcept
1136 : Environment(resource.get())
1137 {
1138 }
1139
1147 constexpr EnvironmentRef(Environment&& resource) noexcept
1148 : Environment(std::move(resource).release())
1149 {
1150 }
1151
1153 constexpr EnvironmentRef(const EnvironmentRef& other) noexcept
1154 : Environment(other.get())
1155 {
1156 }
1157
1159 constexpr EnvironmentRef(EnvironmentRef&& other) noexcept
1160 : Environment(other.get())
1161 {
1162 }
1163
1166
1169 {
1170 release();
1171 Environment::operator=(Environment(other.get()));
1172 return *this;
1173 }
1174
1176 constexpr operator EnvironmentRaw() const noexcept { return get(); }
1177};
1178
1200inline EnvironmentRaw GetEnvironment() { return SDL_GetEnvironment(); }
1201
1222inline Environment CreateEnvironment(bool populated)
1223{
1224 return Environment(populated);
1225}
1226
1227inline Environment::Environment(bool populated)
1228 : m_resource(SDL_CreateEnvironment(populated))
1229{
1230}
1231
1251{
1252 return SDL_GetEnvironmentVariable(env, name);
1253}
1254
1256{
1257 return SDL::GetEnvironmentVariable(m_resource, std::move(name));
1258}
1259
1280{
1281 return OwnArray<char*>{CheckError(SDL_GetEnvironmentVariables(env))};
1282}
1283
1285{
1286 return SDL::GetEnvironmentVariables(m_resource);
1287}
1288
1310 StringParam name,
1311 StringParam value,
1312 bool overwrite)
1313{
1314 CheckError(SDL_SetEnvironmentVariable(env, name, value, overwrite));
1315}
1316
1318 StringParam value,
1319 bool overwrite)
1320{
1322 m_resource, std::move(name), std::move(value), overwrite);
1323}
1324
1344{
1345 CheckError(SDL_UnsetEnvironmentVariable(env, name));
1346}
1347
1349{
1350 SDL::UnsetEnvironmentVariable(m_resource, std::move(name));
1351}
1352
1366{
1367 SDL_DestroyEnvironment(env);
1368}
1369
1371
1385inline const char* getenv(StringParam name) { return SDL_getenv(name); }
1386
1404inline const char* getenv_unsafe(StringParam name)
1405{
1406 return SDL_getenv_unsafe(name);
1407}
1408
1425inline int setenv_unsafe(StringParam name, StringParam value, int overwrite)
1426{
1427 return SDL_setenv_unsafe(name, value, overwrite);
1428}
1429
1444{
1445 return SDL_unsetenv_unsafe(name);
1446}
1447
1462using CompareCallback = int(SDLCALL*)(const void* a, const void* b);
1463
1508inline void qsort(void* base,
1509 size_t nmemb,
1510 size_t size,
1511 CompareCallback compare)
1512{
1513 SDL_qsort(base, nmemb, size, compare);
1514}
1515
1565inline void* bsearch(const void* key,
1566 const void* base,
1567 size_t nmemb,
1568 size_t size,
1569 CompareCallback compare)
1570{
1571 return SDL_bsearch(key, base, nmemb, size, compare);
1572}
1573
1589using CompareCallback_r = int(SDLCALL*)(void* userdata,
1590 const void* a,
1591 const void* b);
1592
1608using CompareCB = std::function<int(const void* a, const void* b)>;
1609
1662inline void qsort_r(void* base,
1663 size_t nmemb,
1664 size_t size,
1665 CompareCallback_r compare,
1666 void* userdata)
1667{
1668 SDL_qsort_r(base, nmemb, size, compare, userdata);
1669}
1670
1722inline void qsort_r(void* base, size_t nmemb, size_t size, CompareCB compare)
1723{
1724 return qsort_r(
1725 base,
1726 nmemb,
1727 size,
1728 [](void* userdata, const void* a, const void* b) {
1729 auto& cb = *static_cast<const CompareCB*>(userdata);
1730 return cb(a, b);
1731 },
1732 &compare);
1733}
1734
1792inline void* bsearch_r(const void* key,
1793 const void* base,
1794 size_t nmemb,
1795 size_t size,
1796 CompareCallback_r compare,
1797 void* userdata)
1798{
1799 return SDL_bsearch_r(key, base, nmemb, size, compare, userdata);
1800}
1801
1858inline void* bsearch_r(const void* key,
1859 const void* base,
1860 size_t nmemb,
1861 size_t size,
1862 CompareCB compare)
1863{
1864 return bsearch_r(
1865 key,
1866 base,
1867 nmemb,
1868 size,
1869 [](void* userdata, const void* a, const void* b) {
1870 auto& cb = *static_cast<const CompareCB*>(userdata);
1871 return cb(a, b);
1872 },
1873 &compare);
1874}
1875
1886inline int abs(int x) { return SDL_abs(x); }
1887
1907inline double abs(double x) { return SDL_fabs(x); }
1908
1928inline float abs(float x) { return SDL_fabsf(x); }
1929
1946template<class T, class U>
1947constexpr T min(T x, U y)
1948{
1949 return SDL_min(x, y);
1950}
1951
1968template<class T, class U>
1969constexpr T max(T x, U y)
1970{
1971 return SDL_max(x, y);
1972}
1973
1996template<class T, class U, class V>
1997constexpr T clamp(T x, U a, V b)
1998{
1999 return SDL_clamp(x, a, b);
2000}
2001
2015inline int isalpha(int x) { return SDL_isalpha(x); }
2016
2030inline int isalnum(int x) { return SDL_isalnum(x); }
2031
2045inline int isblank(int x) { return SDL_isblank(x); }
2046
2060inline int iscntrl(int x) { return SDL_iscntrl(x); }
2061
2075inline int isdigit(int x) { return SDL_isdigit(x); }
2076
2090inline int isxdigit(int x) { return SDL_isxdigit(x); }
2091
2108inline int ispunct(int x) { return SDL_ispunct(x); }
2109
2130inline int isspace(int x) { return SDL_isspace(x); }
2131
2145inline int isupper(int x) { return SDL_isupper(x); }
2146
2160inline int islower(int x) { return SDL_islower(x); }
2161
2179inline int isprint(int x) { return SDL_isprint(x); }
2180
2200inline int isgraph(int x) { return SDL_isgraph(x); }
2201
2218inline int toupper(int x) { return SDL_toupper(x); }
2219
2236inline int tolower(int x) { return SDL_tolower(x); }
2237
2257inline Uint16 crc16(Uint16 crc, const void* data, size_t len)
2258{
2259 return SDL_crc16(crc, data, len);
2260}
2261
2281inline Uint32 crc32(Uint32 crc, const void* data, size_t len)
2282{
2283 return SDL_crc32(crc, data, len);
2284}
2285
2310inline Uint32 murmur3_32(const void* data, size_t len, Uint32 seed)
2311{
2312 return SDL_murmur3_32(data, len, seed);
2313}
2314
2333inline void* memcpy(void* dst, const void* src, size_t len)
2334{
2335#ifdef SDL_SLOW_MEMCPY
2336 return SDL_memcpy(dst, src, len);
2337#else
2338 return ::memcpy(dst, src, len);
2339#endif // SDL_SLOW_MEMCPY
2340}
2341
2366template<typename T, typename U>
2367constexpr T* copyp(T* dst, const U* src)
2368{
2369 SDL_copyp(dst, src);
2370 return dst;
2371}
2372
2390inline void* memmove(void* dst, const void* src, size_t len)
2391{
2392#ifdef SDL_SLOW_MEMMOVE
2393 return SDL_memmove(dst, src, len);
2394#else
2395 return ::memmove(dst, src, len);
2396#endif // SDL_SLOW_MEMMOVE
2397}
2398
2417inline void* memset(void* dst, int c, size_t len)
2418{
2419#ifdef SDL_SLOW_MEMSET
2420 return SDL_memset(dst, c, len);
2421#else
2422 return ::memset(dst, c, len);
2423#endif // SDL_SLOW_MEMSET
2424}
2425
2444inline void* memset4(void* dst, Uint32 val, size_t dwords)
2445{
2446 return SDL_memset4(dst, val, dwords);
2447}
2448
2466template<class T>
2467inline void zero(T& x)
2468{
2469 SDL_zero(x);
2470}
2471
2489template<class T>
2490inline void zerop(T* x)
2491{
2492 SDL_zerop(x);
2493}
2494
2512template<class T, std::size_t N>
2513inline void zeroa(T (&x)[N])
2514{
2515 SDL_zeroa(x);
2516}
2517
2532inline int memcmp(const void* s1, const void* s2, size_t len)
2533{
2534 return SDL_memcmp(s1, s2, len);
2535}
2536
2561inline size_t wcslen(const wchar_t* wstr) { return SDL_wcslen(wstr); }
2562
2591inline size_t wcsnlen(const wchar_t* wstr, size_t maxlen)
2592{
2593 return SDL_wcsnlen(wstr, maxlen);
2594}
2595
2621inline size_t wcslcpy(wchar_t* dst, const wchar_t* src, size_t maxlen)
2622{
2623 return SDL_wcslcpy(dst, src, maxlen);
2624}
2625
2652inline size_t wcslcat(wchar_t* dst, const wchar_t* src, size_t maxlen)
2653{
2654 return SDL_wcslcat(dst, src, maxlen);
2655}
2656
2673inline wchar_t* wcsdup(const wchar_t* wstr) { return SDL_wcsdup(wstr); }
2674
2693inline wchar_t* wcsstr(const wchar_t* haystack, const wchar_t* needle)
2694{
2695 return SDL_wcsstr(haystack, needle);
2696}
2697
2719inline wchar_t* wcsnstr(const wchar_t* haystack,
2720 const wchar_t* needle,
2721 size_t maxlen)
2722{
2723 return SDL_wcsnstr(haystack, needle, maxlen);
2724}
2725
2742inline int wcscmp(const wchar_t* str1, const wchar_t* str2)
2743{
2744 return SDL_wcscmp(str1, str2);
2745}
2746
2774inline int wcsncmp(const wchar_t* str1, const wchar_t* str2, size_t maxlen)
2775{
2776 return SDL_wcsncmp(str1, str2, maxlen);
2777}
2778
2806inline int wcscasecmp(const wchar_t* str1, const wchar_t* str2)
2807{
2808 return SDL_wcscasecmp(str1, str2);
2809}
2810
2850inline int wcsncasecmp(const wchar_t* str1, const wchar_t* str2, size_t maxlen)
2851{
2852 return SDL_wcsncasecmp(str1, str2, maxlen);
2853}
2854
2879inline long wcstol(const wchar_t* str, wchar_t** endp, int base)
2880{
2881 return SDL_wcstol(str, endp, base);
2882}
2883
2902inline size_t strlen(StringParam str) { return SDL_strlen(str); }
2903
2925inline size_t strnlen(StringParam str, size_t maxlen)
2926{
2927 return SDL_strnlen(str, maxlen);
2928}
2929
2955inline size_t strlcpy(char* dst, StringParam src, size_t maxlen)
2956{
2957 return SDL_strlcpy(dst, src, maxlen);
2958}
2959
2986inline size_t utf8strlcpy(char* dst, StringParam src, size_t dst_bytes)
2987{
2988 return SDL_utf8strlcpy(dst, src, dst_bytes);
2989}
2990
3017inline size_t strlcat(char* dst, StringParam src, size_t maxlen)
3018{
3019 return SDL_strlcat(dst, src, maxlen);
3020}
3021
3038inline char* strdup(StringParam str) { return SDL_strdup(str); }
3039
3063inline char* strndup(StringParam str, size_t maxlen)
3064{
3065 return SDL_strndup(str, maxlen);
3066}
3067
3087inline char* strrev(char* str) { return SDL_strrev(str); }
3088
3108inline char* strupr(char* str) { return SDL_strupr(str); }
3109
3129inline char* strlwr(char* str) { return SDL_strlwr(str); }
3130
3149inline char* strchr(StringParam str, int c) { return SDL_strchr(str, c); }
3150
3168inline char* strrchr(StringParam str, int c) { return SDL_strrchr(str, c); }
3169
3188inline char* strstr(StringParam haystack, StringParam needle)
3189{
3190 return SDL_strstr(haystack, needle);
3191}
3192
3214inline char* strnstr(StringParam haystack, StringParam needle, size_t maxlen)
3215{
3216 return SDL_strnstr(haystack, needle, maxlen);
3217}
3218
3245inline char* strcasestr(StringParam haystack, StringParam needle)
3246{
3247 return SDL_strcasestr(haystack, needle);
3248}
3249
3276inline char* strtok_r(char* str, StringParam delim, char** saveptr)
3277{
3278 return SDL_strtok_r(str, delim, saveptr);
3279}
3280
3305inline size_t utf8strlen(StringParam str) { return SDL_utf8strlen(str); }
3306
3337inline size_t utf8strnlen(StringParam str, size_t bytes)
3338{
3339 return SDL_utf8strnlen(str, bytes);
3340}
3341
3367inline char* itoa(int value, char* str, int radix)
3368{
3369 return SDL_itoa(value, str, radix);
3370}
3371
3397inline char* uitoa(unsigned int value, char* str, int radix)
3398{
3399 return SDL_uitoa(value, str, radix);
3400}
3401
3427inline char* ltoa(long value, char* str, int radix)
3428{
3429 return SDL_ltoa(value, str, radix);
3430}
3431
3457inline char* ultoa(unsigned long value, char* str, int radix)
3458{
3459 return SDL_ultoa(value, str, radix);
3460}
3461
3462#ifndef SDL_NOLONGLONG
3463
3489inline char* lltoa(long long value, char* str, int radix)
3490{
3491 return SDL_lltoa(value, str, radix);
3492}
3493
3519inline char* ulltoa(unsigned long long value, char* str, int radix)
3520{
3521 return SDL_ulltoa(value, str, radix);
3522}
3523
3524#endif // SDL_NOLONGLONG
3525
3547inline int atoi(StringParam str) { return SDL_atoi(str); }
3548
3568inline double atof(StringParam str) { return SDL_atof(str); }
3569
3601inline long strtol(StringParam str, char** endp, int base)
3602{
3603 return SDL_strtol(str, endp, base);
3604}
3605
3636inline unsigned long strtoul(StringParam str, char** endp, int base)
3637{
3638 return SDL_strtoul(str, endp, base);
3639}
3640
3641#ifndef SDL_NOLONGLONG
3642
3673inline long long strtoll(StringParam str, char** endp, int base)
3674{
3675 return SDL_strtoll(str, endp, base);
3676}
3677
3708inline unsigned long long strtoull(StringParam str, char** endp, int base)
3709{
3710 return SDL_strtoull(str, endp, base);
3711}
3712
3713#endif // SDL_NOLONGLONG
3714
3742inline double strtod(StringParam str, char** endp)
3743{
3744 return SDL_strtod(str, endp);
3745}
3746
3764inline int strcmp(StringParam str1, StringParam str2)
3765{
3766 return SDL_strcmp(str1, str2);
3767}
3768
3796inline int strncmp(StringParam str1, StringParam str2, size_t maxlen)
3797{
3798 return SDL_strncmp(str1, str2, maxlen);
3799}
3800
3826inline int strcasecmp(StringParam str1, StringParam str2)
3827{
3828 return SDL_strcasecmp(str1, str2);
3829}
3830
3867inline int strncasecmp(StringParam str1, StringParam str2, size_t maxlen)
3868{
3869 return SDL_strncasecmp(str1, str2, maxlen);
3870}
3871
3888inline char* strpbrk(StringParam str, StringParam breakset)
3889{
3890 return SDL_strpbrk(str, breakset);
3891}
3892
3906constexpr Uint32 INVALID_UNICODE_CODEPOINT = SDL_INVALID_UNICODE_CODEPOINT;
3907
3949inline Uint32 StepUTF8(const char** pstr, size_t* pslen)
3950{
3951 return SDL_StepUTF8(pstr, pslen);
3952}
3953
3981inline Uint32 StepBackUTF8(StringParam start, const char** pstr)
3982{
3983 return SDL_StepBackUTF8(start, pstr);
3984}
3985
4013inline char* UCS4ToUTF8(Uint32 codepoint, char* dst)
4014{
4015 return SDL_UCS4ToUTF8(codepoint, dst);
4016}
4017
4033inline int sscanf(StringParam text,
4034 SDL_SCANF_FORMAT_STRING const char* fmt,
4035 ...)
4036{
4037 int rc;
4038 va_list ap;
4039 va_start(ap, fmt);
4040 rc = SDL_vsscanf(text, fmt, ap);
4041 va_end(ap);
4042 return rc;
4043}
4044
4061inline int vsscanf(StringParam text,
4062 SDL_SCANF_FORMAT_STRING const char* fmt,
4063 va_list ap)
4064{
4065 return SDL_vsscanf(text, fmt, ap);
4066}
4067
4098inline int snprintf(char* text,
4099 size_t maxlen,
4100 SDL_PRINTF_FORMAT_STRING const char* fmt,
4101 ...)
4102{
4103 va_list ap;
4104 int result;
4105
4106 va_start(ap, fmt);
4107 result = SDL_vsnprintf(text, maxlen, fmt, ap);
4108 va_end(ap);
4109
4110 return result;
4111}
4112
4144inline int swprintf(wchar_t* text,
4145 size_t maxlen,
4146 SDL_PRINTF_FORMAT_STRING const wchar_t* fmt,
4147 ...)
4148{
4149 va_list ap;
4150 int result;
4151
4152 va_start(ap, fmt);
4153 result = SDL_vswprintf(text, maxlen, fmt, ap);
4154 va_end(ap);
4155
4156 return result;
4157}
4158
4177inline int vsnprintf(char* text,
4178 size_t maxlen,
4179 SDL_PRINTF_FORMAT_STRING const char* fmt,
4180 va_list ap)
4181{
4182 return SDL_vsnprintf(text, maxlen, fmt, ap);
4183}
4184
4204inline int vswprintf(wchar_t* text,
4205 size_t maxlen,
4206 SDL_PRINTF_FORMAT_STRING const wchar_t* fmt,
4207 va_list ap)
4208{
4209 return SDL_vswprintf(text, maxlen, fmt, ap);
4210}
4211
4238inline int asprintf(char** strp, SDL_PRINTF_FORMAT_STRING const char* fmt, ...)
4239{
4240 va_list ap;
4241 int result;
4242
4243 va_start(ap, fmt);
4244 result = SDL_vasprintf(strp, fmt, ap);
4245 va_end(ap);
4246
4247 return result;
4248}
4249
4267inline int vasprintf(char** strp,
4268 SDL_PRINTF_FORMAT_STRING const char* fmt,
4269 va_list ap)
4270{
4271 return SDL_vasprintf(strp, fmt, ap);
4272}
4273
4291inline void srand(Uint64 seed) { SDL_srand(seed); }
4292
4304{
4305 Uint64 m_state;
4306
4307public:
4309 constexpr Random()
4310 : m_state(0)
4311 {
4312 }
4313
4315 constexpr explicit Random(Uint64 state)
4316 : m_state(state)
4317 {
4318 }
4319
4321 constexpr operator Uint64() const { return m_state; }
4322
4354 Sint32 rand(Sint32 n) { return SDL_rand_r(&m_state, n); }
4355
4378 float randf() { return SDL_randf_r(&m_state); }
4379
4401 Uint32 rand_bits() { return SDL_rand_bits_r(&m_state); }
4402};
4403
4434inline Sint32 rand(Sint32 n) { return SDL_rand(n); }
4435
4469inline Sint32 rand(Uint64* state, Sint32 n) { return SDL_rand_r(state, n); }
4470
4504inline Sint32 rand(Random& state, Sint32 n) { return state.rand(n); }
4505
4526inline float randf() { return SDL_randf(); }
4527
4552inline float randf(Uint64* state) { return SDL_randf_r(state); }
4553
4578inline float randf(Random& state) { return state.randf(); }
4579
4601inline Uint32 rand_bits() { return SDL_rand_bits(); }
4602
4626inline Uint32 rand_bits(Uint64* state) { return SDL_rand_bits_r(state); }
4627
4651inline Uint32 rand_bits(Random& state) { return state.rand_bits(); }
4652
4660constexpr double PI_D = SDL_PI_D;
4661
4669constexpr float PI_F = SDL_PI_F;
4670
4698inline double acos(double x) { return SDL_acos(x); }
4699
4727inline float acos(float x) { return SDL_acosf(x); }
4728
4756inline double asin(double x) { return SDL_asin(x); }
4757
4785inline float asin(float x) { return SDL_asinf(x); }
4786
4816inline double atan(double x) { return SDL_atan(x); }
4817
4847inline float atan(float x) { return SDL_atanf(x); }
4848
4881inline double atan2(double y, double x) { return SDL_atan2(y, x); }
4882
4916inline float atan2(float y, float x) { return SDL_atan2f(y, x); }
4917
4944inline double ceil(double x) { return SDL_ceil(x); }
4945
4972inline float ceil(float x) { return SDL_ceilf(x); }
4973
4997inline double copysign(double x, double y) { return SDL_copysign(x, y); }
4998
5022inline float copysign(float x, float y) { return SDL_copysignf(x, y); }
5023
5049inline double cos(double x) { return SDL_cos(x); }
5050
5076inline float cos(float x) { return SDL_cosf(x); }
5077
5107inline double exp(double x) { return SDL_exp(x); }
5108
5138inline float exp(float x) { return SDL_expf(x); }
5139
5166inline double floor(double x) { return SDL_floor(x); }
5167
5194inline float floor(float x) { return SDL_floorf(x); }
5195
5223inline double trunc(double x) { return SDL_trunc(x); }
5224
5252inline float trunc(float x) { return SDL_truncf(x); }
5253
5282inline double fmod(double x, double y) { return SDL_fmod(x, y); }
5283
5312inline float fmod(float x, float y) { return SDL_fmodf(x, y); }
5313
5326inline int isinf(double x) { return SDL_isinf(x); }
5327
5340inline int isinf(float x) { return SDL_isinff(x); }
5341
5354inline int isnan(double x) { return SDL_isnan(x); }
5355
5368inline int isnan(float x) { return SDL_isnanf(x); }
5369
5397inline double log(double x) { return SDL_log(x); }
5398
5425inline float log(float x) { return SDL_logf(x); }
5426
5454inline double log10(double x) { return SDL_log10(x); }
5455
5483inline float log10(float x) { return SDL_log10f(x); }
5484
5503inline double modf(double x, double* y) { return SDL_modf(x, y); }
5504
5523inline float modf(float x, float* y) { return SDL_modff(x, y); }
5524
5553inline double pow(double x, double y) { return SDL_pow(x, y); }
5554
5583inline float pow(float x, float y) { return SDL_powf(x, y); }
5584
5612inline double round(double x) { return SDL_round(x); }
5613
5641inline float round(float x) { return SDL_roundf(x); }
5642
5670inline long lround(double x) { return SDL_lround(x); }
5671
5699inline long lround(float x) { return SDL_lroundf(x); }
5700
5724inline double scalbn(double x, int n) { return SDL_scalbn(x, n); }
5725
5749inline float scalbn(float x, int n) { return SDL_scalbnf(x, n); }
5750
5776inline double sin(double x) { return SDL_sin(x); }
5777
5803inline float sin(float x) { return SDL_sinf(x); }
5804
5828inline double sqrt(double x) { return SDL_sqrt(x); }
5829
5853inline float sqrt(float x) { return SDL_sqrtf(x); }
5854
5882inline double tan(double x) { return SDL_tan(x); }
5883
5911inline float tan(float x) { return SDL_tanf(x); }
5912
5924{
5925 IConvRaw m_resource = nullptr;
5926
5927public:
5929 IConv(std::nullptr_t = nullptr) noexcept
5930 : m_resource(IConvRaw(SDL_ICONV_ERROR))
5931 {
5932 }
5933
5941 constexpr explicit IConv(IConvRaw resource) noexcept
5942 : m_resource(resource)
5943 {
5944 }
5945
5947 constexpr IConv(const IConv& other) noexcept = delete;
5948
5950 constexpr IConv(IConv&& other) noexcept
5951 : IConv(other.release())
5952 {
5953 }
5954
5955 constexpr IConv(const IConvRef& other) = delete;
5956
5957 constexpr IConv(IConvRef&& other) = delete;
5958
5975 IConv(StringParam tocode, StringParam fromcode);
5976
5978 ~IConv() { SDL_iconv_close(m_resource); }
5979
5981 constexpr IConv& operator=(IConv&& other) noexcept
5982 {
5983 std::swap(m_resource, other.m_resource);
5984 return *this;
5985 }
5986
5988 IConv& operator=(const IConv& other) = delete;
5989
5991 constexpr IConvRaw get() const noexcept { return m_resource; }
5992
5994 constexpr IConvRaw release() noexcept
5995 {
5996 auto r = m_resource;
5997 m_resource = nullptr;
5998 return r;
5999 }
6000
6002 constexpr auto operator<=>(const IConv& other) const noexcept = default;
6003
6005 explicit operator bool() const noexcept
6006 {
6007 return reinterpret_cast<size_t>(m_resource) != SDL_ICONV_ERROR;
6008 }
6009
6023 int close();
6024
6061 size_t iconv(const char** inbuf,
6062 size_t* inbytesleft,
6063 char** outbuf,
6064 size_t* outbytesleft) const;
6065};
6066
6073{
6074 using IConv::IConv;
6075
6083 constexpr IConvRef(IConvRaw resource) noexcept
6084 : IConv(resource)
6085 {
6086 }
6087
6095 constexpr IConvRef(const IConv& resource) noexcept
6096 : IConv(resource.get())
6097 {
6098 }
6099
6107 constexpr IConvRef(IConv&& resource) noexcept
6108 : IConv(std::move(resource).release())
6109 {
6110 }
6111
6113 constexpr IConvRef(const IConvRef& other) noexcept
6114 : IConv(other.get())
6115 {
6116 }
6117
6119 constexpr IConvRef(IConvRef&& other) noexcept
6120 : IConv(other.get())
6121 {
6122 }
6123
6126
6128 IConvRef& operator=(const IConvRef& other) noexcept
6129 {
6130 release();
6131 IConv::operator=(IConv(other.get()));
6132 return *this;
6133 }
6134
6136 constexpr operator IConvRaw() const noexcept { return get(); }
6137};
6138
6155inline IConv iconv_open(StringParam tocode, StringParam fromcode)
6156{
6157 return IConv(std::move(tocode), std::move(fromcode));
6158}
6159
6160inline IConv::IConv(StringParam tocode, StringParam fromcode)
6161 : m_resource(SDL_iconv_open(tocode, fromcode))
6162{
6163}
6164
6180inline int iconv_close(IConvRaw cd) { return CheckError(SDL_iconv_close(cd)); }
6181
6182inline int IConv::close() { return iconv_close(release()); }
6183
6220inline size_t iconv(IConvRaw cd,
6221 const char** inbuf,
6222 size_t* inbytesleft,
6223 char** outbuf,
6224 size_t* outbytesleft)
6225{
6226 return CheckError(SDL_iconv(cd, inbuf, inbytesleft, outbuf, outbytesleft));
6227}
6228
6229inline size_t IConv::iconv(const char** inbuf,
6230 size_t* inbytesleft,
6231 char** outbuf,
6232 size_t* outbytesleft) const
6233{
6234 return SDL::iconv(m_resource, inbuf, inbytesleft, outbuf, outbytesleft);
6235}
6236
6237constexpr size_t ICONV_ERROR =
6238 SDL_ICONV_ERROR;
6239
6240constexpr size_t ICONV_E2BIG =
6241 SDL_ICONV_E2BIG;
6242
6243constexpr size_t ICONV_EILSEQ =
6244 SDL_ICONV_EILSEQ;
6245
6246constexpr size_t ICONV_EINVAL =
6247 SDL_ICONV_EINVAL;
6248
6273 StringParam fromcode,
6274 SourceBytes inbuf)
6275{
6276 return OwnArray<char>{
6277 SDL_iconv_string(tocode, fromcode, inbuf.data(), inbuf.size_bytes())};
6278}
6279
6294inline OwnArray<char> iconv_utf8_locale(std::string_view S)
6295{
6296 return iconv_string("", "UTF-8", S);
6297}
6298
6313inline OwnArray<Uint16> iconv_utf8_ucs2(std::string_view S)
6314{
6315 auto data = SDL_iconv_string("UCS-2", "UTF-8", S.data(), S.size());
6316 return OwnArray<Uint16>(reinterpret_cast<Uint16*>(data));
6317}
6318
6333inline OwnArray<Uint32> iconv_utf8_ucs4(std::string_view S)
6334{
6335 auto data = SDL_iconv_string("UCS-4", "UTF-8", S.data(), S.size());
6336 return OwnArray<Uint32>(reinterpret_cast<Uint32*>(data));
6337}
6338
6353inline OwnArray<char> iconv_wchar_utf8(std::wstring_view S)
6354{
6355 return iconv_string("UTF-8", "WCHAR_T", S);
6356}
6357
6375inline bool size_mul_check_overflow(size_t a, size_t b, size_t* ret)
6376{
6377 return SDL_size_mul_check_overflow(a, b, ret);
6378}
6379
6397inline bool size_add_check_overflow(size_t a, size_t b, size_t* ret)
6398{
6399 return SDL_size_add_check_overflow(a, b, ret);
6400}
6401
6417using FunctionPointer = void(SDLCALL*)();
6418
6420
6421inline void PtrDeleter::operator()(void* ptr) const { SDL_free(ptr); }
6422
6424template<std::integral T>
6426{
6427 if constexpr (std::is_signed_v<T>) {
6428 SDL_assert_paranoid(value >= std::numeric_limits<Sint32>::min() &&
6429 value <= std::numeric_limits<Sint32>::max());
6430 } else {
6431 SDL_assert_paranoid(value <= std::numeric_limits<Sint32>::max());
6432 }
6433 return static_cast<Sint32>(value);
6434}
6435
6437template<std::integral T>
6439{
6440 SDL_assert_paranoid(value <= std::numeric_limits<Uint32>::max());
6441 return static_cast<Uint32>(value);
6442}
6443
6444} // namespace SDL
6445
6446#endif /* SDL3PP_STDINC_H_ */
A thread-safe set of environment variables.
Definition: SDL3pp_stdinc.h:917
constexpr Environment(EnvironmentRaw resource) noexcept
Constructs from raw Environment.
Definition: SDL3pp_stdinc.h:934
constexpr EnvironmentRaw get() const noexcept
Retrieves underlying EnvironmentRaw.
Definition: SDL3pp_stdinc.h:988
constexpr EnvironmentRaw release() noexcept
Retrieves underlying EnvironmentRaw and clear this.
Definition: SDL3pp_stdinc.h:991
constexpr Environment(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_stdinc.h:922
Uint64 GetVariableCount()
Get the Variables count.
Definition: SDL3pp_stdinc.h:1063
constexpr Environment & operator=(Environment &&other) noexcept
Assignment operator.
Definition: SDL3pp_stdinc.h:978
constexpr auto operator<=>(const Environment &other) const noexcept=default
Comparison.
Environment & operator=(const Environment &other)=delete
Assignment operator.
~Environment()
Destructor.
Definition: SDL3pp_stdinc.h:975
constexpr Environment(Environment &&other) noexcept
Move constructor.
Definition: SDL3pp_stdinc.h:943
constexpr Environment(const Environment &other) noexcept=delete
Copy constructor.
An opaque handle representing string encoding conversion state.
Definition: SDL3pp_stdinc.h:5924
IConv(std::nullptr_t=nullptr) noexcept
Default ctor.
Definition: SDL3pp_stdinc.h:5929
IConv & operator=(const IConv &other)=delete
Assignment operator.
constexpr IConv(const IConv &other) noexcept=delete
Copy constructor.
constexpr IConvRaw get() const noexcept
Retrieves underlying IConvRaw.
Definition: SDL3pp_stdinc.h:5991
constexpr IConv & operator=(IConv &&other) noexcept
Assignment operator.
Definition: SDL3pp_stdinc.h:5981
~IConv()
Destructor.
Definition: SDL3pp_stdinc.h:5978
constexpr IConv(IConvRaw resource) noexcept
Constructs from raw IConv.
Definition: SDL3pp_stdinc.h:5941
constexpr IConvRaw release() noexcept
Retrieves underlying IConvRaw and clear this.
Definition: SDL3pp_stdinc.h:5994
constexpr auto operator<=>(const IConv &other) const noexcept=default
Comparison.
constexpr IConv(IConv &&other) noexcept
Move constructor.
Definition: SDL3pp_stdinc.h:5950
Base class for SDL memory allocated array wrap.
Definition: SDL3pp_ownPtr.h:44
A independent pseudo random state.
Definition: SDL3pp_stdinc.h:4304
constexpr Random(Uint64 state)
Init state with the given value.
Definition: SDL3pp_stdinc.h:4315
float randf()
Generate a uniform pseudo-random floating point number less than 1.0.
Definition: SDL3pp_stdinc.h:4378
constexpr Random()
Default constructor initializes state to zero.
Definition: SDL3pp_stdinc.h:4309
Uint32 rand_bits()
Generate 32 pseudo-random bits.
Definition: SDL3pp_stdinc.h:4401
Sint32 rand(Sint32 n)
Generate a pseudo-random number less than n for positive n.
Definition: SDL3pp_stdinc.h:4354
Source byte stream.
Definition: SDL3pp_strings.h:237
constexpr size_t size_bytes() const
Retrieves contained size in bytes.
Definition: SDL3pp_strings.h:301
constexpr const char * data() const
Retrieves contained data.
Definition: SDL3pp_strings.h:304
Helpers to use C++ strings parameters.
Definition: SDL3pp_strings.h:43
SDL times are signed, 64-bit integers representing nanoseconds since the Unix epoch (Jan 1,...
Definition: SDL3pp_stdinc.h:354
constexpr Sint64 ToNS() const
Converts to nanoseconds Sint64.
Definition: SDL3pp_stdinc.h:408
constexpr Time & operator+=(std::chrono::nanoseconds interval)
Increment time.
Definition: SDL3pp_stdinc.h:482
constexpr float ToSeconds() const
Converts a time to seconds (float) since epoch.
Definition: SDL3pp_stdinc.h:472
constexpr Time & operator-=(std::chrono::nanoseconds interval)
Decrement.
Definition: SDL3pp_stdinc.h:489
constexpr Time(std::chrono::nanoseconds time) noexcept
Wraps Time.
Definition: SDL3pp_stdinc.h:375
constexpr Time(TimeRaw time) noexcept
Wraps Time.
Definition: SDL3pp_stdinc.h:365
static constexpr Time FromNS(Sint64 time)
Create from a nanoseconds Sint64.
Definition: SDL3pp_stdinc.h:402
static constexpr Time FromSeconds(float interval)
Converts a time to seconds (float) since epoch.
Definition: SDL3pp_stdinc.h:475
Concept of interface.
Definition: SDL3pp_stdinc.h:522
#define SDL_assert_paranoid(condition)
An assertion test that is performed only when built with paranoid settings.
Definition: SDL3pp_assert.h:383
constexpr void CheckError(bool result)
Check and throw if returned value from SDL is an error.
Definition: SDL3pp_error.h:199
int wcsncmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
Compare two wide strings up to a number of wchar_t values.
Definition: SDL3pp_stdinc.h:2774
double log(double x)
Compute the natural logarithm of x.
Definition: SDL3pp_stdinc.h:5397
char * UCS4ToUTF8(Uint32 codepoint, char *dst)
Convert a single Unicode codepoint to UTF-8.
Definition: SDL3pp_stdinc.h:4013
long wcstol(const wchar_t *str, wchar_t **endp, int base)
Parse a long from a wide string.
Definition: SDL3pp_stdinc.h:2879
char * strdup(StringParam str)
Allocate a copy of a string.
Definition: SDL3pp_stdinc.h:3038
void SetMemoryFunctions(malloc_func malloc_func, calloc_func calloc_func, realloc_func realloc_func, free_func free_func)
Replace SDL's memory allocation functions with a custom set.
Definition: SDL3pp_stdinc.h:836
double strtod(StringParam str, char **endp)
Parse a double from a string.
Definition: SDL3pp_stdinc.h:3742
void SetVariable(StringParam name, StringParam value, bool overwrite)
Set the value of a variable in the environment.
Definition: SDL3pp_stdinc.h:1317
int(SDLCALL *)(void *userdata, const void *a, const void *b) CompareCallback_r
A callback used with SDL sorting and binary search functions.
Definition: SDL3pp_stdinc.h:1591
constexpr Sint8 MIN_SINT8
Min representable value.
Definition: SDL3pp_stdinc.h:222
char * strcasestr(StringParam haystack, StringParam needle)
Search a UTF-8 string for the first instance of a specific substring, case-insensitively.
Definition: SDL3pp_stdinc.h:3245
void UnsetVariable(StringParam name)
Clear a variable from the environment.
Definition: SDL3pp_stdinc.h:1348
double atan(double x)
Compute the arc tangent of x.
Definition: SDL3pp_stdinc.h:4816
int asprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
This works exactly like asprintf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4238
double ceil(double x)
Compute the ceiling of x.
Definition: SDL3pp_stdinc.h:4944
void SetEnvironmentVariable(EnvironmentRef env, StringParam name, StringParam value, bool overwrite)
Set the value of a variable in the environment.
Definition: SDL3pp_stdinc.h:1309
char * strlwr(char *str)
Convert a string to lowercase.
Definition: SDL3pp_stdinc.h:3129
void * memmove(void *dst, const void *src, size_t len)
Copy memory ranges that might overlap.
Definition: SDL3pp_stdinc.h:2390
int memcmp(const void *s1, const void *s2, size_t len)
Compare two buffers of memory.
Definition: SDL3pp_stdinc.h:2532
constexpr Uint16 MIN_UINT16
Min representable value.
Definition: SDL3pp_stdinc.h:261
constexpr std::size_t arraysize(const T(&array)[N])
The number of elements in a static array.
Definition: SDL3pp_stdinc.h:145
char * strnstr(StringParam haystack, StringParam needle, size_t maxlen)
Search a string, up to n bytes, for the first instance of a specific substring.
Definition: SDL3pp_stdinc.h:3214
OwnArray< Uint16 > iconv_utf8_ucs2(std::string_view S)
Convert a UTF-8 string to UCS-2.
Definition: SDL3pp_stdinc.h:6313
int isnan(double x)
Return whether the value is NaN.
Definition: SDL3pp_stdinc.h:5354
constexpr Uint32 INVALID_UNICODE_CODEPOINT
The Unicode REPLACEMENT CHARACTER codepoint.
Definition: SDL3pp_stdinc.h:3906
double scalbn(double x, int n)
Scale x by an integer power of two.
Definition: SDL3pp_stdinc.h:5724
char * ultoa(unsigned long value, char *str, int radix)
Convert an unsigned long integer into a string.
Definition: SDL3pp_stdinc.h:3457
wchar_t * wcsdup(const wchar_t *wstr)
Allocate a copy of a wide string.
Definition: SDL3pp_stdinc.h:2673
void(SDLCALL *)(void *mem) free_func
A callback used to implement free().
Definition: SDL3pp_stdinc.h:758
int isgraph(int x)
Report if a character is any "printable" except space.
Definition: SDL3pp_stdinc.h:2200
constexpr Sint16 MIN_SINT16
Min representable value.
Definition: SDL3pp_stdinc.h:248
OwnArray< char * > GetVariables()
Get all variables in the environment.
Definition: SDL3pp_stdinc.h:1284
int strncmp(StringParam str1, StringParam str2, size_t maxlen)
Compare two UTF-8 strings up to a number of bytes.
Definition: SDL3pp_stdinc.h:3796
void *(SDLCALL *)(size_t nmemb, size_t size) calloc_func
A callback used to implement calloc().
Definition: SDL3pp_stdinc.h:719
double asin(double x)
Compute the arc sine of x.
Definition: SDL3pp_stdinc.h:4756
Uint16 crc16(Uint16 crc, const void *data, size_t len)
Calculate a CRC-16 value.
Definition: SDL3pp_stdinc.h:2257
char * strrev(char *str)
Reverse a string's contents.
Definition: SDL3pp_stdinc.h:3087
int strncasecmp(StringParam str1, StringParam str2, size_t maxlen)
Compare two UTF-8 strings, case-insensitively, up to a number of bytes.
Definition: SDL3pp_stdinc.h:3867
constexpr T min(T x, U y)
Return the lesser of two values.
Definition: SDL3pp_stdinc.h:1947
unsigned long strtoul(StringParam str, char **endp, int base)
Parse an unsigned long from a string.
Definition: SDL3pp_stdinc.h:3636
void *(SDLCALL *)(void *mem, size_t size) realloc_func
A callback used to implement realloc().
Definition: SDL3pp_stdinc.h:740
::Uint32 Uint32
An unsigned 32-bit integer type.
Definition: SDL3pp_stdinc.h:281
int isdigit(int x)
Report if a character is a numeric digit.
Definition: SDL3pp_stdinc.h:2075
std::chrono::duration< float > Seconds
Duration in seconds (float).
Definition: SDL3pp_stdinc.h:320
double exp(double x)
Compute the exponential of x.
Definition: SDL3pp_stdinc.h:5107
char * strstr(StringParam haystack, StringParam needle)
Search a string for the first instance of a specific substring.
Definition: SDL3pp_stdinc.h:3188
constexpr Uint32 MAX_UINT32
Max representable value.
Definition: SDL3pp_stdinc.h:284
IConv iconv_open(StringParam tocode, StringParam fromcode)
This function allocates a context for the specified character set conversion.
Definition: SDL3pp_stdinc.h:6155
int vsnprintf(char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
This works exactly like vsnprintf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4177
char * strchr(StringParam str, int c)
Search a string for the first instance of a specific byte.
Definition: SDL3pp_stdinc.h:3149
double copysign(double x, double y)
Copy the sign of one floating-point value to another.
Definition: SDL3pp_stdinc.h:4997
Environment CreateEnvironment(bool populated)
Create a set of environment variables.
Definition: SDL3pp_stdinc.h:1222
void * malloc(size_t size)
Allocate uninitialized memory.
Definition: SDL3pp_stdinc.h:593
constexpr float FLT_EPSILON
Epsilon constant, used for comparing floating-point numbers.
Definition: SDL3pp_stdinc.h:512
double modf(double x, double *y)
Split x into integer and fractional parts.
Definition: SDL3pp_stdinc.h:5503
void zero(T &x)
Clear an object's memory to zero.
Definition: SDL3pp_stdinc.h:2467
size_t strlcat(char *dst, StringParam src, size_t maxlen)
Concatenate strings.
Definition: SDL3pp_stdinc.h:3017
void zeroa(T(&x)[N])
Clear an array's memory to zero.
Definition: SDL3pp_stdinc.h:2513
char * strndup(StringParam str, size_t maxlen)
Allocate a copy of a string, up to n characters.
Definition: SDL3pp_stdinc.h:3063
constexpr Uint8 MIN_UINT64
Min representable value.
Definition: SDL3pp_stdinc.h:317
size_t iconv(IConvRaw cd, const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft)
This function converts text between encodings, reading from and writing to a buffer.
Definition: SDL3pp_stdinc.h:6220
std::chrono::milliseconds Milliseconds
Duration in Miliseconds (Uint32).
Definition: SDL3pp_stdinc.h:326
int snprintf(char *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const char *fmt,...)
This works exactly like snprintf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4098
::Uint64 Uint64
An unsigned 64-bit integer type.
Definition: SDL3pp_stdinc.h:311
double round(double x)
Round x to the nearest integer.
Definition: SDL3pp_stdinc.h:5612
int sscanf(StringParam text, SDL_SCANF_FORMAT_STRING const char *fmt,...)
This works exactly like sscanf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4033
size_t strlcpy(char *dst, StringParam src, size_t maxlen)
Copy a string.
Definition: SDL3pp_stdinc.h:2955
void * memset(void *dst, int c, size_t len)
Initialize all bytes of buffer of memory to a specific value.
Definition: SDL3pp_stdinc.h:2417
void(SDLCALL *)() FunctionPointer
A generic function pointer.
Definition: SDL3pp_stdinc.h:6417
constexpr Uint64 MAX_UINT64
Max representable value.
Definition: SDL3pp_stdinc.h:314
bool size_mul_check_overflow(size_t a, size_t b, size_t *ret)
Multiply two integers, checking for overflow.
Definition: SDL3pp_stdinc.h:6375
int iconv_close(IConvRaw cd)
This function frees a context used for character set conversion.
Definition: SDL3pp_stdinc.h:6180
void GetOriginalMemoryFunctions(malloc_func *malloc_func, calloc_func *calloc_func, realloc_func *realloc_func, free_func *free_func)
Get the original set of SDL memory functions.
Definition: SDL3pp_stdinc.h:777
int strcmp(StringParam str1, StringParam str2)
Compare two null-terminated UTF-8 strings.
Definition: SDL3pp_stdinc.h:3764
bool size_add_check_overflow(size_t a, size_t b, size_t *ret)
Add two integers, checking for overflow.
Definition: SDL3pp_stdinc.h:6397
void UnsetEnvironmentVariable(EnvironmentRef env, StringParam name)
Clear a variable from the environment.
Definition: SDL3pp_stdinc.h:1343
char * uitoa(unsigned int value, char *str, int radix)
Convert an unsigned integer into a string.
Definition: SDL3pp_stdinc.h:3397
double pow(double x, double y)
Raise x to the power y
Definition: SDL3pp_stdinc.h:5553
constexpr T * copyp(T *dst, const U *src)
A macro to copy memory between objects, with basic type checking.
Definition: SDL3pp_stdinc.h:2367
constexpr Sint32 MIN_SINT32
Min representable value.
Definition: SDL3pp_stdinc.h:274
EnvironmentRaw GetEnvironment()
Get the process environment.
Definition: SDL3pp_stdinc.h:1200
int isprint(int x)
Report if a character is "printable".
Definition: SDL3pp_stdinc.h:2179
long lround(double x)
Round x to the nearest integer representable as a long.
Definition: SDL3pp_stdinc.h:5670
std::chrono::nanoseconds Nanoseconds
Duration in Nanoseconds (Uint64).
Definition: SDL3pp_stdinc.h:323
int isxdigit(int x)
Report if a character is a hexadecimal digit.
Definition: SDL3pp_stdinc.h:2090
constexpr T max(T x, U y)
Return the greater of two values.
Definition: SDL3pp_stdinc.h:1969
int atoi(StringParam str)
Parse an int from a string.
Definition: SDL3pp_stdinc.h:3547
OwnArray< char > iconv_string(StringParam tocode, StringParam fromcode, SourceBytes inbuf)
Helper function to convert a string's encoding in one call.
Definition: SDL3pp_stdinc.h:6272
int tolower(int x)
Convert low-ASCII English letters to lowercase.
Definition: SDL3pp_stdinc.h:2236
int isalpha(int x)
Query if a character is alphabetic (a letter).
Definition: SDL3pp_stdinc.h:2015
constexpr size_t ICONV_E2BIG
Output buffer was too small.
Definition: SDL3pp_stdinc.h:6240
OwnArray< char > iconv_utf8_locale(std::string_view S)
Convert a UTF-8 string to the current locale's character encoding.
Definition: SDL3pp_stdinc.h:6294
OwnArray< Uint32 > iconv_utf8_ucs4(std::string_view S)
Convert a UTF-8 string to UCS-4.
Definition: SDL3pp_stdinc.h:6333
int unsetenv_unsafe(StringParam name)
Clear a variable from the environment.
Definition: SDL3pp_stdinc.h:1443
constexpr float ToSeconds(Seconds duration)
Converts a time duration to seconds (float).
Definition: SDL3pp_stdinc.h:329
char * strupr(char *str)
Convert a string to uppercase.
Definition: SDL3pp_stdinc.h:3108
::Uint8 Uint8
An unsigned 8-bit integer type.
Definition: SDL3pp_stdinc.h:229
int close()
This function frees a context used for character set conversion.
Definition: SDL3pp_stdinc.h:6182
size_t utf8strlen(StringParam str)
Count the number of codepoints in a UTF-8 string.
Definition: SDL3pp_stdinc.h:3305
constexpr Seconds FromSeconds(float duration)
Converts a float to seconds representation.
Definition: SDL3pp_stdinc.h:332
size_t utf8strnlen(StringParam str, size_t bytes)
Count the number of codepoints in a UTF-8 string, up to n bytes.
Definition: SDL3pp_stdinc.h:3337
int vswprintf(wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt, va_list ap)
This works exactly like vswprintf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4204
int isupper(int x)
Report if a character is upper case.
Definition: SDL3pp_stdinc.h:2145
size_t wcsnlen(const wchar_t *wstr, size_t maxlen)
This works exactly like wcsnlen() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:2591
double sqrt(double x)
Compute the square root of x.
Definition: SDL3pp_stdinc.h:5828
constexpr Sint16 MAX_SINT16
Max representable value.
Definition: SDL3pp_stdinc.h:245
void srand(Uint64 seed)
Seeds the pseudo-random number generator.
Definition: SDL3pp_stdinc.h:4291
constexpr Uint8 MAX_UINT8
Max representable value.
Definition: SDL3pp_stdinc.h:232
double tan(double x)
Compute the tangent of x.
Definition: SDL3pp_stdinc.h:5882
double sin(double x)
Compute the sine of x.
Definition: SDL3pp_stdinc.h:5776
constexpr size_t ICONV_EILSEQ
Invalid input sequence was encountered.
Definition: SDL3pp_stdinc.h:6243
const char * getenv_unsafe(StringParam name)
Get the value of a variable in the environment.
Definition: SDL3pp_stdinc.h:1404
size_t utf8strlcpy(char *dst, StringParam src, size_t dst_bytes)
Copy an UTF-8 string.
Definition: SDL3pp_stdinc.h:2986
constexpr Sint64 MIN_SINT64
Min representable value.
Definition: SDL3pp_stdinc.h:302
::Sint8 Sint8
A signed 8-bit integer type.
Definition: SDL3pp_stdinc.h:216
char * strtok_r(char *str, StringParam delim, char **saveptr)
This works exactly like strtok_r() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:3276
void * memset4(void *dst, Uint32 val, size_t dwords)
Initialize all 32-bit words of buffer of memory to a specific value.
Definition: SDL3pp_stdinc.h:2444
constexpr size_t ICONV_ERROR
Generic error. Check GetError()?
Definition: SDL3pp_stdinc.h:6237
int iscntrl(int x)
Report if a character is a control character.
Definition: SDL3pp_stdinc.h:2060
int swprintf(wchar_t *text, size_t maxlen, SDL_PRINTF_FORMAT_STRING const wchar_t *fmt,...)
This works exactly like swprintf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4144
constexpr double PI_D
The value of Pi, as a double-precision floating point literal.
Definition: SDL3pp_stdinc.h:4660
int islower(int x)
Report if a character is lower case.
Definition: SDL3pp_stdinc.h:2160
int isinf(double x)
Return whether the value is infinity.
Definition: SDL3pp_stdinc.h:5326
int isspace(int x)
Report if a character is whitespace.
Definition: SDL3pp_stdinc.h:2130
void DestroyEnvironment(EnvironmentRaw env)
Destroy a set of environment variables.
Definition: SDL3pp_stdinc.h:1365
size_t strnlen(StringParam str, size_t maxlen)
This works exactly like strnlen() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:2925
int strcasecmp(StringParam str1, StringParam str2)
Compare two null-terminated UTF-8 strings, case-insensitively.
Definition: SDL3pp_stdinc.h:3826
size_t strlen(StringParam str)
This works exactly like strlen() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:2902
constexpr Uint16 MAX_UINT16
Max representable value.
Definition: SDL3pp_stdinc.h:258
const char * GetVariable(StringParam name)
Get the value of a variable in the environment.
Definition: SDL3pp_stdinc.h:1255
const char * getenv(StringParam name)
Get the value of a variable in the environment.
Definition: SDL3pp_stdinc.h:1385
int setenv_unsafe(StringParam name, StringParam value, int overwrite)
Set the value of a variable in the environment.
Definition: SDL3pp_stdinc.h:1425
constexpr void InitInterface(I *iface)
A macro to initialize an SDL interface.
Definition: SDL3pp_stdinc.h:563
void *(SDLCALL *)(size_t size) malloc_func
A callback used to implement malloc().
Definition: SDL3pp_stdinc.h:698
int wcscmp(const wchar_t *str1, const wchar_t *str2)
Compare two null-terminated wide strings.
Definition: SDL3pp_stdinc.h:2742
double acos(double x)
Compute the arc cosine of x.
Definition: SDL3pp_stdinc.h:4698
Sint32 rand(Sint32 n)
Generate a pseudo-random number less than n for positive n.
Definition: SDL3pp_stdinc.h:4434
constexpr Sint64 MAX_SINT64
Max representable value.
Definition: SDL3pp_stdinc.h:299
void qsort_r(void *base, size_t nmemb, size_t size, CompareCallback_r compare, void *userdata)
Sort an array, passing a userdata pointer to the compare function.
Definition: SDL3pp_stdinc.h:1662
double floor(double x)
Compute the floor of x.
Definition: SDL3pp_stdinc.h:5166
Uint32 StepUTF8(const char **pstr, size_t *pslen)
Decode a UTF-8 string, one Unicode codepoint at a time.
Definition: SDL3pp_stdinc.h:3949
int toupper(int x)
Convert low-ASCII English letters to uppercase.
Definition: SDL3pp_stdinc.h:2218
SDL_Time TimeRaw
Alias to raw representation for Time.
Definition: SDL3pp_stdinc.h:42
int(SDLCALL *)(const void *a, const void *b) CompareCallback
A callback used with SDL sorting and binary search functions.
Definition: SDL3pp_stdinc.h:1462
Uint32 murmur3_32(const void *data, size_t len, Uint32 seed)
Calculate a 32-bit MurmurHash3 value for a block of data.
Definition: SDL3pp_stdinc.h:2310
constexpr Uint32 FourCC(Uint8 a, Uint8 b, Uint8 c, Uint8 d)
Define a four character code as a Uint32.
Definition: SDL3pp_stdinc.h:176
Uint32 StepBackUTF8(StringParam start, const char **pstr)
Decode a UTF-8 string in reverse, one Unicode codepoint at a time.
Definition: SDL3pp_stdinc.h:3981
size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t maxlen)
Copy a wide string.
Definition: SDL3pp_stdinc.h:2621
float randf()
Generate a uniform pseudo-random floating point number less than 1.0.
Definition: SDL3pp_stdinc.h:4526
constexpr T clamp(T x, U a, V b)
Return a value clamped to a range.
Definition: SDL3pp_stdinc.h:1997
constexpr Time MAX_TIME
Max allowed time representation.
Definition: SDL3pp_stdinc.h:497
constexpr Nanoseconds FromNS(Sint64 duration)
Converts a Sint64 to nanoseconds representation.
Definition: SDL3pp_stdinc.h:338
SDL_iconv_t IConvRaw
Alias to raw representation for IConv.
Definition: SDL3pp_stdinc.h:60
int wcsncasecmp(const wchar_t *str1, const wchar_t *str2, size_t maxlen)
Compare two wide strings, case-insensitively, up to a number of wchar_t.
Definition: SDL3pp_stdinc.h:2850
void aligned_free(void *mem)
Free memory allocated by aligned_alloc().
Definition: SDL3pp_stdinc.h:888
void zerop(T *x)
Clear an object's memory to zero, using a pointer.
Definition: SDL3pp_stdinc.h:2490
int abs(int x)
Compute the absolute value of x.
Definition: SDL3pp_stdinc.h:1886
void * calloc(size_t nmemb, size_t size)
Allocate a zero-initialized array.
Definition: SDL3pp_stdinc.h:618
void GetMemoryFunctions(malloc_func *malloc_func, calloc_func *calloc_func, realloc_func *realloc_func, free_func *free_func)
Get the current set of SDL memory functions.
Definition: SDL3pp_stdinc.h:803
OwnArray< char * > GetEnvironmentVariables(EnvironmentRef env)
Get all variables in the environment.
Definition: SDL3pp_stdinc.h:1279
void qsort(void *base, size_t nmemb, size_t size, CompareCallback compare)
Sort an array.
Definition: SDL3pp_stdinc.h:1508
constexpr Time MIN_TIME
Min allowed time representation.
Definition: SDL3pp_stdinc.h:500
constexpr Sint64 ToNS(Nanoseconds duration)
Converts a time duration to nanoseconds (Sint64);.
Definition: SDL3pp_stdinc.h:335
int isblank(int x)
Report if a character is blank (a space or tab).
Definition: SDL3pp_stdinc.h:2045
void * realloc(void *mem, size_t size)
Change the size of allocated memory.
Definition: SDL3pp_stdinc.h:659
::Sint64 Sint64
A signed 64-bit integer type.
Definition: SDL3pp_stdinc.h:296
::Sint32 Sint32
A signed 32-bit integer type.
Definition: SDL3pp_stdinc.h:268
int vasprintf(char **strp, SDL_PRINTF_FORMAT_STRING const char *fmt, va_list ap)
This works exactly like vasprintf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4267
char * itoa(int value, char *str, int radix)
Convert an integer into a string.
Definition: SDL3pp_stdinc.h:3367
int ispunct(int x)
Report if a character is a punctuation mark.
Definition: SDL3pp_stdinc.h:2108
int vsscanf(StringParam text, SDL_SCANF_FORMAT_STRING const char *fmt, va_list ap)
This works exactly like vsscanf() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:4061
constexpr Uint8 MIN_UINT8
Min representable value.
Definition: SDL3pp_stdinc.h:235
std::function< int(const void *a, const void *b)> CompareCB
A callback used with SDL sorting and binary search functions.
Definition: SDL3pp_stdinc.h:1608
::Sint16 Sint16
A signed 16-bit integer type.
Definition: SDL3pp_stdinc.h:242
wchar_t * wcsnstr(const wchar_t *haystack, const wchar_t *needle, size_t maxlen)
Search a wide string, up to n wide chars, for the first instance of a specific substring.
Definition: SDL3pp_stdinc.h:2719
Uint32 crc32(Uint32 crc, const void *data, size_t len)
Calculate a CRC-32 value.
Definition: SDL3pp_stdinc.h:2281
double log10(double x)
Compute the base-10 logarithm of x.
Definition: SDL3pp_stdinc.h:5454
const char * GetEnvironmentVariable(EnvironmentRef env, StringParam name)
Get the value of a variable in the environment.
Definition: SDL3pp_stdinc.h:1250
constexpr float PI_F
The value of Pi, as a single-precision floating point literal.
Definition: SDL3pp_stdinc.h:4669
void Destroy()
Destroy a set of environment variables.
Definition: SDL3pp_stdinc.h:1370
wchar_t * wcsstr(const wchar_t *haystack, const wchar_t *needle)
Search a wide string for the first instance of a specific substring.
Definition: SDL3pp_stdinc.h:2693
void * bsearch(const void *key, const void *base, size_t nmemb, size_t size, CompareCallback compare)
Perform a binary search on a previously sorted array.
Definition: SDL3pp_stdinc.h:1565
double cos(double x)
Compute the cosine of x.
Definition: SDL3pp_stdinc.h:5049
void free(void *mem)
Free allocated memory.
Definition: SDL3pp_stdinc.h:679
double atan2(double y, double x)
Compute the arc tangent of y / x, using the signs of x and y to adjust the result's quadrant.
Definition: SDL3pp_stdinc.h:4881
::Uint16 Uint16
An unsigned 16-bit integer type.
Definition: SDL3pp_stdinc.h:255
int wcscasecmp(const wchar_t *str1, const wchar_t *str2)
Compare two null-terminated wide strings, case-insensitively.
Definition: SDL3pp_stdinc.h:2806
char * strpbrk(StringParam str, StringParam breakset)
Searches a string for the first occurrence of any character contained in a breakset,...
Definition: SDL3pp_stdinc.h:3888
void * aligned_alloc(size_t alignment, size_t size)
Allocate memory aligned to a specific alignment.
Definition: SDL3pp_stdinc.h:867
int GetNumAllocations()
Get the number of outstanding (unfreed) allocations.
Definition: SDL3pp_stdinc.h:899
Uint32 rand_bits()
Generate 32 pseudo-random bits.
Definition: SDL3pp_stdinc.h:4601
constexpr Sint8 MAX_SINT8
Max representable value.
Definition: SDL3pp_stdinc.h:219
constexpr Uint8 MIN_UINT32
Min representable value.
Definition: SDL3pp_stdinc.h:287
double trunc(double x)
Truncate x to an integer.
Definition: SDL3pp_stdinc.h:5223
char * ltoa(long value, char *str, int radix)
Convert a long integer into a string.
Definition: SDL3pp_stdinc.h:3427
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t maxlen)
Concatenate wide strings.
Definition: SDL3pp_stdinc.h:2652
double atof(StringParam str)
Parse a double from a string.
Definition: SDL3pp_stdinc.h:3568
constexpr size_t ICONV_EINVAL
Incomplete input sequence was encountered.
Definition: SDL3pp_stdinc.h:6246
constexpr Sint32 MAX_SINT32
Max representable value.
Definition: SDL3pp_stdinc.h:271
void * bsearch_r(const void *key, const void *base, size_t nmemb, size_t size, CompareCallback_r compare, void *userdata)
Perform a binary search on a previously sorted array, passing a userdata pointer to the compare funct...
Definition: SDL3pp_stdinc.h:1792
long strtol(StringParam str, char **endp, int base)
Parse a long from a string.
Definition: SDL3pp_stdinc.h:3601
OwnArray< char > iconv_wchar_utf8(std::wstring_view S)
Convert a wchar_t string to UTF-8.
Definition: SDL3pp_stdinc.h:6353
size_t iconv(const char **inbuf, size_t *inbytesleft, char **outbuf, size_t *outbytesleft) const
This function converts text between encodings, reading from and writing to a buffer.
Definition: SDL3pp_stdinc.h:6229
char * strrchr(StringParam str, int c)
Search a string for the last instance of a specific byte.
Definition: SDL3pp_stdinc.h:3168
size_t wcslen(const wchar_t *wstr)
This works exactly like wcslen() but doesn't require access to a C runtime.
Definition: SDL3pp_stdinc.h:2561
SDL_Environment * EnvironmentRaw
Alias to raw representation for Environment.
Definition: SDL3pp_stdinc.h:51
int isalnum(int x)
Query if a character is alphabetic (a letter) or a number.
Definition: SDL3pp_stdinc.h:2030
double fmod(double x, double y)
Return the floating-point remainder of x / y
Definition: SDL3pp_stdinc.h:5282
void * memcpy(void *dst, const void *src, size_t len)
Copy non-overlapping memory.
Definition: SDL3pp_stdinc.h:2333
static Time FromWindows(Uint32 dwLowDateTime, Uint32 dwHighDateTime)
Converts a Windows FILETIME (100-nanosecond intervals since January 1, 1601) to an SDL time.
Definition: SDL3pp_time.h:411
void ToWindows(Uint32 *dwLowDateTime, Uint32 *dwHighDateTime) const
Converts an SDL time into a Windows FILETIME (100-nanosecond intervals since January 1,...
Definition: SDL3pp_time.h:406
static Time Current()
Gets the current value of the system realtime clock in nanoseconds since Jan 1, 1970 in Universal Coo...
Definition: SDL3pp_time.h:351
constexpr Sint64 ToPosix() const
Convert nanoseconds to seconds.
Definition: SDL3pp_timer.h:31
static constexpr Time FromPosix(Sint64 time)
Convert seconds to nanoseconds.
Definition: SDL3pp_timer.h:26
Main include header for the SDL3pp library.
Uint32 narrowU32(T value)
Narrows to Uint32.
Definition: SDL3pp_stdinc.h:6438
Sint32 narrowS32(T value)
Narrows to Sint32.
Definition: SDL3pp_stdinc.h:6425
Reference for Environment.
Definition: SDL3pp_stdinc.h:1113
constexpr EnvironmentRef(EnvironmentRaw resource) noexcept
Constructs from raw Environment.
Definition: SDL3pp_stdinc.h:1123
constexpr EnvironmentRef(const Environment &resource) noexcept
Constructs from Environment.
Definition: SDL3pp_stdinc.h:1135
EnvironmentRef & operator=(const EnvironmentRef &other) noexcept
Assignment operator.
Definition: SDL3pp_stdinc.h:1168
~EnvironmentRef()
Destructor.
Definition: SDL3pp_stdinc.h:1165
constexpr EnvironmentRef(EnvironmentRef &&other) noexcept
Move constructor.
Definition: SDL3pp_stdinc.h:1159
constexpr EnvironmentRef(Environment &&resource) noexcept
Constructs from Environment.
Definition: SDL3pp_stdinc.h:1147
constexpr EnvironmentRef(const EnvironmentRef &other) noexcept
Copy constructor.
Definition: SDL3pp_stdinc.h:1153
Reference for IConv.
Definition: SDL3pp_stdinc.h:6073
constexpr IConvRef(IConvRef &&other) noexcept
Move constructor.
Definition: SDL3pp_stdinc.h:6119
constexpr IConvRef(const IConv &resource) noexcept
Constructs from IConv.
Definition: SDL3pp_stdinc.h:6095
constexpr IConvRef(IConvRaw resource) noexcept
Constructs from raw IConv.
Definition: SDL3pp_stdinc.h:6083
~IConvRef()
Destructor.
Definition: SDL3pp_stdinc.h:6125
IConvRef & operator=(const IConvRef &other) noexcept
Assignment operator.
Definition: SDL3pp_stdinc.h:6128
constexpr IConvRef(const IConvRef &other) noexcept
Copy constructor.
Definition: SDL3pp_stdinc.h:6113
constexpr IConvRef(IConv &&resource) noexcept
Constructs from IConv.
Definition: SDL3pp_stdinc.h:6107