You.i Engine
YiPredefWin32.h
Go to the documentation of this file.
1 // © You i Labs Inc. 2000-2017. All rights reserved.
2 #ifndef _YI_PREDEF_WIN32_H_
3 #define _YI_PREDEF_WIN32_H_
4 
5 #ifndef WIN32_LEAN_AND_MEAN
6 # define WIN32_LEAN_AND_MEAN
7 #endif
8 
9 #include <windows.h>
10 
11 /*
12  windows.h, by default, will define 'min' and 'max' macros which conflict with the usage of std::numeric_limits<>::min() and max.
13  Defining "NOMINMAX" will prevent windows.h from doing so, but users may include windows.h before this file.
14 
15  In order to ensure that You.i Engine code will always compile, these macros are undefined here.
16 */
17 
18 #ifdef min
19 #undef min
20 #endif
21 #ifdef max
22 #undef max
23 #endif
24 
25 #include <algorithm>
26 #include <cfloat>
27 #include <cstdio>
28 #include <cstdlib>
29 #include <cstring>
30 #include <ctime>
31 #include <ctype.h>
32 #include <fstream>
33 #include <functional>
34 #include <hash_map>
35 #include <iostream>
36 #include <list>
37 #include <map>
38 #include <queue>
39 #include <sstream>
40 #include <stack>
41 #include <vector>
42 
49 #ifdef DEBUG_HEAP
50 #include "mmgr.h" // mmgr.h MUST come next
51 #endif
52 
53 #define YI_HASINLINE
54 
55 // platform-dependant functions
56 // memory
57 #ifdef MEMORY_FAILURE_TEST
58 void *operator new(size_t nSize);
59 void operator delete(void *pBuf);
60 void *operator new [](size_t nSize);
61 void operator delete [](void *pBuf);
62 // needed for log file
63 #define YI_ERRORFILE
64 #else
65 #define YI_SYSTEM_FREE(a) free(a)
66 #define YI_SYSTEM_MALLOC(a) malloc(a)
67 #endif
68 #define YI_SYSTEM_REALLOC(a, b) realloc(a, b)
69 #define YI_MEMCMP(dst, src, size) memcmp(dst, src, size)
70 #define YI_MEMMOVE(dst, src, size) memmove(dst, src, size)
71 #define YI_MEMCOPY(dst, src, size) memcpy(dst, src, size)
72 #define YI_MEMSET(dst, src, size) memset(dst, src, size)
73 
74 // multi-byte string
75 // NOTE: To be used only when absolutely required.
76 // Wide strings are preferred
77 #define YI_STRCAT(a, b) strcat(a, b)
78 #define YI_STRCHR(a, b) strchr(a, b)
79 #define YI_STRCMP(a, b) strcmp(a, b)
80 #define YI_STRCPY(a, b) strcpy(a, b)
81 #define YI_STRREV(a) _strrev(a)
82 #define YI_STRLEN(a) (int32_t) strlen(a)
83 #define YI_STRNCMP(a, b, c) strncmp(a, b, c)
84 #define YI_STRNCPY(a, b, c) strncpy(a, b, c)
85 #define YI_STRNCAT(a, b, c) strncat(a, b, c)
86 #define YI_STRRCHR(a, b) strrchr(a, b)
87 #define YI_STRTOUL(a, b, c) strtoul(a, b, c)
88 #define YI_VSNPRINTF(s, c, f, a) _vsnprintf_s(s, c, _TRUNCATE, f, a)
89 #define YI_STRICMP(a, b) _stricmp(a, b)
90 #define YI_STRNICMP(a, b, c) _strnicmp(a, b, c)
91 #define YI_SPRINTF sprintf
92 #define YI_SNPRINTF(s, c, f, ...) _snprintf_s(s, c, _TRUNCATE, f, __VA_ARGS__)
93 #define YI_ATOI(a) atoi(a)
94 #define YI_ATOF(a) atof(a)
95 
96 // wide string
97 #define YI_WCSCPY(a, b) wcscpy( a, b)
98 #define YI_WCSNCPY(a, b, c) wcsncpy( a, b, (size_t)c)
99 #define YI_WCSCAT(a, b) wcscat( a, b)
100 #define YI_WCSLEN(a) (int32_t) wcslen(a)
101 #define YI_WCSREV(a) _wcsrev( a)
102 #define YI_WCSCMP(a, b) wcscmp( a, b)
103 #define YI_WCSNCMP(a, b, c) wcsncmp( a, b, (size_t)c)
104 #define YI_WCSICMP(a, b) _wcsicmp( a, b)
105 #define YI_WCSNICMP(a, b, c) _wcsnicmp(a, b, (size_t)c)
106 #define YI_WCSNCAT(a, b, c) wcsncat(a, b, (size_t)c)
107 #define YI_WCSSTR WCSSTR
108 #define YI_WCSCHR WCSCHR
109 #define YI_SWPRINTF swprintf
110 
111 
112 #define YI_SLEEP(x) ::Sleep(x)
113 #define YI_USLEEP(x) ::Sleep((DWORD)(x) / 1000)
114 
115 //File handling
116 #define YI_FILE FILE
117 #define YI_FREAD (int32_t) fread
118 #define YI_FWRITE fwrite
119 #define YI_FGETC fgetc
120 #define YI_FPUTC fputc
121 #define YI_FERROR ferror
122 
123 #define YI_KEYCODE_BACK_BUTTON 0x00000008
124 
125 #if defined(YI_UWP)
126 #define YI_HAS_VIRTUAL_KEYBOARD
127 #endif
128 
129 // vs2013 and UWP do not have ssize_t defined
130 #if defined(YI_ENV_64)
131 typedef long long ssize_t;
132 #else
133 typedef int ssize_t;
134 #endif
135 
139 #endif // _YI_PREDEF_WIN32_H_
int ssize_t
Definition: YiPredefWin32.h:133