CFugue
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
E:
WinApp
CarMusTy
src
References
CFugue
include
Common
_TChar.h
1
/*
2
* tchar.h
3
*
4
* Unicode mapping layer for the standard C library. By including this
5
* file and using the 't' names for string functions
6
* (eg. _tprintf) you can make code which can be easily adapted to both
7
* Unicode and non-unicode environments. In a unicode enabled compile define
8
* _UNICODE before including tchar.h, otherwise the standard non-unicode
9
* library functions will be used.
10
*
11
* Note that you still need to include string.h or stdlib.h etc. to define
12
* the appropriate functions. Also note that there are several defines
13
* included for non-ANSI functions which are commonly available (but using
14
* the convention of prepending an underscore to non-ANSI library function
15
* names).
16
*
17
* This file is part of the Mingw32 package.
18
*
19
* Contributors:
20
* Created by Colin Peters <colin@bird.fu.is.saga-u.ac.jp>
21
*
22
* THIS SOFTWARE IS NOT COPYRIGHTED
23
*
24
* This source code is offered for use in the public domain. You may
25
* use, modify or distribute it freely.
26
*
27
* This code is distributed in the hope that it will be useful but
28
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
29
* DISCLAMED. This includes but is not limited to warranties of
30
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
31
*
32
* $Revision: 587 $
33
* $Author: krishnapg $
34
* $Date: 2014-05-10 11:12:21 +0530 (Sat, 10 May 2014) $
35
*
36
* Added ifndef _INC_TCHAR and #ifndef __TCHAR_DEFINED sections
37
* $Revision: 587 $
38
* $Author: krishnapg $
39
* $Date: 2014-05-10 11:12:21 +0530 (Sat, 10 May 2014) $
40
*/
41
42
43
#ifdef _MSC_VER // if this is MS VC Compiler - use the default TChar.h
44
#include <tchar.h>
45
46
#else // if this some other compiler which may not have in-built TCahar.h
47
48
#ifndef _INC_TCHAR // if the standard TChar.h has not been included
49
#ifndef _TCHAR_H_
50
#define _TCHAR_H_
51
52
#include <wchar.h>
// Qt by default uses /Zc:wchar_t- option which make wchar_t an undefined type - hence this #include
53
54
/*
55
* NOTE: This tests _UNICODE, which is different from the UNICODE define
56
* used to differentiate Win32 API calls.
57
*/
58
#ifdef _UNICODE
59
60
#ifndef __TCHAR_DEFINED
61
typedef
wchar_t
_TCHAR;
62
typedef
wchar_t
_TSCHAR;
63
typedef
wchar_t
_TUCHAR;
64
typedef
wchar_t
_TXCHAR;
65
#define __TCHAR_DEFINED
66
#endif
67
68
/*
69
* Use TCHAR instead of char or wchar_t. It will be appropriately translated
70
* if _UNICODE is correctly defined (or not).
71
*/
72
#ifndef _TCHAR_DEFINED
73
#ifndef RC_INVOKED
74
typedef
wchar_t
TCHAR;
75
#endif
/* Not RC_INVOKED */
76
#define _TCHAR_DEFINED
77
#endif
78
79
80
/*
81
* Enclose constant strings and literal characters in the _TEXT and _T macro to make
82
* them unicode constant strings when _UNICODE is defined.
83
*/
84
#define _TEXT(x) L ## x
85
#define _T(x) L ## x
86
87
/* Program */
88
89
#define _tmain wmain
90
#define _tWinMain wWinMain
91
#define _tenviron _wenviron
92
#define __targv __wargv
93
94
/*
95
* Unicode functions
96
*/
97
98
#define _tprintf wprintf
99
#define _ftprintf fwprintf
100
#define _stprintf swprintf
101
#define _sntprintf _snwprintf
102
#define _vtprintf vwprintf
103
#define _vftprintf vfwprintf
104
#define _vstprintf vswprintf
105
#define _vsntprintf _vsnwprintf
106
#define _tscanf wscanf
107
#define _ftscanf fwscanf
108
#define _stscanf swscanf
109
#define _fgettc fgetwc
110
#define _fgettchar _fgetwchar
111
#define _fgetts fgetws
112
#define _fputtc fputwc
113
#define _fputtchar _fputwchar
114
#define _fputts fputws
115
#define _gettc getwc
116
#define _getts getws
117
#define _puttc putwc
118
#define _putts putws
119
#define _ungettc ungetwc
120
#define _tcstod wcstod
121
#define _tcstol wcstol
122
#define _tcstoul wcstoul
123
#define _tcscat wcscat
124
#define _tcschr wcschr
125
#define _tcscmp wcscmp
126
#define _tcscpy wcscpy
127
#define _tcscspn wcscspn
128
#define _tcslen wcslen
129
#define _tcsncat wcsncat
130
#define _tcsncmp wcsncmp
131
#define _tcsncpy wcsncpy
132
#define _tcspbrk wcspbrk
133
#define _tcsrchr wcsrchr
134
#define _tcsspn wcsspn
135
#define _tcsstr wcsstr
136
#define _tcstok wcstok
137
#define _tcsdup wcsdup
138
#if defined __GNUC__ && !defined(_WIN32)
139
#define _tcsicmp wcscasecmp
140
#define _tcsnicmp wcsncasecmp
141
#define _tcstok_s wcstok
142
#elif defined _WIN32
143
#define _tcsicmp _wcsicmp
144
#define _tcsnicmp _wcsnicmp
145
#define _tcstok_s wcstok_s
146
#endif // __GNUC__
147
#define _tcsnset _wcsnset
148
#define _tcsrev _wcsrev
149
#define _tcsset _wcsset
150
#define _tcslwr _wcslwr
151
#define _tcsupr _wcsupr
152
#define _tcsxfrm wcsxfrm
153
#define _tcscoll wcscoll
154
#define _tcsicoll _wcsicoll
155
#define _istalpha iswalpha
156
#define _istupper iswupper
157
#define _istlower iswlower
158
#define _istdigit iswdigit
159
#define _istxdigit iswxdigit
160
#define _istspace iswspace
161
#define _istpunct iswpunct
162
#define _istalnum iswalnum
163
#define _istprint iswprint
164
#define _istgraph iswgraph
165
#define _istcntrl iswcntrl
166
#define _istascii iswascii
167
#define _totupper towupper
168
#define _totlower towlower
169
#define _ttoi _wtoi
170
#define _tcsftime wcsftime
171
172
#else
/* Not _UNICODE */
173
174
#ifndef __TCHAR_DEFINED
175
typedef
char
_TCHAR;
176
typedef
signed
char
_TSCHAR;
177
typedef
unsigned
char
_TUCHAR;
178
typedef
unsigned
char
_TXCHAR;
179
#define __TCHAR_DEFINED
180
#endif
181
182
/*
183
* TCHAR, the type you should use instead of char.
184
*/
185
#ifndef _TCHAR_DEFINED
186
#ifndef RC_INVOKED
187
typedef
char
TCHAR;
188
#endif
189
#define _TCHAR_DEFINED
190
#endif
191
192
/*
193
* Enclose constant strings and characters in the _TEXT and _T macro.
194
*/
195
#define _TEXT(x) x
196
#define _T(x) x
197
198
/* Program */
199
200
#define _tmain main
201
#define _tWinMain WinMain
202
#ifdef _POSIX_
203
#define _tenviron environ
204
#else
205
#define _tenviron _environ
206
#endif
207
#define __targv __argv
208
209
/*
210
* Non-unicode (standard) functions
211
*/
212
213
#define _tprintf printf
214
#define _ftprintf fprintf
215
#define _stprintf sprintf
216
#define _sntprintf _snprintf
217
#define _vtprintf vprintf
218
#define _vftprintf vfprintf
219
#define _vstprintf vsprintf
220
#define _vsntprintf _vsnprintf
221
#define _tscanf scanf
222
#define _ftscanf fscanf
223
#define _stscanf sscanf
224
#define _fgettc fgetc
225
#define _fgettchar _fgetchar
226
#define _fgetts fgets
227
#define _fputtc fputc
228
#define _fputtchar _fputchar
229
#define _fputts fputs
230
#define _gettc getc
231
#define _getts gets
232
#define _puttc putc
233
#define _putts puts
234
#define _ungettc ungetc
235
#define _tcstod strtod
236
#define _tcstol strtol
237
#define _tcstoul strtoul
238
#define _tcscat strcat
239
#define _tcschr strchr
240
#define _tcscmp strcmp
241
#define _tcscpy strcpy
242
#define _tcscspn strcspn
243
#define _tcslen strlen
244
#define _tcsncat strncat
245
#define _tcsncmp strncmp
246
#define _tcsncpy strncpy
247
#define _tcspbrk strpbrk
248
#define _tcsrchr strrchr
249
#define _tcsspn strspn
250
#define _tcsstr strstr
251
#define _tcstok strtok
252
#define _tcsdup _strdup
253
#if defined __GNUC__
254
#include <strings.h>
255
#define _tcsicmp strcasecmp
256
#define _tcsnicmp strncasecmp
257
#elif defined _MSC_VER
258
#define _tcsicmp _stricmp
259
#define _tcsnicmp _strnicmp
260
#endif
261
#define _tcsnset _strnset
262
#define _tcsrev _strrev
263
#define _tcsset _strset
264
#define _tcslwr _strlwr
265
#define _tcsupr _strupr
266
#define _tcsxfrm strxfrm
267
#define _tcscoll strcoll
268
#define _tcsicoll _stricoll
269
#define _istalpha isalpha
270
#define _istupper isupper
271
#define _istlower islower
272
#define _istdigit isdigit
273
#define _istxdigit isxdigit
274
#define _istspace isspace
275
#define _istpunct ispunct
276
#define _istalnum isalnum
277
#define _istprint isprint
278
#define _istgraph isgraph
279
#define _istcntrl iscntrl
280
#define _istascii isascii
281
#define _totupper toupper
282
#define _totlower tolower
283
#define _ttoi atoi
284
#define _tcsftime strftime
285
286
#endif
/* Not _UNICODE */
287
288
289
#if defined __GNUC__
290
#include <ctype.h>
291
#include <wctype.h>
292
inline
TCHAR* _wcsupr(TCHAR* sz)
// GNU does not define _wcsupr, hence our own definition
293
{
294
TCHAR* szRetVal = sz;
// store the original pointer to return
295
while
(*sz != _T(
'\0'
))
296
{
297
*sz = _totupper(*sz);
298
sz++;
299
}
300
return
szRetVal;
301
}
302
#endif
303
304
#endif
/* Not _TCHAR_H_ */
305
#endif // #ifndef _INC_TCHAR
306
307
#endif // ifdef _WINDOWS
CFugue, the C++ Music Programming Library
© Copyright 2009
Cenacle Research India Private Limited
Gopalakrishna Palem