Polygon Crucher SDK - Documentation
Documentation
Loading...
Searching...
No Matches
XStdLib.h
1#if !defined(CEXSTDLIB_INCLUDE_H)
2#define CEXSTDLIB_INCLUDE_H
3
4#ifdef _MSC_VER
5#pragma once
6#endif // _MSC_VER
7
8#ifdef __WINDOWS__
9#include "./win/win_stdlib.h"
10#elif __APPLE__
11#include "./macos/macos_stdlib.h"
12#elif __LINUX__
13#include "./linux/linux_stdlib.h"
14#endif
15
16BEGIN_MOOTOOLS_NAMESPACE
17
18inline void xwmemset(wchar_t *str, wchar_t value, SIZET count)
19{
20 wmemset(str, value, count);
21}
22
23inline void xmemset(void *str, char value, SIZET count)
24{
25 memset(str, value, count);
26}
27
28inline void xwmemmove_s(wchar_t *dst, SIZET dstcount, const wchar_t *src, SIZET srccount)
29{
31}
32
33inline void xmemmove_s(void *dst, SIZET dstcount, const void *src, SIZET srccount)
34{
36}
37
38inline void xwwmemcpy_s(wchar_t *dst, SIZET dstcount, const wchar_t *src, SIZET srccount)
39{
41}
42
43inline void xmemcpy_s(void *dst, SIZET dstcount, const void *src, SIZET srccount)
44{
46}
47
48inline int xmemcmp(const void* buf1, const void* buf2, SIZET count)
49{
50 return memcmp(buf1, buf2, count);
51}
52
53inline SIZET xwstrnlen(const wchar_t *str, SIZET bufsize)
54{
55 return wcsnlen(str, bufsize);
56}
57
58inline SIZET xstrnlen(const char *str, SIZET bufsize)
59{
60 return strnlen(str, bufsize);
61}
62
63inline SIZET xwstrlen(const wchar_t *str)
64{
65 return wcslen(str);
66}
67
68inline SIZET xstrlen(const char *str)
69{
70 return strlen(str);
71}
72
73inline bool xstrcpy_s(char *dst, size_t dstcount, const char *src)
74{
75 return (strcpy_s(dst, dstcount, src) == 0);
76}
77
78inline bool xwstrcpy_s(wchar_t *dst, size_t dstcount, const wchar_t *src)
79{
80 return (wcscpy_s(dst, dstcount, src) == 0);
81}
82
83inline bool xstrcat_s(char *dst, size_t dstcount, const char *src)
84{
85 return (strcat_s(dst, dstcount, src) == 0);
86}
87
88inline bool xwcscat_s(wchar_t *dst, size_t dstcount, const wchar_t *src)
89{
90 return (wcscat_s(dst, dstcount, src) == 0);
91}
92
93inline char *xstrncpy_s(char *dst, size_t dstcount, const char *src, size_t srccount)
94{
96 return dst;
97}
98
99inline wchar_t *xwstrncpy_s(wchar_t *dst, size_t dstcount, const wchar_t *src, size_t srccount)
100{
102 return dst;
103}
104
105inline bool xwstrlwr_s(wchar_t *char1, SIZET charCount)
106{
107 return (_wcslwr_s(char1, charCount) == 0);
108}
109
110inline bool xstrlwr_s(char *char1, SIZET charCount)
111{
112 return (_strlwr_s(char1, charCount) == 0);
113}
114
115inline bool xwstrupr_s(wchar_t *char1, SIZET charCount)
116{
117 return (_wcsupr_s(char1, charCount) == 0);
118}
119
120inline bool xstrupr_s(char *char1, SIZET charCount)
121{
122 return (_strupr_s(char1, charCount) == 0);
123}
124
125inline int xwisspace(wchar_t char1)
126{
127 return iswspace(char1);
128}
129
130inline int xisspace(char char1)
131{
132 return isspace(char1);
133}
134
135inline int xwisalpha(wchar_t char1)
136{
137 return iswalpha(char1);
138}
139
140inline int xisalpha(char char1)
141{
142 return isalpha(char1);
143}
144
145inline int xwtolower(const wchar_t char1)
146{
147 return _towlower_l(char1, NULL);
148}
149
150inline int xtolower(const char char1)
151{
152 return _tolower_l(char1, NULL);
153}
154
155inline int xwtoupper(const wchar_t char1)
156{
157 return _towupper_l(char1, NULL);
158}
159
160inline int xtoupper(const char char1)
161{
162 return _toupper_l(char1, NULL);
163}
164
165inline int xwisdigit(wchar_t c)
166{
167 return iswdigit(c);
168}
169
170inline int xisdigit(int c)
171{
172 return isdigit(c);
173}
174
175inline int xwstrcoll(const wchar_t *char1, const wchar_t *char2)
176{
177 return wcscoll(char1, char2);
178}
179
180inline int xstrcoll(const char *char1, const char *char2)
181{
182 return strcoll(char1, char2);
183}
184
185inline int xwstricoll(const wchar_t *char1, const wchar_t *char2)
186{
187 return _wcsicoll(char1, char2);
188}
189
190inline int xstricoll(const char *char1, const char *char2)
191{
192 return _stricoll(char1, char2);
193}
194
195inline int xwstrcmp(const wchar_t *char1, const wchar_t *char2)
196{
197 return wcscmp(char1, char2);
198}
199
200inline int xstrcmp(const char *char1, const char *char2)
201{
202 return strcmp(char1, char2);
203}
204
205inline int xwstricmp(const wchar_t *char1, const wchar_t *char2)
206{
207 return _wcsicmp(char1, char2);
208}
209
210inline int xstricmp(const char *char1, const char *char2)
211{
212 return _stricmp(char1, char2);
213}
214
215#if !defined(__WINDOWS__) || (_MSC_VER >= 1900)
216inline int xwvscanf_s(const wchar_t *buffer, const wchar_t *format, va_list argptr)
217{
218 return vswscanf_s(buffer, format, argptr);
219}
220
221inline int xvscanf_s(const char *buffer, const char *format, va_list argptr)
222{
223 return vsscanf_s(buffer, format, argptr);
224}
225
226inline int xwvfscanf_s(FILE *stream, const wchar_t *format, va_list argptr)
227{
228 return vfwscanf_s(stream, format, argptr);
229}
230
231inline int xvfscanf_s(FILE *stream, const char *format, va_list argptr)
232{
233 return vfscanf_s(stream, format, argptr);
234}
235#endif
236
237#ifdef __WINDOWS__
238#pragma warning( push )
239#pragma warning( disable : 4996 )
240#endif
241
242inline int xwsprintf(wchar_t *buffer, SIZET count, const wchar_t *format, ...)
243{
245 int result = _vsnwprintf(buffer, count, format, args);
246 va_end(args);
247 return result;
248}
249
250inline int xsprintf(char *buffer, SIZET count, const char *format, ...)
251{
253 int result = _vsnprintf(buffer, count, format, args);
254 va_end(args);
255 return result;
256}
257
258inline int xwvnprintf(wchar_t *buffer, SIZET count, const wchar_t *format, va_list argptr)
259{
260 return _vsnwprintf(buffer, count, format, argptr);
261}
262
263inline int xvnprintf(char *buffer, SIZET count, const char *format, va_list argptr)
264{
265 return _vsnprintf(buffer, count, format, argptr);
266}
267
268inline FILE *xfopen(const char *name, const char *mode)
269{
270 return fopen(name, mode);
271}
272
273inline FILE *xwfopen(const wchar_t *name, const wchar_t *mode)
274{
275 return _wfopen(name, mode);
276}
277
278#ifdef __WINDOWS__
279#pragma warning( pop )
280#endif
281
282inline int xfileno(FILE *stream)
283{
284 return _fileno(stream);
285}
286
287inline FILE *xfdopen(int fd, const char *mode)
288{
289 return _fdopen(fd, mode);
290}
291
292inline FILE *xwfdopen(int fd, const wchar_t *mode)
293{
294 return _wfdopen(fd, mode);
295}
296
297inline int xfclose(FILE *stream)
298{
299 return fclose(stream);
300}
301
302inline int xferror(FILE *stream)
303{
304 return ferror(stream);
305}
306
307inline bool xfputs(const char *str, FILE *stream)
308{
309 return (fputs(str, stream) != EOF);
310}
311
312inline char *xfgets(char *str, int maxcount, FILE *stream)
313{
314 return fgets(str, maxcount, stream);
315}
316
317inline bool xwfputs(const wchar_t *str, FILE *stream)
318{
319 return (fputws(str, stream) != (int)WEOF);
320}
321
322inline wchar_t *xwfgets(wchar_t *str, int maxcount, FILE *stream)
323{
324 return fgetws(str, maxcount, stream);
325}
326
327inline fileuint xftell(FILE *stream)
328{
329 return _ftelli64(stream);
330}
331
332inline fileuint xfseek(FILE *stream, longint offset, int seekmode)
333{
334 return _fseeki64(stream, offset, seekmode);
335}
336
337#ifdef _UNICODE
338 #define xtmemset xwmemset
339 #define xtmemmove_s xwmemmove_s
340 #define xtmemcpy_s xwwmemcpy_s
341 #define xtstrnlen xwstrnlen
342 #define xtstrlen xwstrlen
343 #define xtstrcpy_s xwstrcpy_s
344 #define xtstrncpy_s xwstrncpy_s
345 #define xtstrcat_s xwcscat_s
346 #define xtstrlwr_s xwstrlwr_s
347 #define xtstrupr_s xwstrupr_s
348 #define xtisspace xwisspace
349 #define xtisalpha xwisalpha
350 #define xttolower xwtolower
351 #define xttoupper xwtoupper
352 #define xtisdigit xwisdigit
353 #define xtstrcoll xwstrcoll
354 #define xtstricoll xwstricoll
355 #define xtstrcmp xwstrcmp
356 #define xtstricmp xwstricmp
357 // scanf method is a define (not an inline) in OS overrides because the prototype has ... arguments. Using define allows the compiler to perform checks on the arguments.
358 #define xtscanf xwscanf
359 // scanf_s method is a define (not an inline) in OS overrides because the prototype has ... arguments. Using define allows the compiler to perform checks on the arguments.
360 // Secured version for OS that support it: use SCANS_TEXT_PARAM(string, sizeofbuffer) for text param
361 #define xtscanf_s xwscanf_s
362 #define xtvscanf_s xwvscanf_s
363 #define xtvfscanf_s xwvfscanf_s
364 #define xtsprintf xwsprintf
365 #define xtvnprintf xwvnprintf
366 #define xtfopen xwfopen
367 #define xtfdopen xwfdopen
368 #define xtfgets xwfgets
369 #define xtfputs xwfputs
370#else
371 #define xtmemset xmemset
372 #define xtmemmove_s xmemmove_s
373 #define xtmemcpy_s xmemcpy_s
374 #define xtstrnlen xstrnlen
375 #define xtstrlen xstrlen
376 #define xtstrcpy_s xstrcpy_s
377 #define xtstrncpy_s xstrncpy_s
378 #define xtstrcat_s xstrcat_s
379 #define xtstrlwr_s xstrlwr_s
380 #define xtstrupr_s xstrupr_s
381 #define xtisspace xisspace
382 #define xtisalpha xisalpha
383 #define xttolower xtolower
384 #define xttoupper xtoupper
385 #define xtisdigit xisdigit
386 #define xtstrcoll xstrcoll
387 #define xtstricoll xstricoll
388 #define xtstrcmp xstrcmp
389 #define xtstricmp xstricmp
390 // scanf method is a define (not an inline) in OS overrides because the prototype has ... arguments. Using define allows the compiler to perform checks on the arguments.
391 #define xtscanf xscanf
392 // scanf_s method is a define (not an inline) in OS overrides because the prototype has ... arguments. Using define allows the compiler to perform checks on the arguments.
393 // Secured version for OS that support it: use SCANS_TEXT_PARAM(string, sizeofbuffer) for text param
394 #define xtscanf_s xscanf_s
395 #define xtvscanf_s xvscanf_s
396 #define xtvfscanf_s xvfscanf_s
397 #define xtsprintf xsprintf
398 #define xtvnprintf xvnprintf
399 #define xtfopen fopen
400 #define xtfdopen xfdopen
401 #define xtfgets xfgets
402 #define xtfputs xfputs
403#endif
404
405END_MOOTOOLS_NAMESPACE
406
407
408#endif // !defined(CEXSTDLIB_INCLUDE_H);
The class defines an x, y, z 3D point which can use int, float or double.
Definition 3DPoint.h:27