]> git.saurik.com Git - wxWidgets.git/blob - include/wx/wxchar.h
added ctor for wxChar/WCharBuffer from wxCStrData in ANSI/Unicode build to make it...
[wxWidgets.git] / include / wx / wxchar.h
1 /*
2 * Name: wx/wxchar.h
3 * Purpose: Declarations common to wx char/wchar_t usage (wide chars)
4 * Author: Joel Farley, Ove Kåven
5 * Modified by: Vadim Zeitlin, Robert Roebling, Ron Lee
6 * Created: 1998/06/12
7 * RCS-ID: $Id$
8 * Copyright: (c) 1998-2006 wxWidgets dev team
9 * Licence: wxWindows licence
10 */
11
12 /* THIS IS A C FILE, DON'T USE C++ FEATURES (IN PARTICULAR COMMENTS) IN IT */
13
14 #ifndef _WX_WXCHAR_H_
15 #define _WX_WXCHAR_H_
16
17 /* defs.h indirectly includes this file, so don't include it here */
18 #include "wx/platform.h"
19 #include "wx/dlimpexp.h"
20
21 #ifdef __cplusplus
22 #include "wx/strvararg.h"
23 #else
24 /* make the file compile without doing anything in C code: */
25 #define WX_DEFINE_VARARG_FUNC(rettype, name, impl)
26 #endif
27
28 #include <stdio.h> /* we use FILE below */
29
30 #if defined(HAVE_STRTOK_R) && defined(__DARWIN__) && defined(_MSL_USING_MW_C_HEADERS) && _MSL_USING_MW_C_HEADERS
31 char *strtok_r(char *, const char *, char **);
32 #endif
33
34 /* check whether we have wchar_t and which size it is if we do */
35 #if !defined(wxUSE_WCHAR_T)
36 #if defined(__UNIX__)
37 #if defined(HAVE_WCSTR_H) || defined(HAVE_WCHAR_H) || defined(__FreeBSD__) || defined(__DARWIN__)
38 #define wxUSE_WCHAR_T 1
39 #else
40 #define wxUSE_WCHAR_T 0
41 #endif
42 #elif defined(__GNUWIN32__) && !defined(__MINGW32__)
43 #define wxUSE_WCHAR_T 0
44 #elif defined(__WATCOMC__)
45 #define wxUSE_WCHAR_T 0
46 #elif defined(__VISAGECPP__) && (__IBMCPP__ < 400)
47 #define wxUSE_WCHAR_T 0
48 #else
49 /* add additional compiler checks if this fails */
50 #define wxUSE_WCHAR_T 1
51 #endif
52 #endif /* !defined(wxUSE_WCHAR_T) */
53
54 /* Unicode support requires wchar_t */
55 #if wxUSE_UNICODE && !wxUSE_WCHAR_T
56 #error "wchar_t must be available in Unicode build"
57 #endif /* Unicode */
58
59 /*
60 Standard headers we need here.
61
62 NB: don't include any wxWidgets headers here because almost all of them include
63 this one!
64 */
65
66 /* Required for wxPrintf() etc */
67 #include <stdarg.h>
68
69 /* Almost all compiler have strdup(), but not quite all: CodeWarrior under Mac */
70 /* and VC++ for Windows CE don't provide it */
71 #if defined(__VISUALC__) && __VISUALC__ >= 1400
72 #define wxStrdupA _strdup
73 #elif !(defined(__MWERKS__) && defined(__WXMAC__)) && !defined(__WXWINCE__)
74 /* use #define, not inline wrapper, as it is tested with #ifndef below */
75 #define wxStrdupA strdup
76 #endif
77
78 /*
79 non Unix compilers which do have wchar.h (but not tchar.h which is included
80 below and which includes wchar.h anyhow).
81
82 Actually MinGW has tchar.h, but it does not include wchar.h
83 */
84 #if defined(__MWERKS__) || defined(__VISAGECPP__) || defined(__MINGW32__) || defined(__WATCOMC__)
85 #ifndef HAVE_WCHAR_H
86 #define HAVE_WCHAR_H
87 #endif
88 #endif
89 #if defined(__MWERKS__) && !defined(__MACH__)
90 #ifndef HAVE_WCSLEN
91 #define HAVE_WCSLEN
92 #endif
93 #endif
94
95 #if wxUSE_WCHAR_T
96 #ifdef HAVE_WCHAR_H
97 /* the current (as of Nov 2002) version of cygwin has a bug in its */
98 /* wchar.h -- there is no extern "C" around the declarations in it and */
99 /* this results in linking errors later; also, at least on some */
100 /* Cygwin versions, wchar.h requires sys/types.h */
101 #ifdef __CYGWIN__
102 #include <sys/types.h>
103 #ifdef __cplusplus
104 extern "C" {
105 #endif
106 #endif /* Cygwin */
107
108 #include <wchar.h>
109
110 #if defined(__CYGWIN__) && defined(__cplusplus)
111 }
112 #endif /* Cygwin and C++ */
113
114 #elif defined(HAVE_WCSTR_H)
115 /* old compilers have relevant declarations here */
116 #include <wcstr.h>
117 #elif defined(__FreeBSD__) || defined(__DARWIN__) || defined(__EMX__)
118 /* include stdlib.h for wchar_t */
119 #include <stdlib.h>
120 #endif /* HAVE_WCHAR_H */
121
122 #ifdef HAVE_WIDEC_H
123 #include <widec.h>
124 #endif
125
126 #if !defined(__GNUC__) || defined(__DARWIN__)
127 #define wxWINT_T_IS_TYPEDEF
128 #endif
129 #endif /* wxUSE_WCHAR_T */
130
131 /* ---------------------------------------------------------------------------- */
132 /* define wxHAVE_TCHAR_SUPPORT for the compilers which support the TCHAR type */
133 /* mapped to either char or wchar_t depending on the ASCII/Unicode mode and have */
134 /* the function mapping _tfoo() -> foo() or wfoo() */
135 /* ---------------------------------------------------------------------------- */
136
137 /* VC++ and BC++ starting with 5.2 have TCHAR support */
138 #ifdef __VISUALC__
139 #define wxHAVE_TCHAR_SUPPORT
140 #elif defined(__BORLANDC__) && (__BORLANDC__ >= 0x520)
141 #define wxHAVE_TCHAR_SUPPORT
142 #include <ctype.h>
143 #elif defined(__WATCOMC__)
144 #define wxHAVE_TCHAR_SUPPORT
145 #elif defined(__DMC__)
146 #define wxHAVE_TCHAR_SUPPORT
147 #elif defined(__WXPALMOS__)
148 #include <stddef.h>
149 #elif defined(__MINGW32__) && wxCHECK_W32API_VERSION( 1, 0 )
150 #define wxHAVE_TCHAR_SUPPORT
151 #include <stddef.h>
152 #include <string.h>
153 #include <ctype.h>
154 #elif 0 && defined(__VISAGECPP__) && (__IBMCPP__ >= 400)
155 /* VZ: the old VisualAge definitions were completely wrong and had no */
156 /* chance at all to work in Unicode build anyhow so let's pretend that */
157 /* VisualAge does _not_ support TCHAR for the moment (as indicated by */
158 /* "0 &&" above) until someone really has time to delve into Unicode */
159 /* issues under OS/2 */
160
161 /* VisualAge 4.0+ supports TCHAR */
162 #define wxHAVE_TCHAR_SUPPORT
163 #endif /* compilers with (good) TCHAR support */
164
165 #if defined(__MWERKS__)
166 /* Metrowerks only has wide char support for OS X >= 10.3 */
167 #if !defined(__DARWIN__) || \
168 (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_3)
169 #define wxHAVE_MWERKS_UNICODE
170 #endif
171
172 #ifdef wxHAVE_MWERKS_UNICODE
173 #define HAVE_WPRINTF 1
174 #define HAVE_WCSRTOMBS 1
175 #define HAVE_VSWPRINTF 1
176 #endif
177 #endif /* __MWERKS__ */
178
179 #ifdef wxHAVE_TCHAR_SUPPORT
180 /* get TCHAR definition if we've got it */
181 #include <tchar.h>
182
183 /* we surely do have wchar_t if we have TCHAR */
184 #ifndef wxUSE_WCHAR_T
185 #define wxUSE_WCHAR_T 1
186 #endif /* !defined(wxUSE_WCHAR_T) */
187
188 /* and we also do have wcslen() */
189 #ifndef HAVE_WCSLEN
190 #define HAVE_WCSLEN
191 #endif
192 #endif /* wxHAVE_TCHAR_SUPPORT */
193
194 /* ---------------------------------------------------------------------------- */
195 /* define wxChar type */
196 /* ---------------------------------------------------------------------------- */
197
198 /* TODO: define wxCharInt to be equal to either int or wint_t? */
199
200 #if !wxUSE_UNICODE
201 typedef char wxChar;
202 typedef signed char wxSChar;
203 typedef unsigned char wxUChar;
204 #else /* Unicode */
205 /* VZ: note that VC++ defines _T[SU]CHAR simply as wchar_t and not as */
206 /* signed/unsigned version of it which (a) makes sense to me (unlike */
207 /* char wchar_t is always unsigned) and (b) was how the previous */
208 /* definitions worked so keep it like this */
209
210 /* Sun's SunPro compiler supports the wchar_t type and wide character */
211 /* functions, but does not define __WCHAR_TYPE__. Define it here to */
212 /* allow unicode enabled builds. */
213 #if defined(__SUNPRO_CC) || defined(__SUNPRO_C)
214 #define __WCHAR_TYPE__ wxchar_t
215 #endif
216
217 /* GNU libc has __WCHAR_TYPE__ which requires special treatment, see */
218 /* comment below */
219 #if !defined(__WCHAR_TYPE__) || \
220 (!defined(__GNUC__) || wxCHECK_GCC_VERSION(2, 96))
221 /* standard case */
222 typedef wchar_t wxChar;
223 typedef wchar_t wxSChar;
224 typedef wchar_t wxUChar;
225 #else /* __WCHAR_TYPE__ and gcc < 2.96 */
226 /* VS: wxWidgets used to define wxChar as __WCHAR_TYPE__ here. */
227 /* However, this doesn't work with new GCC 3.x compilers because */
228 /* wchar_t is C++'s builtin type in the new standard. OTOH, old */
229 /* compilers (GCC 2.x) won't accept new definition of */
230 /* wx{S,U}CharType, so we have to define wxChar */
231 /* conditionally depending on detected compiler & compiler */
232 /* version. */
233
234 /* with old definition of wxChar. */
235 #define wchar_t __WCHAR_TYPE__
236 typedef __WCHAR_TYPE__ wxChar;
237 typedef __WCHAR_TYPE__ wxSChar;
238 typedef __WCHAR_TYPE__ wxUChar;
239 #endif /* __WCHAR_TYPE__ */
240 #endif /* ASCII/Unicode */
241
242 /* ---------------------------------------------------------------------------- */
243 /* define _T() and related macros */
244 /* ---------------------------------------------------------------------------- */
245
246 /* BSD systems define _T() to be something different in ctype.h, override it */
247 #if defined(__FreeBSD__) || defined(__DARWIN__)
248 #include <ctype.h>
249 #undef _T
250 #endif
251
252 /* could already be defined by tchar.h (it's quasi standard) */
253 #ifndef _T
254 #if !wxUSE_UNICODE
255 #define _T(x) x
256 #else /* Unicode */
257 /* use wxCONCAT_HELPER so that x could be expanded if it's a macro */
258 #define _T(x) wxCONCAT_HELPER(L, x)
259 #endif /* ASCII/Unicode */
260 #endif /* !defined(_T) */
261
262 /* although global macros with such names are normally bad, we want to have */
263 /* another name for _T() which should be used to avoid confusion between _T() */
264 /* and _() in wxWidgets sources */
265 #define wxT(x) _T(x)
266
267 /* a helper macro allowing to make another macro Unicode-friendly, see below */
268 #define wxAPPLY_T(x) _T(x)
269
270 /* Unicode-friendly __FILE__, __DATE__ and __TIME__ analogs */
271 #ifndef __TFILE__
272 #define __TFILE__ wxAPPLY_T(__FILE__)
273 #endif
274
275 #ifndef __TDATE__
276 #define __TDATE__ wxAPPLY_T(__DATE__)
277 #endif
278
279 #ifndef __TTIME__
280 #define __TTIME__ wxAPPLY_T(__TIME__)
281 #endif
282
283 /*
284 define wxFoo() function for each standard foo() function whose signature
285 (exceptionally including the return type) includes any mention of char:
286 wxFoo() is going to be a Unicode-friendly version of foo(), i.e. will have
287 the same signature but with char replaced by wxChar which allows us to
288 use it in Unicode build as well
289 */
290
291 #ifdef wxHAVE_TCHAR_SUPPORT
292 #include <ctype.h>
293
294 #if defined(__WATCOMC__) && defined(UNICODE)
295 #define WXWCHAR_T_CAST(c) (wint_t)(c)
296 #else
297 #define WXWCHAR_T_CAST(c) c
298 #endif
299
300 /* ctype.h functions */
301 #define wxIsalnum(c) _istalnum(WXWCHAR_T_CAST(c))
302 #define wxIsalpha(c) _istalpha(WXWCHAR_T_CAST(c))
303 #define wxIscntrl(c) _istcntrl(WXWCHAR_T_CAST(c))
304 #define wxIsdigit(c) _istdigit(WXWCHAR_T_CAST(c))
305 #define wxIsgraph(c) _istgraph(WXWCHAR_T_CAST(c))
306 #define wxIslower(c) _istlower(WXWCHAR_T_CAST(c))
307 #define wxIsprint(c) _istprint(WXWCHAR_T_CAST(c))
308 #define wxIspunct(c) _istpunct(WXWCHAR_T_CAST(c))
309 #define wxIsspace(c) _istspace(WXWCHAR_T_CAST(c))
310 #define wxIsupper(c) _istupper(WXWCHAR_T_CAST(c))
311 #define wxIsxdigit(c) _istxdigit(WXWCHAR_T_CAST(c))
312
313 /*
314 There is a bug in VC6 C RTL: toxxx() functions dosn't do anything with
315 signed chars < 0, so "fix" it here.
316 */
317 #define wxTolower(c) _totlower((wxUChar)(wxChar)(c))
318 #define wxToupper(c) _totupper((wxUChar)(wxChar)(c))
319
320 /* locale.h functons */
321 #define wxSetlocale _tsetlocale
322
323 /* string.h functions */
324 #define wxStrcat _tcscat
325 #define wxStrchr _tcschr
326 #define wxStrcmp _tcscmp
327 #define wxStrcoll _tcscoll
328 #define wxStrcpy _tcscpy
329 #define wxStrcspn _tcscspn
330 #define wxStrdupW _wcsdup /* notice the 'W'! */
331 #define wxStrftime _tcsftime
332 #define wxStricmp _tcsicmp
333 #define wxStrnicmp _tcsnicmp
334 #define wxStrlen_ _tcslen /* used in wxStrlen inline function */
335 #define wxStrncat _tcsncat
336 #define wxStrncmp _tcsncmp
337 #define wxStrncpy _tcsncpy
338 #define wxStrpbrk _tcspbrk
339 #define wxStrrchr _tcsrchr
340 #define wxStrspn _tcsspn
341 #define wxStrstr _tcsstr
342 #define wxStrtod _tcstod
343 #define wxStrtol _tcstol
344 #define wxStrtoul _tcstoul
345 #ifdef __VISUALC__
346 #if __VISUALC__ >= 1300 && !defined(__WXWINCE__)
347 #define wxStrtoll _tcstoi64
348 #define wxStrtoull _tcstoui64
349 #endif /* VC++ 7+ */
350 #endif
351 #define wxStrxfrm _tcsxfrm
352
353 /* stdio.h functions */
354 #define wxFgetc _fgettc
355 #define wxFgetchar _fgettchar
356 #define wxFgets _fgetts
357 #if wxUSE_UNICODE_MSLU
358 WXDLLIMPEXP_BASE FILE * wxMSLU__tfopen(const wxChar *name, const wxChar *mode);
359
360 #define wxFopen wxMSLU__tfopen
361 #else
362 #define wxFopen _tfopen
363 #endif
364 #define wxFputc _fputtc
365 #define wxFputchar _fputtchar
366 WX_DEFINE_VARARG_FUNC(int, wxFprintf, _ftprintf)
367 #define wxFputs _fputts
368 #define wxFreopen _tfreopen
369 #define wxFscanf _ftscanf
370 #define wxGetc _gettc
371 #define wxGetchar _gettchar
372 #define wxGets _getts
373 #define wxPerror _tperror
374 WX_DEFINE_VARARG_FUNC(int, wxPrintf, _tprintf)
375 #define wxPutc(c,f) _puttc(WXWCHAR_T_CAST(c),f)
376 #define wxPutchar _puttchar
377 #define wxPuts _putts
378 #define wxScanf _tscanf
379 #if defined(__DMC__)
380 #if wxUSE_UNICODE
381 /* Digital Mars adds count to _stprintf (C99) so prototype conversion see wxchar.cpp */
382 int wxDoSprintf (wchar_t * __RESTRICT s, const wchar_t * __RESTRICT format, ... ) ;
383 WX_DEFINE_VARARG_FUNC(int, wxSprintf, wxDoSprintf)
384 #else
385 /* and there is a bug in D Mars tchar.h prior to 8.39.4n, so define as sprintf */
386 WX_DEFINE_VARARG_FUNC(int, wxSprintf, sprintf)
387 #endif
388 #else
389 WX_DEFINE_VARARG_FUNC(int, wxSprintf, _stprintf)
390 #endif
391
392 #define wxSscanf _stscanf
393 #define wxTmpnam _ttmpnam
394 #define wxUngetc _tungetc
395 #define wxVfprintf _vftprintf
396 #define wxVprintf _vtprintf
397 #define wxVsscanf _vstscanf
398 #define wxVsprintf _vstprintf
399
400 /* special case: these functions are missing under Win9x with Unicows so we */
401 /* have to implement them ourselves */
402 #if wxUSE_UNICODE_MSLU
403 WXDLLIMPEXP_BASE int wxMSLU__trename(const wxChar *oldname, const wxChar *newname);
404 WXDLLIMPEXP_BASE int wxMSLU__tremove(const wxChar *name);
405
406 #define wxRemove wxMSLU__tremove
407 #define wxRename wxMSLU__trename
408 #else
409 #ifdef __WXWINCE__
410 /* carefully: wxRemove() must return 0 on success while DeleteFile()
411 returns 0 on error, so don't just define one as the other */
412 int wxRemove(const wxChar *path);
413 #else
414 #define wxRemove _tremove
415 #define wxRename _trename
416 #endif
417 #endif
418
419 /* stdlib.h functions */
420 #define wxAtoi _ttoi
421 #define wxAtol _ttol
422 /* #define wxAtof _tttof -- notice that there is no such thing (why?) */
423 /* there are no env vars at all under CE, so no _tgetenv neither */
424 #ifdef __WXWINCE__
425 /* can't define as inline function as this is a C file... */
426 #define wxGetenv(name) ((wxChar *)NULL)
427 #else
428 #define wxGetenv _tgetenv
429 #endif
430 #define wxSystem _tsystem
431
432 /* time.h functions */
433 #define wxAsctime _tasctime
434 #define wxCtime _tctime
435
436 #define wxMbstowcs mbstowcs
437 #define wxWcstombs wcstombs
438 #else /* !TCHAR-aware compilers */
439 /*
440 There are 2 unrelated problems with these functions under Mac:
441 a) Metrowerks MSL CRT implements them strictly in C99 sense and
442 doesn't support (very common) extension of allowing to call
443 mbstowcs(NULL, ...) which makes it pretty useless as you can't
444 know the size of the needed buffer
445 b) OS X <= 10.2 declares and even defined these functions but
446 doesn't really implement them -- they always return an error
447
448 So use our own replacements in both cases.
449 */
450 #if defined(__MWERKS__) && defined(__MSL__)
451 #define wxNEED_WX_MBSTOWCS
452 #endif
453
454 #ifdef __DARWIN__
455 #if MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2
456 #define wxNEED_WX_MBSTOWCS
457 #endif
458 #endif
459
460 #ifdef wxNEED_WX_MBSTOWCS
461 /* even though they are defined and "implemented", they are bad and just
462 stubs so we need our own - we need these even in ANSI builds!! */
463 WXDLLIMPEXP_BASE size_t wxMbstowcs (wchar_t *, const char *, size_t);
464 WXDLLIMPEXP_BASE size_t wxWcstombs (char *, const wchar_t *, size_t);
465 #else
466 #define wxMbstowcs mbstowcs
467 #define wxWcstombs wcstombs
468 #endif
469
470 /*
471 The system C library on Mac OS X 10.2 and below does not support
472 unicode: in other words all wide-character functions such as towupper et
473 al. do simply not exist so we need to provide our own in that context,
474 except for the wchar_t definition/typedef itself.
475
476 We need to do this for both project builder and CodeWarrior as
477 the latter uses the system C library in Mach builds for wide character
478 support, which as mentioned does not exist on 10.2 and below.
479 */
480 #if wxUSE_UNICODE && \
481 defined(__DARWIN__) && \
482 ( MAC_OS_X_VERSION_MAX_ALLOWED <= MAC_OS_X_VERSION_10_2 )
483 /* we need everything! */
484 #define wxNEED_WX_STRING_H
485 #define wxNEED_WX_CTYPE_H
486
487 #define wxFgetchar(c) wxFgetc(c, stdin)
488 #define wxFputc wxPutc
489 #define wxFputchar(c) wxPutc(c, stdout)
490 #define wxGetc wxFgetc
491 #define wxGetchar(c) wxFgetc(c, stdin)
492
493 #include <stdio.h>
494
495 #define wxNEED_FGETC
496 #define wxNEED_FGETS
497 #define wxNEED_GETS
498 #define wxNEED_UNGETC
499
500 #define wxNEED_FPUTS
501 #define wxNEED_PUTS
502 #define wxNEED_PUTC
503
504 int wxFputs(const wxChar *ch, FILE *stream);
505 int wxPuts(const wxChar *ws);
506 int wxPutc(wxChar ch, FILE *stream);
507
508 #ifdef __cplusplus
509 extern "C" {
510 #endif
511 WXDLLIMPEXP_BASE size_t wxStrlen_(const wxChar *s);
512 #ifdef __cplusplus
513 }
514 #endif
515
516 #define wxPutchar(wch) wxPutc(wch, stdout)
517
518 #define wxNEED_PRINTF_CONVERSION
519 #define wxNEED_WX_STDIO_H
520 #define wxNEED_WX_STDLIB_H
521 #define wxNEED_WX_TIME_H
522
523 #elif wxUSE_UNICODE
524 #include <wctype.h>
525
526 /* this is probably glibc-specific */
527 #if defined(__WCHAR_TYPE__) && !defined(__MWERKS__)
528 /* ctype.h functions (wctype.h) */
529 #define wxIsalnum iswalnum
530 #define wxIsalpha iswalpha
531 #define wxIscntrl iswcntrl
532 #define wxIsdigit iswdigit
533 #define wxIsgraph iswgraph
534 #define wxIslower iswlower
535 #define wxIsprint iswprint
536 #define wxIspunct iswpunct
537 #define wxIsspace iswspace
538 #define wxIsupper iswupper
539 #define wxIsxdigit iswxdigit
540
541 #if defined(__GLIBC__) && (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
542 /* /usr/include/wctype.h incorrectly declares translations */
543 /* tables which provokes tons of compile-time warnings -- try */
544 /* to correct this */
545 #define wxTolower(wc) towctrans((wc), (wctrans_t)__ctype_tolower)
546 #define wxToupper(wc) towctrans((wc), (wctrans_t)__ctype_toupper)
547 #else /* !glibc 2.0 */
548 #define wxTolower towlower
549 #define wxToupper towupper
550 #endif /* gcc/!gcc */
551
552 /* string.h functions (wchar.h) */
553 #define wxStrcat wcscat
554 #define wxStrchr wcschr
555 #define wxStrcmp wcscmp
556 #define wxStrcoll wcscoll
557 #define wxStrcpy wcscpy
558 #define wxStrcspn wcscspn
559 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
560 #define wxStrncat wcsncat
561 #define wxStrncmp wcsncmp
562 #define wxStrncpy wcsncpy
563 #define wxStrpbrk wcspbrk
564 #define wxStrrchr wcsrchr
565 #define wxStrspn wcsspn
566 #define wxStrstr wcsstr
567 #define wxStrtod wcstod
568 #define wxStrtol wcstol
569 #define wxStrtoul wcstoul
570 #ifdef HAVE_WCSTOULL
571 /* assume that we have wcstoull(), which is also C99, too */
572 #define wxStrtoll wcstoll
573 #define wxStrtoull wcstoull
574 #endif /* HAVE_WCSTOULL */
575 #define wxStrxfrm wcsxfrm
576
577 #define wxFgetc fgetwc
578 #define wxFgetchar fgetwchar
579 #define wxFgets fgetws
580 #define wxFputc fputwc
581 #define wxFputchar fputwchar
582 #define wxGetc getwc
583 #define wxGetchar getwchar
584 #define wxGets getws
585 #define wxUngetc ungetwc
586
587 #ifdef HAVE_FPUTWS
588 #define wxFputs fputws
589 #else
590 #define wxNEED_FPUTS
591 #include <stdio.h>
592 int wxFputs(const wxChar *ch, FILE *stream);
593 #endif
594
595 #ifdef HAVE_WPUTC
596 #define wxPutc wputc
597 #else
598 #define wxNEED_PUTC
599 #include <stdio.h>
600 int wxPutc(wxChar ch, FILE *stream);
601 #endif
602
603 #ifdef HAVE_WPUTCHAR
604 #define wxPutchar wputchar
605 #else
606 #define wxPutchar(wch) wxPutc(wch, stdout)
607 #endif
608
609 #ifdef HAVE_PUTWS
610 #define wxPuts putws
611 #else
612 #define wxNEED_PUTS
613 int wxPuts(const wxChar *ws);
614 #endif
615
616 /* we need %s to %ls conversion for printf and scanf etc */
617 #define wxNEED_PRINTF_CONVERSION
618
619 /* glibc doesn't have wide char equivalents of the other stuff so */
620 /* use our own versions */
621 #define wxNEED_WX_STDIO_H
622 #define wxNEED_WX_STDLIB_H
623 #define wxNEED_WX_TIME_H
624 #elif defined(__MWERKS__) && ( defined(__MSL__) || defined(__MACH__) )
625 /* ctype.h functions (wctype.h) */
626 #define wxIsalnum iswalnum
627 #define wxIsalpha iswalpha
628 #define wxIscntrl iswcntrl
629 #define wxIsdigit iswdigit
630 #define wxIsgraph iswgraph
631 #define wxIslower iswlower
632 #define wxIsprint iswprint
633 #define wxIspunct iswpunct
634 #define wxIsspace iswspace
635 #define wxIsupper iswupper
636 #define wxIsxdigit iswxdigit
637 #define wxTolower towlower
638 #define wxToupper towupper
639
640 /* string.h functions (wchar.h) */
641 #define wxStrcat wcscat
642 #define wxStrchr wcschr
643 #define wxStrcmp wcscmp
644 #define wxStrcoll wcscoll
645 #define wxStrcpy wcscpy
646 #define wxStrcspn wcscspn
647 #define wxStrlen_ wxWcslen /* wxStrlen_() is used in wxStrlen() */
648 #define wxStrncat wcsncat
649 #define wxStrncmp wcsncmp
650 #define wxStrncpy wcsncpy
651 #define wxStrpbrk wcspbrk
652 #define wxStrrchr wcsrchr
653 #define wxStrspn wcsspn
654 #define wxStrstr wcsstr
655 #define wxStrtod wcstod
656 #define wxStrtol wcstol
657 #define wxStrtoul wcstoul
658 #define wxStrxfrm wcsxfrm
659
660 #define wxFgetc fgetwc
661 #define wxFgetchar fgetwchar
662 #define wxFgets fgetws
663 #define wxFputc fputwc
664 #define wxFputchar fputwchar
665 #define wxGetc getwc
666 #define wxGetchar getwchar
667 #define wxGets getws
668 #define wxUngetc ungetwc
669
670 #define wxNEED_PRINTF_CONVERSION
671
672 #define wxPutc putwc
673 #define wxPutchar putwchar
674 #define wxFputs fputws
675
676 /* stdio.h functions */
677
678 #define wxNEED_WX_STDIO_H
679
680 /* stdlib.h functions */
681 #ifdef __MACH__
682 #define wxNEED_WX_STDLIB_H
683 #else
684 #define wxAtof watof
685 #define wxAtoi watoi
686 #define wxAtol watol
687 #define wxGetenv(a) ((wxChar*)NULL)
688 #define wxSystem(a) ((int)NULL)
689 #endif
690 /* time.h functions */
691 #define wxAsctime wasciitime
692 #define wxCtime wctime
693 /* #define wxStrftime wcsftime */
694
695 #define wxNEED_WX_TIME_H
696 #else /* !metrowerks for apple */
697 #error "Please define wide character functions for your environment"
698 #endif
699 #else /* ASCII */
700 #include <ctype.h>
701 #include <string.h>
702
703 /* ctype.h functions */
704 #define wxIsalnum isalnum
705 #define wxIsalpha isalpha
706 #define wxIscntrl iscntrl
707 #define wxIsdigit isdigit
708 #define wxIsgraph isgraph
709 #define wxIslower islower
710 #define wxIsprint isprint
711 #define wxIspunct ispunct
712 #define wxIsspace isspace
713 #define wxIsupper isupper
714 #define wxIsxdigit isxdigit
715 #define wxTolower tolower
716 #define wxToupper toupper
717
718 /* locale.h functons */
719 #define wxSetlocale setlocale
720
721 /* string.h functions */
722 #define wxStrcat strcat
723 #define wxStrchr strchr
724 #define wxStrcmp strcmp
725 #define wxStrcoll strcoll
726 #define wxStrcpy strcpy
727 #define wxStrcspn strcspn
728
729 /* wxStricmp and wxStrnicmp are defined below */
730 #define wxStrlen_ strlen /* used in wxStrlen inline function */
731 #define wxStrncat strncat
732 #define wxStrncmp strncmp
733 #define wxStrncpy strncpy
734 #define wxStrpbrk strpbrk
735 #define wxStrrchr strrchr
736 #define wxStrspn strspn
737 #define wxStrstr strstr
738 #define wxStrtod strtod
739 #ifdef HAVE_STRTOK_R
740 #define wxStrtok(str, sep, last) strtok_r(str, sep, last)
741 #endif
742 #define wxStrtol strtol
743 #define wxStrtoul strtoul
744 #ifdef HAVE_STRTOULL
745 /* assume that we have wcstoull(), which is also C99, too */
746 #define wxStrtoll strtoll
747 #define wxStrtoull strtoull
748 #endif /* HAVE_WCSTOULL */
749 #define wxStrxfrm strxfrm
750
751 /* stdio.h functions */
752 #define wxFopen fopen
753 #define wxFreopen freopen
754 #define wxRemove remove
755 #define wxRename rename
756
757 #define wxPerror perror
758 #define wxTmpnam tmpnam
759
760 #define wxFgetc fgetc
761 #define wxFgetchar fgetchar
762 #define wxFgets fgets
763 #define wxFputc fputc
764 #define wxFputs fputs
765 #define wxFputchar fputchar
766 WX_DEFINE_VARARG_FUNC(int, wxFprintf, fprintf)
767 #define wxFscanf fscanf
768 #define wxGetc getc
769 #define wxGetchar getchar
770 #define wxGets gets
771 WX_DEFINE_VARARG_FUNC(int, wxPrintf, printf)
772 #define wxPutc putc
773 #define wxPutchar putchar
774 #define wxPuts puts
775 #define wxScanf scanf
776 WX_DEFINE_VARARG_FUNC(int, wxSprintf, sprintf)
777 #define wxSscanf sscanf
778 #define wxUngetc ungetc
779 #define wxVfprintf vfprintf
780 #define wxVprintf vprintf
781 #define wxVsscanf vsscanf
782 #define wxVsprintf vsprintf
783
784 /* stdlib.h functions */
785 #define wxAtof atof
786 #define wxAtoi atoi
787 #define wxAtol atol
788 #define wxGetenv getenv
789 #define wxSystem system
790
791 /* time.h functions */
792 #define wxAsctime asctime
793 #define wxCtime ctime
794 #define wxStrftime strftime
795 #endif /* Unicode/ASCII */
796 #endif /* TCHAR-aware compilers/the others */
797
798 #ifdef wxStrtoll
799 #define wxHAS_STRTOLL
800 #endif
801
802 /*
803 various special cases
804 */
805
806 /* define wxStricmp and wxStrnicmp for various compilers */
807
808 /* note that in Unicode mode we definitely are going to need our own version */
809 #if !defined(wxStricmp) && !wxUSE_UNICODE
810 #if defined(__BORLANDC__) || defined(__WATCOMC__) || \
811 defined(__SALFORDC__) || defined(__VISAGECPP__) || \
812 defined(__EMX__) || defined(__DJGPP__)
813 #define wxStricmp stricmp
814 #define wxStrnicmp strnicmp
815 #elif defined(__WXPALMOS__)
816 /* FIXME: There is no equivalent to strnicmp in the Palm OS API. This
817 * quick hack should do until one can be written.
818 */
819 #define wxStricmp StrCaselessCompare
820 #define wxStrnicmp strnicmp
821 #elif defined(__SYMANTEC__) || defined(__VISUALC__) || \
822 (defined(__MWERKS__) && defined(__INTEL__))
823 #define wxStricmp _stricmp
824 #define wxStrnicmp _strnicmp
825 #elif defined(__UNIX__) || defined(__GNUWIN32__)
826 #define wxStricmp strcasecmp
827 #define wxStrnicmp strncasecmp
828 /* #else -- use wxWidgets implementation */
829 #endif
830 #endif /* !defined(wxStricmp) */
831
832 /* define wxWcslen() which should be always available if wxUSE_WCHAR_T == 1 (as */
833 /* it's used in wx/buffer.h -- and also might be used just below by wxStrlen() */
834 /* when wxStrlen_() is #define'd as wxWcslen so do it before defining wxStrlen) */
835 #if wxUSE_WCHAR_T
836 #ifdef HAVE_WCSLEN
837 #define wxWcslen wcslen
838 #else
839 WXDLLIMPEXP_BASE size_t wxWcslen(const wchar_t *s);
840 #endif
841 #endif /* wxUSE_WCHAR_T */
842
843 #ifdef __cplusplus
844 /* checks whether the passed in pointer is NULL and if the string is empty */
845 inline bool wxIsEmpty(const wxChar *p) { return !p || !*p; }
846
847 /* safe version of strlen() (returns 0 if passed NULL pointer) */
848 inline size_t wxStrlen(const wxChar *psz) { return psz ? wxStrlen_(psz) : 0; }
849 #endif
850
851 /*
852 each of strdup() and wcsdup() may or may not be available but we need both
853 of them anyhow for wx/buffer.h so we define the missing one(s) in
854 wxchar.cpp and so we should always have both wxStrdupA and wxStrdupW
855 defined -- if this is somehow not the case in some situations, please
856 correct that and not the lines here
857 */
858 #if wxUSE_UNICODE
859 #define wxStrdup wxStrdupW
860 #else
861 #define wxStrdup wxStrdupA
862 #endif
863
864 #ifdef __cplusplus
865 WXDLLIMPEXP_BASE bool wxOKlibc(); /* for internal use */
866 #endif
867
868 /* printf() family saga */
869
870 /*
871 For some systems [v]snprintf() exists in the system libraries but not in the
872 headers, so we need to declare it ourselves to be able to use it.
873 */
874 #if defined(HAVE_VSNPRINTF) && !defined(HAVE_VSNPRINTF_DECL)
875 #ifdef __cplusplus
876 extern "C"
877 #else
878 extern
879 #endif
880 int vsnprintf(char *str, size_t size, const char *format, va_list ap);
881 #endif /* !HAVE_VSNPRINTF_DECL */
882
883 #if defined(HAVE_SNPRINTF) && !defined(HAVE_SNPRINTF_DECL)
884 #ifdef __cplusplus
885 extern "C"
886 #else
887 extern
888 #endif
889 WXDLLIMPEXP_BASE int snprintf(char *str, size_t size, const char *format, ...);
890 #endif /* !HAVE_SNPRINTF_DECL */
891
892 /* Wrapper for vsnprintf if it's 3rd parameter is non-const. Note: the
893 * same isn't done for snprintf below, the builtin wxSnprintf_ is used
894 * instead since it's already a simple wrapper */
895 #if defined __cplusplus && defined HAVE_BROKEN_VSNPRINTF_DECL
896 inline int wx_fixed_vsnprintf(char *str, size_t size, const char *format, va_list ap)
897 {
898 return vsnprintf(str, size, (char*)format, ap);
899 }
900 #endif
901
902 /*
903 MinGW MSVCRT has non-standard vswprintf() (for MSVC compatibility
904 presumably) and normally _vsnwprintf() is used instead
905 */
906 #if defined(HAVE_VSWPRINTF) && defined(__MINGW32__)
907 #undef HAVE_VSWPRINTF
908 #endif
909
910 #if wxUSE_PRINTF_POS_PARAMS
911 /*
912 The systems where vsnprintf() supports positional parameters should
913 define the HAVE_UNIX98_PRINTF symbol.
914
915 On systems which don't (e.g. Windows) we are forced to use
916 our wxVsnprintf() implementation.
917 */
918 #if defined(HAVE_UNIX98_PRINTF)
919 #if wxUSE_UNICODE
920 #ifdef HAVE_VSWPRINTF
921 #define wxVsnprintf_ vswprintf
922 #endif
923 #else /* ASCII */
924 #ifdef HAVE_BROKEN_VSNPRINTF_DECL
925 #define wxVsnprintf_ wx_fixed_vsnprintf
926 #else
927 #define wxVsnprintf_ vsnprintf
928 #endif
929 #endif
930 #else /* !HAVE_UNIX98_PRINTF */
931 /*
932 The only compiler with positional parameters support under Windows
933 is VC++ 8.0 which provides a new xxprintf_p() functions family.
934 The 2003 PSDK includes a slightly earlier version of VC8 than the
935 main release and does not have the printf_p functions.
936 */
937 #if defined _MSC_FULL_VER && _MSC_FULL_VER >= 140050727 && !defined __WXWINCE__
938 #if wxUSE_UNICODE
939 #define wxVsnprintf_ _vswprintf_p
940 #else
941 #define wxVsnprintf_ _vsprintf_p
942 #endif
943 #endif
944 #endif /* HAVE_UNIX98_PRINTF/!HAVE_UNIX98_PRINTF */
945 #else /* !wxUSE_PRINTF_POS_PARAMS */
946 /*
947 We always want to define safe snprintf() function to be used instead of
948 sprintf(). Some compilers already have it (or rather vsnprintf() which
949 we really need...), otherwise we implement it using our own printf()
950 code.
951
952 We define function with a trailing underscore here because the real one
953 is a wrapper around it as explained below
954 */
955
956 /* first deal with TCHAR-aware compilers which have _vsntprintf */
957 #ifndef wxVsnprintf_
958 #if defined(__VISUALC__) || \
959 (defined(__BORLANDC__) && __BORLANDC__ >= 0x540)
960 #define wxVsnprintf_ _vsntprintf
961 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, _sntprintf)
962 #endif
963 #endif
964
965 /* if this didn't work, define it separately for Unicode and ANSI builds */
966 #ifndef wxVsnprintf_
967 #if wxUSE_UNICODE
968 #if defined(HAVE__VSNWPRINTF)
969 #define wxVsnprintf_ _vsnwprintf
970 #elif defined(HAVE_VSWPRINTF)
971 #define wxVsnprintf_ vswprintf
972 #elif defined(__WATCOMC__)
973 #define wxVsnprintf_ _vsnwprintf
974 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, _snwprintf)
975 #endif
976 #else /* ASCII */
977 /*
978 All versions of CodeWarrior supported by wxWidgets apparently
979 have both snprintf() and vsnprintf()
980 */
981 #if defined(HAVE_SNPRINTF) \
982 || defined(__MWERKS__) || defined(__WATCOMC__)
983 #ifndef HAVE_BROKEN_SNPRINTF_DECL
984 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, snprintf)
985 #endif
986 #endif
987 #if defined(HAVE_VSNPRINTF) \
988 || defined(__MWERKS__) || defined(__WATCOMC__)
989 #ifdef HAVE_BROKEN_VSNPRINTF_DECL
990 #define wxVsnprintf_ wx_fixed_vsnprintf
991 #else
992 #define wxVsnprintf_ vsnprintf
993 #endif
994 #endif
995 #endif /* Unicode/ASCII */
996 #endif /* wxVsnprintf_ */
997 #endif /* wxUSE_PRINTF_POS_PARAMS/!wxUSE_PRINTF_POS_PARAMS */
998
999 #ifndef wxSnprintf_
1000 /* no snprintf(), cook our own */
1001 WXDLLIMPEXP_BASE int
1002 wxDoSnprintf_(wxChar *buf, size_t len,
1003 const wxChar *format, ...) ATTRIBUTE_PRINTF_3;
1004 WX_DEFINE_VARARG_FUNC(int, wxSnprintf_, wxDoSnprintf_)
1005 #endif
1006 #ifndef wxVsnprintf_
1007 /* no (suitable) vsnprintf(), cook our own */
1008 WXDLLIMPEXP_BASE int
1009 wxVsnprintf_(wxChar *buf, size_t len,
1010 const wxChar *format, va_list argptr);
1011
1012 #define wxUSE_WXVSNPRINTF 1
1013 #else
1014 #define wxUSE_WXVSNPRINTF 0
1015 #endif
1016
1017 /*
1018 In Unicode mode we need to have all standard functions such as wprintf() and
1019 so on but not all systems have them so use our own implementations in this
1020 case.
1021 */
1022 #if wxUSE_UNICODE && !defined(wxHAVE_TCHAR_SUPPORT) && !defined(HAVE_WPRINTF)
1023 #define wxNEED_WPRINTF
1024 #endif
1025
1026 /*
1027 More Unicode complications: although both ANSI C and C++ define a number of
1028 wide character functions such as wprintf(), not all environments have them.
1029 Worse, those which do have different behaviours: under Windows, %s format
1030 specifier changes its meaning in Unicode build and expects a Unicode string
1031 while under Unix/POSIX it still means an ASCII string even for wprintf() and
1032 %ls has to be used for wide strings.
1033
1034 We choose to always emulate Windows behaviour as more useful for us so even
1035 if we have wprintf() we still must wrap it in a non trivial wxPrintf().
1036
1037 */
1038
1039 #if defined(wxNEED_PRINTF_CONVERSION) || defined(wxNEED_WPRINTF)
1040 /*
1041 we need to implement all wide character printf and scanf functions
1042 either because we don't have them at all or because they don't have the
1043 semantics we need
1044 */
1045 WX_DEFINE_VARARG_FUNC(int, wxScanf, wxDoScanf)
1046 int wxDoScanf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
1047
1048 WX_DEFINE_VARARG_FUNC(int, wxSscanf, wxDoSscanf)
1049 int wxDoSscanf( const wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1050
1051 WX_DEFINE_VARARG_FUNC(int, wxFscanf, wxDoFscanf)
1052 int wxDoFscanf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1053
1054 WX_DEFINE_VARARG_FUNC(int, wxPrintf, wxDoPrintf)
1055 int wxDoPrintf( const wxChar *format, ... ) ATTRIBUTE_PRINTF_1;
1056
1057 WX_DEFINE_VARARG_FUNC(int, wxSprintf, wxDoSprintf)
1058 int wxDoSprintf( wxChar *str, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1059
1060 WX_DEFINE_VARARG_FUNC(int, wxFprintf, wxDoFprintf)
1061 int wxDoFprintf( FILE *stream, const wxChar *format, ... ) ATTRIBUTE_PRINTF_2;
1062
1063 int wxVsscanf( const wxChar *str, const wxChar *format, va_list ap );
1064 int wxVfprintf( FILE *stream, const wxChar *format, va_list ap );
1065 int wxVprintf( const wxChar *format, va_list ap );
1066 int wxVsprintf( wxChar *str, const wxChar *format, va_list ap );
1067 #endif /* wxNEED_PRINTF_CONVERSION */
1068
1069 /* these 2 can be simply mapped to the versions with underscore at the end */
1070 /* if we don't have to do the conversion */
1071 /*
1072 However, if we don't have any vswprintf() at all we don't need to redefine
1073 anything as our own wxVsnprintf_() already behaves as needed.
1074 */
1075 #if defined(wxNEED_PRINTF_CONVERSION) && defined(wxVsnprintf_)
1076 WX_DEFINE_VARARG_FUNC(int, wxSnprintf, wxDoSnprintf)
1077 int wxDoSnprintf( wxChar *str, size_t size, const wxChar *format, ... ) ATTRIBUTE_PRINTF_3;
1078 int wxVsnprintf( wxChar *str, size_t size, const wxChar *format, va_list ap );
1079 #else
1080 #define wxSnprintf wxSnprintf_
1081 #define wxVsnprintf wxVsnprintf_
1082 #endif
1083
1084 /*
1085 various functions which might not be available in libc and for which we
1086 provide our own replacements in wxchar.cpp
1087 */
1088
1089 /* ctype.h functions */
1090
1091 /* RN: Used only under OSX <= 10.2 currently */
1092 #ifdef wxNEED_WX_CTYPE_H
1093 WXDLLIMPEXP_BASE int wxIsalnum(wxChar ch);
1094 WXDLLIMPEXP_BASE int wxIsalpha(wxChar ch);
1095 WXDLLIMPEXP_BASE int wxIscntrl(wxChar ch);
1096 WXDLLIMPEXP_BASE int wxIsdigit(wxChar ch);
1097 WXDLLIMPEXP_BASE int wxIsgraph(wxChar ch);
1098 WXDLLIMPEXP_BASE int wxIslower(wxChar ch);
1099 WXDLLIMPEXP_BASE int wxIsprint(wxChar ch);
1100 WXDLLIMPEXP_BASE int wxIspunct(wxChar ch);
1101 WXDLLIMPEXP_BASE int wxIsspace(wxChar ch);
1102 WXDLLIMPEXP_BASE int wxIsupper(wxChar ch);
1103 WXDLLIMPEXP_BASE int wxIsxdigit(wxChar ch);
1104 WXDLLIMPEXP_BASE int wxTolower(wxChar ch);
1105 WXDLLIMPEXP_BASE int wxToupper(wxChar ch);
1106 #endif /* wxNEED_WX_CTYPE_H */
1107
1108 /* under VC++ 6.0 isspace() returns 1 for 8 bit chars which completely breaks */
1109 /* the file parsing -- this may be true for 5.0 as well, update #ifdef then */
1110 #if defined(__VISUALC__) && (__VISUALC__ >= 1200) && !wxUSE_UNICODE
1111 #undef wxIsspace
1112 #define wxIsspace(c) ((((unsigned)(wxChar)c) < 128) && isspace(c))
1113 #endif /* VC++ */
1114
1115 /*
1116 a few compilers don't have the (non standard but common) isascii function,
1117 define it ourselves for them
1118 */
1119 #ifndef isascii
1120 #if defined(__MWERKS__)
1121 #define wxNEED_ISASCII
1122 #elif defined(_WIN32_WCE)
1123 #if _WIN32_WCE <= 211
1124 #define wxNEED_ISASCII
1125 #endif
1126 #endif
1127 #endif /* isascii */
1128
1129 #ifdef wxNEED_ISASCII
1130 inline int isascii(int c) { return (unsigned)c < 0x80; }
1131 #endif
1132
1133 #ifdef _WIN32_WCE
1134 #if _WIN32_WCE <= 211
1135 #define isspace(c) ((c) == _T(' ') || (c) == _T('\t'))
1136 #endif
1137 #endif /* _WIN32_WCE */
1138
1139 /*
1140 we had goofed and defined wxIsctrl() instead of (correct) wxIscntrl() in the
1141 initial versions of this header -- now it is too late to remove it so
1142 although we fixed the function/macro name above, still provide the
1143 backwards-compatible synonym.
1144 */
1145 #define wxIsctrl wxIscntrl
1146
1147 /* string.h functions */
1148 #ifndef strdup
1149 #if defined(__MWERKS__) && !defined(__MACH__) && (__MSL__ < 0x00008000)
1150 #define wxNEED_STRDUP
1151 #elif defined(__WXWINCE__)
1152 #if _WIN32_WCE <= 211
1153 #define wxNEED_STRDUP
1154 #endif
1155 #endif
1156 #endif /* strdup */
1157
1158 #ifdef wxNEED_STRDUP
1159 WXDLLIMPEXP_BASE char *strdup(const char* s);
1160 #endif
1161
1162 /* RN: Used only under OSX <= 10.2 currently
1163 The __cplusplus ifdefs are messy, but they are required to build
1164 the regex library, since c does not support function overloading
1165 */
1166 #ifdef wxNEED_WX_STRING_H
1167 # ifdef __cplusplus
1168 extern "C" {
1169 # endif
1170 WXDLLIMPEXP_BASE wxChar * wxStrcat(wxChar *dest, const wxChar *src);
1171 WXDLLIMPEXP_BASE const wxChar * wxStrchr(const wxChar *s, wxChar c);
1172 WXDLLIMPEXP_BASE int wxStrcmp(const wxChar *s1, const wxChar *s2);
1173 WXDLLIMPEXP_BASE int wxStrcoll(const wxChar *s1, const wxChar *s2);
1174 WXDLLIMPEXP_BASE wxChar * wxStrcpy(wxChar *dest, const wxChar *src);
1175 WXDLLIMPEXP_BASE size_t wxStrcspn(const wxChar *s, const wxChar *reject);
1176 WXDLLIMPEXP_BASE wxChar * wxStrncat(wxChar *dest, const wxChar *src, size_t n);
1177 WXDLLIMPEXP_BASE int wxStrncmp(const wxChar *s1, const wxChar *s2, size_t n);
1178 WXDLLIMPEXP_BASE wxChar * wxStrncpy(wxChar *dest, const wxChar *src, size_t n);
1179 WXDLLIMPEXP_BASE const wxChar * wxStrpbrk(const wxChar *s, const wxChar *accept);
1180 WXDLLIMPEXP_BASE const wxChar * wxStrrchr(const wxChar *s, wxChar c);
1181 WXDLLIMPEXP_BASE size_t wxStrspn(const wxChar *s, const wxChar *accept);
1182 WXDLLIMPEXP_BASE const wxChar * wxStrstr(const wxChar *haystack, const wxChar *needle);
1183 # ifdef __cplusplus
1184 }
1185 # endif
1186
1187 /* These functions use C++, so we can't c extern them */
1188 WXDLLIMPEXP_BASE double wxStrtod(const wxChar *nptr, wxChar **endptr);
1189 WXDLLIMPEXP_BASE long int wxStrtol(const wxChar *nptr, wxChar **endptr, int base);
1190 WXDLLIMPEXP_BASE unsigned long int wxStrtoul(const wxChar *nptr, wxChar **endptr, int base);
1191 WXDLLIMPEXP_BASE size_t wxStrxfrm(wxChar *dest, const wxChar *src, size_t n);
1192
1193 /* inlined versions */
1194 #ifdef __cplusplus
1195 inline wxChar * wxStrchr(wxChar *s, wxChar c)
1196 { return (wxChar *)wxStrchr((const wxChar *)s, c); }
1197 inline wxChar * wxStrpbrk(wxChar *s, const wxChar *accept)
1198 { return (wxChar *)wxStrpbrk((const wxChar *)s, accept); }
1199 inline wxChar * wxStrrchr(wxChar *s, wxChar c)
1200 { return (wxChar *)wxStrrchr((const wxChar *)s, c); }
1201 inline wxChar *wxStrstr(wxChar *haystack, const wxChar *needle)
1202 { return (wxChar *)wxStrstr((const wxChar *)haystack, needle); }
1203 #endif
1204
1205 #endif /* wxNEED_WX_STRING_H */
1206
1207 #ifndef wxStrdupA
1208 WXDLLIMPEXP_BASE char *wxStrdupA(const char *psz);
1209 #endif
1210
1211 #ifndef wxStrdupW
1212 WXDLLIMPEXP_BASE wchar_t *wxStrdupW(const wchar_t *pwz);
1213 #endif
1214
1215 #ifndef wxStricmp
1216 WXDLLIMPEXP_BASE int wxStricmp(const wxChar *psz1, const wxChar *psz2);
1217 #endif
1218
1219 #ifndef wxStrnicmp
1220 WXDLLIMPEXP_BASE int wxStrnicmp(const wxChar *psz1, const wxChar *psz2, size_t len);
1221 #endif
1222
1223 #ifndef wxStrtok
1224 WXDLLIMPEXP_BASE wxChar * wxStrtok(wxChar *psz, const wxChar *delim, wxChar **save_ptr);
1225 #endif
1226
1227 #ifdef __cplusplus
1228 #ifndef wxSetlocale
1229 class WXDLLIMPEXP_BASE wxWCharBuffer;
1230 WXDLLIMPEXP_BASE wxWCharBuffer wxSetlocale(int category, const wxChar *locale);
1231 #endif
1232 #endif
1233
1234 /* stdio.h functions */
1235 #ifdef wxNEED_WX_STDIO_H
1236 #include <stdio.h>
1237 WXDLLIMPEXP_BASE FILE * wxFopen(const wxChar *path, const wxChar *mode);
1238 WXDLLIMPEXP_BASE FILE * wxFreopen(const wxChar *path, const wxChar *mode, FILE *stream);
1239 WXDLLIMPEXP_BASE int wxRemove(const wxChar *path);
1240 WXDLLIMPEXP_BASE int wxRename(const wxChar *oldpath, const wxChar *newpath);
1241
1242 /* *printf() family is handled separately */
1243 #endif /* wxNEED_WX_STDIO_H */
1244
1245
1246 /* stdlib.h functions */
1247 #ifndef wxAtof
1248 WXDLLIMPEXP_BASE double wxAtof(const wxChar *psz);
1249 #endif
1250
1251 #ifdef wxNEED_WX_STDLIB_H
1252 WXDLLIMPEXP_BASE int wxAtoi(const wxChar *psz);
1253 WXDLLIMPEXP_BASE long wxAtol(const wxChar *psz);
1254 WXDLLIMPEXP_BASE wxChar * wxGetenv(const wxChar *name);
1255 WXDLLIMPEXP_BASE int wxSystem(const wxChar *psz);
1256 #endif
1257
1258
1259 /* time.h functions */
1260 #ifdef wxNEED_WX_TIME_H
1261 #if defined(__MWERKS__) && defined(macintosh)
1262 #include <time.h>
1263 #endif
1264 /*silent gabby compilers*/
1265 struct tm;
1266 WXDLLIMPEXP_BASE size_t wxStrftime(wxChar *s, size_t max,
1267 const wxChar *fmt,
1268 const struct tm *tm);
1269 #endif /* wxNEED_WX_TIME_H */
1270
1271 #ifndef wxCtime
1272 #include <time.h>
1273 WXDLLIMPEXP_BASE wxChar *wxCtime(const time_t *timep);
1274 #endif
1275
1276
1277 /* missing functions in some WinCE versions */
1278 #ifdef _WIN32_WCE
1279 #if (_WIN32_WCE < 300)
1280 WXDLLIMPEXP_BASE void *calloc( size_t num, size_t size );
1281 #endif
1282 #endif /* _WIN32_WCE */
1283
1284 /* multibyte to wide char conversion functions and macros */
1285
1286 #if wxUSE_WCHAR_T
1287 /* multibyte<->widechar conversion */
1288 WXDLLIMPEXP_BASE size_t wxMB2WC(wchar_t *buf, const char *psz, size_t n);
1289 WXDLLIMPEXP_BASE size_t wxWC2MB(char *buf, const wchar_t *psz, size_t n);
1290
1291 #if wxUSE_UNICODE
1292 #define wxMB2WX wxMB2WC
1293 #define wxWX2MB wxWC2MB
1294 #define wxWC2WX wxStrncpy
1295 #define wxWX2WC wxStrncpy
1296 #else
1297 #define wxMB2WX wxStrncpy
1298 #define wxWX2MB wxStrncpy
1299 #define wxWC2WX wxWC2MB
1300 #define wxWX2WC wxMB2WC
1301 #endif
1302 #else /* !wxUSE_UNICODE */
1303 /* Why is this here?
1304 #error ha */
1305 /* No wxUSE_WCHAR_T: we have to do something (JACS) */
1306 #define wxMB2WC wxStrncpy
1307 #define wxWC2MB wxStrncpy
1308 #define wxMB2WX wxStrncpy
1309 #define wxWX2MB wxStrncpy
1310 #define wxWC2WX wxWC2MB
1311 #define wxWX2WC wxMB2WC
1312 #endif
1313
1314 /*
1315 RN: The following are not normal versions of memcpy et al., rather
1316 these are either char or widechar versions depending on
1317 if unicode is used or not.
1318 */
1319
1320 #ifdef __cplusplus
1321
1322 //
1323 // RN: We could do the usual tricky compiler detection here,
1324 // and use their variant (such as wmemchr, etc.). The problem
1325 // is that these functions are quite rare, even though they are
1326 // part of the current POSIX standard. In addition, most compilers
1327 // (including even MSC) inline them just like we do right in their
1328 // headers.
1329 //
1330 #if wxUSE_UNICODE
1331 #include <string.h> //for mem funcs
1332
1333 //implement our own wmem variants
1334 inline wxChar* wxTmemchr(const wxChar* s, wxChar c, size_t l)
1335 {
1336 for(;l && *s != c;--l, ++s) {}
1337
1338 if(l)
1339 return (wxChar*)s;
1340 return NULL;
1341 }
1342
1343 inline int wxTmemcmp(const wxChar* sz1, const wxChar* sz2, size_t len)
1344 {
1345 for(; *sz1 == *sz2 && len; --len, ++sz1, ++sz2) {}
1346
1347 if(len)
1348 return *sz1 < *sz2 ? -1 : *sz1 > *sz2;
1349 else
1350 return 0;
1351 }
1352
1353 inline wxChar* wxTmemcpy(wxChar* szOut, const wxChar* szIn, size_t len)
1354 {
1355 return (wxChar*) memcpy(szOut, szIn, len * sizeof(wxChar));
1356 }
1357
1358 inline wxChar* wxTmemmove(wxChar* szOut, const wxChar* szIn, size_t len)
1359 {
1360 return (wxChar*) memmove(szOut, szIn, len * sizeof(wxChar));
1361 }
1362
1363 inline wxChar* wxTmemset(wxChar* szOut, const wxChar cIn, size_t len)
1364 {
1365 wxChar* szRet = szOut;
1366
1367 while (len--)
1368 *szOut++ = cIn;
1369
1370 return szRet;
1371 }
1372
1373 #else /* !wxUSE_UNICODE */
1374 # define wxTmemchr memchr
1375 # define wxTmemcmp memcmp
1376 # define wxTmemcpy memcpy
1377 # define wxTmemmove memmove
1378 # define wxTmemset memset
1379 #endif /* wxUSE_UNICODE/!wxUSE_UNICODE */
1380
1381 #endif /*__cplusplus*/
1382
1383 /*
1384 FIXME-UTF8: split this header into more:
1385 wxchartype.h for wxChar definition (only this one will have to
1386 remain C header, the rest can be C++)
1387 wxcrt.h for CRT wrappers
1388 wxchar.h for wxChar+wxCharRef classes
1389 */
1390 #ifdef __cplusplus
1391 class WXDLLIMPEXP_BASE wxString;
1392 class WXDLLIMPEXP_BASE wxUniCharRef;
1393
1394 // This class represents single Unicode character. It can be converted to
1395 // and from char or wchar_t and implements commonly used character operations.
1396 class WXDLLIMPEXP_BASE wxUniChar
1397 {
1398 public:
1399 // NB: this is not wchar_t on purpose, it needs to represent the entire
1400 // Unicode code points range and wchar_t may be too small for that
1401 // (e.g. on Win32 where wchar_t* is encoded in UTF-16)
1402 typedef unsigned int unicode_type;
1403
1404 wxUniChar() : m_value(0) {}
1405
1406 // Create the character from 8bit character value encoded in the current
1407 // locale's charset.
1408 wxUniChar(char c) { m_value = From8bit(c); }
1409
1410 // Create the character from a wchar_t character value.
1411 wxUniChar(wchar_t c) { m_value = c; }
1412
1413 #ifndef wxWINT_T_IS_TYPEDEF
1414 // Create the character from a wint_t character value.
1415 wxUniChar(wint_t c) { m_value = c; }
1416 #endif
1417
1418 wxUniChar(int c) { m_value = c; }
1419
1420 wxUniChar(const wxUniCharRef& c);
1421
1422 // Returns Unicode code point value of the character
1423 unicode_type GetValue() const { return m_value; }
1424
1425 // Casts to char and wchar_t types:
1426 operator char() const { return To8bit(m_value); }
1427 operator wchar_t() const { return m_value; }
1428 #ifndef wxWINT_T_IS_TYPEDEF
1429 operator wint_t() const { return m_value; }
1430 #endif
1431 operator int() const { return m_value; }
1432
1433 // We need this operator for the "*p" part of expressions like "for (
1434 // const_iterator p = begin() + nStart; *p; ++p )". In this case,
1435 // compilation would fail without it because the conversion to bool would
1436 // be ambiguous (there are all these int types conversions...). (And adding
1437 // operator unspecified_bool_type() would only makes the ambiguity worse.)
1438 operator bool() const { return m_value != 0; }
1439 bool operator!() const { return !((bool)*this); }
1440 #if (defined(__VISUALC__) && __VISUALC__ < 1400) || \
1441 defined(__DIGITALMARS__) || defined(__BORLANDC__)
1442 // We need this for VC++ < 8 or DigitalMars and expressions like
1443 // "str[0] && *p":
1444 bool operator&&(bool v) const { return (bool)*this && v; }
1445 #endif
1446
1447 // Assignment operators:
1448 wxUniChar& operator=(const wxUniChar& c) { m_value = c.m_value; return *this; }
1449 wxUniChar& operator=(char c) { m_value = From8bit(c); return *this; }
1450 wxUniChar& operator=(wchar_t c) { m_value = c; return *this; }
1451 #ifndef wxWINT_T_IS_TYPEDEF
1452 wxUniChar& operator=(wint_t c) { m_value = c; return *this; }
1453 #endif
1454
1455 // Comparision operators:
1456 bool operator==(const wxUniChar& c) const { return m_value == c.m_value; }
1457 bool operator==(char c) const { return m_value == From8bit(c); }
1458 bool operator==(wchar_t c) const { return m_value == (unicode_type)c; }
1459 #ifndef wxWINT_T_IS_TYPEDEF
1460 bool operator==(wint_t c) const { return m_value == (unicode_type)c; }
1461 #endif
1462
1463 bool operator!=(const wxUniChar& c) const { return m_value != c.m_value; }
1464 bool operator!=(char c) const { return m_value != From8bit(c); }
1465 bool operator!=(wchar_t c) const { return m_value != (unicode_type)c; }
1466 #ifndef wxWINT_T_IS_TYPEDEF
1467 bool operator!=(wint_t c) const { return m_value != (unicode_type)c; }
1468 #endif
1469
1470 bool operator>(const wxUniChar& c) const { return m_value > c.m_value; }
1471 bool operator>(char c) const { return m_value > (unicode_type)c; }
1472 bool operator>(wchar_t c) const { return m_value > (unicode_type)c; }
1473 #ifndef wxWINT_T_IS_TYPEDEF
1474 bool operator>(wint_t c) const { return m_value > (unicode_type)c; }
1475 #endif
1476
1477 bool operator<(const wxUniChar& c) const { return m_value < c.m_value; }
1478 bool operator<(char c) const { return m_value < From8bit(c); }
1479 bool operator<(wchar_t c) const { return m_value < (unicode_type)c; }
1480 #ifndef wxWINT_T_IS_TYPEDEF
1481 bool operator<(wint_t c) const { return m_value < (unicode_type)c; }
1482 #endif
1483
1484 bool operator>=(const wxUniChar& c) const { return m_value >= c.m_value; }
1485 bool operator>=(char c) const { return m_value >= From8bit(c); }
1486 bool operator>=(wchar_t c) const { return m_value >= (unicode_type)c; }
1487 #ifndef wxWINT_T_IS_TYPEDEF
1488 bool operator>=(wint_t c) const { return m_value >= (unicode_type)c; }
1489 #endif
1490
1491 bool operator<=(const wxUniChar& c) const { return m_value <= c.m_value; }
1492 bool operator<=(char c) const { return m_value <= From8bit(c); }
1493 bool operator<=(wchar_t c) const { return m_value <= (unicode_type)c; }
1494 #ifndef wxWINT_T_IS_TYPEDEF
1495 bool operator<=(wint_t c) const { return m_value <= (unicode_type)c; }
1496 #endif
1497
1498 int operator-(const wxUniChar& c) const { return m_value - c.m_value; }
1499 int operator-(char c) const { return m_value - From8bit(c); }
1500 int operator-(wchar_t c) const { return m_value - (unicode_type)c; }
1501 #ifndef wxWINT_T_IS_TYPEDEF
1502 int operator-(wint_t c) const { return m_value - (unicode_type)c; }
1503 #endif
1504
1505 private:
1506 static unicode_type From8bit(char c);
1507 static char To8bit(unicode_type c);
1508
1509 private:
1510 unicode_type m_value;
1511 };
1512
1513
1514 // Writeable reference to a character in wxString.
1515 //
1516 // This class can be used in the same way wxChar is used, except that changing
1517 // its value updates the underlying string object.
1518 class WXDLLIMPEXP_BASE wxUniCharRef
1519 {
1520 private:
1521 // create the reference
1522 // FIXME: the interface will need changes for UTF-8 build
1523 wxUniCharRef(wxChar *pos) : m_pos(pos) {}
1524
1525 public:
1526 // NB: we have to make this public, because we don't have wxString
1527 // declaration available here and so can't declare wxString::iterator
1528 // as friend; so at least don't use a ctor but a static function
1529 // that must be used explicitly (this is more than using 'explicit'
1530 // keyword on ctor!):
1531 //
1532 // FIXME: the interface will need changes for UTF-8 build
1533 static wxUniCharRef CreateForString(wxChar *pos)
1534 { return wxUniCharRef(pos); }
1535
1536 wxUniChar::unicode_type GetValue() const { return UniChar().GetValue(); }
1537
1538 // Assignment operators:
1539 wxUniCharRef& operator=(const wxUniCharRef& c)
1540 {
1541 *m_pos = *c.m_pos;
1542 return *this;
1543 };
1544
1545 wxUniCharRef& operator=(const wxUniChar& c)
1546 {
1547 *m_pos = c;
1548 return *this;
1549 };
1550
1551 wxUniCharRef& operator=(char c) { return *this = wxUniChar(c); }
1552 wxUniCharRef& operator=(wchar_t c) { return *this = wxUniChar(c); }
1553
1554 // Casts to wxUniChar type:
1555 operator char() const { return UniChar(); }
1556 operator wchar_t() const { return UniChar(); }
1557 #ifndef wxWINT_T_IS_TYPEDEF
1558 operator wint_t() const { return UniChar(); }
1559 #endif
1560 operator int() const { return UniChar(); }
1561
1562 // see wxUniChar::operator bool etc. for explanation
1563 operator bool() const { return (bool)UniChar(); }
1564 bool operator!() const { return !UniChar(); }
1565 #if (defined(__VISUALC__) && __VISUALC__ < 1400) || \
1566 defined(__DIGITALMARS__) || defined(__BORLANDC__)
1567 bool operator&&(bool v) const { return UniChar() && v; }
1568 #endif
1569
1570 // Comparision operators:
1571 bool operator==(const wxUniCharRef& c) const { return m_pos == c.m_pos; }
1572 bool operator==(const wxUniChar& c) const { return UniChar() == c; }
1573 bool operator==(char c) const { return UniChar() == c; }
1574 bool operator==(wchar_t c) const { return UniChar() == c; }
1575 #ifndef wxWINT_T_IS_TYPEDEF
1576 bool operator==(wint_t c) const { return UniChar() == c; }
1577 #endif
1578
1579 bool operator!=(const wxUniCharRef& c) const { return m_pos != c.m_pos; }
1580 bool operator!=(const wxUniChar& c) const { return UniChar() != c; }
1581 bool operator!=(char c) const { return UniChar() != c; }
1582 bool operator!=(wchar_t c) const { return UniChar() != c; }
1583 #ifndef wxWINT_T_IS_TYPEDEF
1584 bool operator!=(wint_t c) const { return UniChar() != c; }
1585 #endif
1586
1587 bool operator>(const wxUniCharRef& c) const { return UniChar() > c.UniChar(); }
1588 bool operator>(const wxUniChar& c) const { return UniChar() > c; }
1589 bool operator>(char c) const { return UniChar() > c; }
1590 bool operator>(wchar_t c) const { return UniChar() > c; }
1591 #ifndef wxWINT_T_IS_TYPEDEF
1592 bool operator>(wint_t c) const { return UniChar() > c; }
1593 #endif
1594
1595 bool operator<(const wxUniCharRef& c) const { return UniChar() < c.UniChar(); }
1596 bool operator<(const wxUniChar& c) const { return UniChar() < c; }
1597 bool operator<(char c) const { return UniChar() < c; }
1598 bool operator<(wchar_t c) const { return UniChar() < c; }
1599 #ifndef wxWINT_T_IS_TYPEDEF
1600 bool operator<(wint_t c) const { return UniChar() < c; }
1601 #endif
1602
1603 bool operator>=(const wxUniCharRef& c) const { return UniChar() >= c.UniChar(); }
1604 bool operator>=(const wxUniChar& c) const { return UniChar() >= c; }
1605 bool operator>=(char c) const { return UniChar() >= c; }
1606 bool operator>=(wchar_t c) const { return UniChar() >= c; }
1607 #ifndef wxWINT_T_IS_TYPEDEF
1608 bool operator>=(wint_t c) const { return UniChar() >= c; }
1609 #endif
1610
1611 bool operator<=(const wxUniCharRef& c) const { return UniChar() <= c.UniChar(); }
1612 bool operator<=(const wxUniChar& c) const { return UniChar() <= c; }
1613 bool operator<=(char c) const { return UniChar() <= c; }
1614 bool operator<=(wchar_t c) const { return UniChar() <= c; }
1615 #ifndef wxWINT_T_IS_TYPEDEF
1616 bool operator<=(wint_t c) const { return UniChar() <= c; }
1617 #endif
1618
1619 int operator-(const wxUniCharRef& c) const { return UniChar() - c.UniChar(); }
1620 int operator-(const wxUniChar& c) const { return UniChar() - c; }
1621 int operator-(char c) const { return UniChar() - c; }
1622 int operator-(wchar_t c) const { return UniChar() - c; }
1623 #ifndef wxWINT_T_IS_TYPEDEF
1624 int operator-(wint_t c) const { return UniChar() - c; }
1625 #endif
1626
1627 private:
1628 wxUniChar UniChar() const { return *m_pos; }
1629 friend class WXDLLIMPEXP_BASE wxUniChar;
1630
1631 private:
1632 // pointer to the character in string
1633 wxChar *m_pos;
1634 };
1635
1636 inline wxUniChar::wxUniChar(const wxUniCharRef& c)
1637 {
1638 m_value = c.UniChar().m_value;
1639 }
1640
1641 // Comparision operators for the case when wxUniChar(Ref) is the second operand:
1642 inline bool operator==(char c1, const wxUniChar& c2) { return c2 == c1; }
1643 inline bool operator==(wchar_t c1, const wxUniChar& c2) { return c2 == c1; }
1644 #ifndef wxWINT_T_IS_TYPEDEF
1645 inline bool operator==(wint_t c1, const wxUniChar& c2) { return c2 == c1; }
1646 #endif
1647
1648 inline bool operator!=(char c1, const wxUniChar& c2) { return c2 != c1; }
1649 inline bool operator!=(wchar_t c1, const wxUniChar& c2) { return c2 != c1; }
1650 #ifndef wxWINT_T_IS_TYPEDEF
1651 inline bool operator!=(wint_t c1, const wxUniChar& c2) { return c2 != c1; }
1652 #endif
1653
1654 inline bool operator>(char c1, const wxUniChar& c2) { return c2 < c1; }
1655 inline bool operator>(wchar_t c1, const wxUniChar& c2) { return c2 < c1; }
1656 #ifndef wxWINT_T_IS_TYPEDEF
1657 inline bool operator>(wint_t c1, const wxUniChar& c2) { return c2 < c1; }
1658 #endif
1659
1660 inline bool operator<(char c1, const wxUniChar& c2) { return c2 > c1; }
1661 inline bool operator<(wchar_t c1, const wxUniChar& c2) { return c2 > c1; }
1662 #ifndef wxWINT_T_IS_TYPEDEF
1663 inline bool operator<(wint_t c1, const wxUniChar& c2) { return c2 > c1; }
1664 #endif
1665
1666 inline bool operator>=(char c1, const wxUniChar& c2) { return c2 <= c1; }
1667 inline bool operator>=(wchar_t c1, const wxUniChar& c2) { return c2 <= c1; }
1668 #ifndef wxWINT_T_IS_TYPEDEF
1669 inline bool operator>=(wint_t c1, const wxUniChar& c2) { return c2 <= c1; }
1670 #endif
1671
1672 inline bool operator<=(char c1, const wxUniChar& c2) { return c2 >= c1; }
1673 inline bool operator<=(wchar_t c1, const wxUniChar& c2) { return c2 >= c1; }
1674 #ifndef wxWINT_T_IS_TYPEDEF
1675 inline bool operator<=(wint_t c1, const wxUniChar& c2) { return c2 >= c1; }
1676 #endif
1677
1678
1679 inline bool operator==(char c1, const wxUniCharRef& c2) { return c2 == c1; }
1680 inline bool operator==(wchar_t c1, const wxUniCharRef& c2) { return c2 == c1; }
1681 #ifndef wxWINT_T_IS_TYPEDEF
1682 inline bool operator==(wint_t c1, const wxUniCharRef& c2) { return c2 == c1; }
1683 #endif
1684 inline bool operator==(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 == c1; }
1685
1686 inline bool operator!=(char c1, const wxUniCharRef& c2) { return c2 != c1; }
1687 inline bool operator!=(wchar_t c1, const wxUniCharRef& c2) { return c2 != c1; }
1688 #ifndef wxWINT_T_IS_TYPEDEF
1689 inline bool operator!=(wint_t c1, const wxUniCharRef& c2) { return c2 != c1; }
1690 #endif
1691 inline bool operator!=(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 != c1; }
1692
1693 inline bool operator>(char c1, const wxUniCharRef& c2) { return c2 < c1; }
1694 inline bool operator>(wchar_t c1, const wxUniCharRef& c2) { return c2 < c1; }
1695 #ifndef wxWINT_T_IS_TYPEDEF
1696 inline bool operator>(wint_t c1, const wxUniCharRef& c2) { return c2 < c1; }
1697 #endif
1698 inline bool operator>(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 < c1; }
1699
1700 inline bool operator<(char c1, const wxUniCharRef& c2) { return c2 > c1; }
1701 inline bool operator<(wchar_t c1, const wxUniCharRef& c2) { return c2 > c1; }
1702 #ifndef wxWINT_T_IS_TYPEDEF
1703 inline bool operator<(wint_t c1, const wxUniCharRef& c2) { return c2 > c1; }
1704 #endif
1705 inline bool operator<(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 > c1; }
1706
1707 inline bool operator>=(char c1, const wxUniCharRef& c2) { return c2 <= c1; }
1708 inline bool operator>=(wchar_t c1, const wxUniCharRef& c2) { return c2 <= c1; }
1709 #ifndef wxWINT_T_IS_TYPEDEF
1710 inline bool operator>=(wint_t c1, const wxUniCharRef& c2) { return c2 <= c1; }
1711 #endif
1712 inline bool operator>=(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 <= c1; }
1713
1714 inline bool operator<=(char c1, const wxUniCharRef& c2) { return c2 >= c1; }
1715 inline bool operator<=(wchar_t c1, const wxUniCharRef& c2) { return c2 >= c1; }
1716 #ifndef wxWINT_T_IS_TYPEDEF
1717 inline bool operator<=(wint_t c1, const wxUniCharRef& c2) { return c2 >= c1; }
1718 #endif
1719 inline bool operator<=(const wxUniChar& c1, const wxUniCharRef& c2) { return c2 >= c1; }
1720
1721 inline int operator-(char c1, const wxUniCharRef& c2) { return -(c2 - c1); }
1722 inline int operator-(wchar_t c1, const wxUniCharRef& c2) { return -(c2 - c1); }
1723 #ifndef wxWINT_T_IS_TYPEDEF
1724 inline int operator-(wint_t c1, const wxUniCharRef& c2) { return -(c2 - c1); }
1725 #endif
1726 inline int operator-(const wxUniChar& c1, const wxUniCharRef& c2) { return -(c2 - c1); }
1727
1728 #endif // __cplusplus
1729
1730 #endif /* _WX_WXCHAR_H_ */
1731