ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
utypes.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 1996-2011, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 *
7 * FILE NAME : UTYPES.H (formerly ptypes.h)
8 *
9 * Date Name Description
10 * 12/11/96 helena Creation.
11 * 02/27/97 aliu Added typedefs for UClassID, int8, int16, int32,
12 * uint8, uint16, and uint32.
13 * 04/01/97 aliu Added XP_CPLUSPLUS and modified to work under C as
14 * well as C++.
15 * Modified to use memcpy() for uprv_arrayCopy() fns.
16 * 04/14/97 aliu Added TPlatformUtilities.
17 * 05/07/97 aliu Added import/export specifiers (replacing the old
18 * broken EXT_CLASS). Added version number for our
19 * code. Cleaned up header.
20 * 6/20/97 helena Java class name change.
21 * 08/11/98 stephen UErrorCode changed from typedef to enum
22 * 08/12/98 erm Changed T_ANALYTIC_PACKAGE_VERSION to 3
23 * 08/14/98 stephen Added uprv_arrayCopy() for int8_t, int16_t, int32_t
24 * 12/09/98 jfitz Added BUFFER_OVERFLOW_ERROR (bug 1100066)
25 * 04/20/99 stephen Cleaned up & reworked for autoconf.
26 * Renamed to utypes.h.
27 * 05/05/99 stephen Changed to use <inttypes.h>
28 * 12/07/99 helena Moved copyright notice string from ucnv_bld.h here.
29 *******************************************************************************
30 */
31 
32 #ifndef UTYPES_H
33 #define UTYPES_H
34 
35 
36 #include "unicode/umachine.h"
37 #include "unicode/utf.h"
38 #include "unicode/uversion.h"
39 #include "unicode/uconfig.h"
40 #include "float.h"
41 
57 #ifdef XP_CPLUSPLUS
58 # ifndef U_SHOW_CPLUSPLUS_API
59 # define U_SHOW_CPLUSPLUS_API 1
60 # endif
61 #else
62 # undef U_SHOW_CPLUSPLUS_API
63 # define U_SHOW_CPLUSPLUS_API 0
64 #endif
65 
78 #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_DRAFT_API)
79 #define U_HIDE_DRAFT_API 1
80 #endif
81 #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_INTERNAL_API)
82 #define U_HIDE_INTERNAL_API 1
83 #endif
84 
85 #ifdef U_HIDE_DRAFT_API
86 #include "unicode/udraft.h"
87 #endif
88 
89 #ifdef U_HIDE_DEPRECATED_API
90 #include "unicode/udeprctd.h"
91 #endif
92 
93 #ifdef U_HIDE_DEPRECATED_API
94 #include "unicode/uobslete.h"
95 #endif
96 
97 #ifdef U_HIDE_INTERNAL_API
98 #include "unicode/uintrnal.h"
99 #endif
100 
101 #ifdef U_HIDE_SYSTEM_API
102 #include "unicode/usystem.h"
103 #endif
104 
108 /*===========================================================================*/
109 /* char Character set family */
110 /*===========================================================================*/
111 
116 #define U_ASCII_FAMILY 0
117 
122 #define U_EBCDIC_FAMILY 1
123 
167 #ifndef U_CHARSET_FAMILY
168 # define U_CHARSET_FAMILY 0
169 #endif
170 
191 #ifndef U_CHARSET_IS_UTF8
192 # define U_CHARSET_IS_UTF8 0
193 #endif
194 
195 /*===========================================================================*/
196 /* ICUDATA naming scheme */
197 /*===========================================================================*/
198 
215 #if U_CHARSET_FAMILY
216 # if U_IS_BIG_ENDIAN
217  /* EBCDIC - should always be BE */
218 # define U_ICUDATA_TYPE_LETTER "e"
219 # define U_ICUDATA_TYPE_LITLETTER e
220 # else
221 # error "Don't know what to do with little endian EBCDIC!"
222 # define U_ICUDATA_TYPE_LETTER "x"
223 # define U_ICUDATA_TYPE_LITLETTER x
224 # endif
225 #else
226 # if U_IS_BIG_ENDIAN
227  /* Big-endian ASCII */
228 # define U_ICUDATA_TYPE_LETTER "b"
229 # define U_ICUDATA_TYPE_LITLETTER b
230 # else
231  /* Little-endian ASCII */
232 # define U_ICUDATA_TYPE_LETTER "l"
233 # define U_ICUDATA_TYPE_LITLETTER l
234 # endif
235 #endif
236 
242 #define U_ICUDATA_NAME "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER
243 #define U_USRDATA_NAME "usrdt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER
244 #define U_USE_USRDATA 1
257 #define U_ICUDATA_ENTRY_POINT U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM, U_ICU_VERSION_MINOR_NUM)
258 
263 #define U_DEF2_ICUDATA_ENTRY_POINT(major, minor) U_DEF_ICUDATA_ENTRY_POINT(major, minor)
264 
268 #ifndef U_DEF_ICUDATA_ENTRY_POINT
269 /* affected by symbol renaming. See platform.h */
270 #define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt##major##minor##_dat
271 #endif
272 
284 #if defined(OS390) && defined(XP_CPLUSPLUS)
285 # define U_CALLCONV __cdecl
286 #else
287 # define U_CALLCONV U_EXPORT2
288 #endif
289 
295 #ifndef NULL
296 #ifdef XP_CPLUSPLUS
297 #define NULL 0
298 #else
299 #define NULL ((void *)0)
300 #endif
301 #endif
302 
303 /*===========================================================================*/
304 /* Calendar/TimeZone data types */
305 /*===========================================================================*/
306 
314 typedef double UDate;
315 
317 #define U_MILLIS_PER_SECOND (1000)
318 
319 #define U_MILLIS_PER_MINUTE (60000)
320 
321 #define U_MILLIS_PER_HOUR (3600000)
322 
323 #define U_MILLIS_PER_DAY (86400000)
324 
329 #define U_DATE_MAX DBL_MAX
330 
335 #define U_DATE_MIN -U_DATE_MAX
336 
337 
338 
339 /*===========================================================================*/
340 /* UClassID-based RTTI */
341 /*===========================================================================*/
342 
385 typedef void* UClassID;
386 
387 /*===========================================================================*/
388 /* Shared library/DLL import-export API control */
389 /*===========================================================================*/
390 
391 /*
392  * Control of symbol import/export.
393  * ICU is separated into three libraries.
394  */
395 
396 /*
397  * \def U_COMBINED_IMPLEMENTATION
398  * Set to export library symbols from inside the ICU library
399  * when all of ICU is in a single library.
400  * This can be set as a compiler option while building ICU, and it
401  * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc.
402  * @stable ICU 2.0
403  */
404 
454 #if defined(U_COMBINED_IMPLEMENTATION)
455 #define U_DATA_API U_EXPORT
456 #define U_COMMON_API U_EXPORT
457 #define U_I18N_API U_EXPORT
458 #define U_LAYOUT_API U_EXPORT
459 #define U_LAYOUTEX_API U_EXPORT
460 #define U_IO_API U_EXPORT
461 #define U_TOOLUTIL_API U_EXPORT
462 #elif defined(U_STATIC_IMPLEMENTATION)
463 #define U_DATA_API
464 #define U_COMMON_API
465 #define U_I18N_API
466 #define U_LAYOUT_API
467 #define U_LAYOUTEX_API
468 #define U_IO_API
469 #define U_TOOLUTIL_API
470 #elif defined(U_COMMON_IMPLEMENTATION)
471 #define U_DATA_API U_IMPORT
472 #define U_COMMON_API U_EXPORT
473 #define U_I18N_API U_IMPORT
474 #define U_LAYOUT_API U_IMPORT
475 #define U_LAYOUTEX_API U_IMPORT
476 #define U_IO_API U_IMPORT
477 #define U_TOOLUTIL_API U_IMPORT
478 #elif defined(U_I18N_IMPLEMENTATION)
479 #define U_DATA_API U_IMPORT
480 #define U_COMMON_API U_IMPORT
481 #define U_I18N_API U_EXPORT
482 #define U_LAYOUT_API U_IMPORT
483 #define U_LAYOUTEX_API U_IMPORT
484 #define U_IO_API U_IMPORT
485 #define U_TOOLUTIL_API U_IMPORT
486 #elif defined(U_LAYOUT_IMPLEMENTATION)
487 #define U_DATA_API U_IMPORT
488 #define U_COMMON_API U_IMPORT
489 #define U_I18N_API U_IMPORT
490 #define U_LAYOUT_API U_EXPORT
491 #define U_LAYOUTEX_API U_IMPORT
492 #define U_IO_API U_IMPORT
493 #define U_TOOLUTIL_API U_IMPORT
494 #elif defined(U_LAYOUTEX_IMPLEMENTATION)
495 #define U_DATA_API U_IMPORT
496 #define U_COMMON_API U_IMPORT
497 #define U_I18N_API U_IMPORT
498 #define U_LAYOUT_API U_IMPORT
499 #define U_LAYOUTEX_API U_EXPORT
500 #define U_IO_API U_IMPORT
501 #define U_TOOLUTIL_API U_IMPORT
502 #elif defined(U_IO_IMPLEMENTATION)
503 #define U_DATA_API U_IMPORT
504 #define U_COMMON_API U_IMPORT
505 #define U_I18N_API U_IMPORT
506 #define U_LAYOUT_API U_IMPORT
507 #define U_LAYOUTEX_API U_IMPORT
508 #define U_IO_API U_EXPORT
509 #define U_TOOLUTIL_API U_IMPORT
510 #elif defined(U_TOOLUTIL_IMPLEMENTATION)
511 #define U_DATA_API U_IMPORT
512 #define U_COMMON_API U_IMPORT
513 #define U_I18N_API U_IMPORT
514 #define U_LAYOUT_API U_IMPORT
515 #define U_LAYOUTEX_API U_IMPORT
516 #define U_IO_API U_IMPORT
517 #define U_TOOLUTIL_API U_EXPORT
518 #else
519 #define U_DATA_API U_IMPORT
520 #define U_COMMON_API U_IMPORT
521 #define U_I18N_API U_IMPORT
522 #define U_LAYOUT_API U_IMPORT
523 #define U_LAYOUTEX_API U_IMPORT
524 #define U_IO_API U_IMPORT
525 #define U_TOOLUTIL_API U_IMPORT
526 #endif
527 
533 #ifdef __cplusplus
534 #define U_STANDARD_CPP_NAMESPACE ::
535 #else
536 #define U_STANDARD_CPP_NAMESPACE
537 #endif
538 
539 
540 /*===========================================================================*/
541 /* Global delete operator */
542 /*===========================================================================*/
543 
544 /*
545  * The ICU4C library must not use the global new and delete operators.
546  * These operators here are defined to enable testing for this.
547  * See Jitterbug 2581 for details of why this is necessary.
548  *
549  * Verification that ICU4C's memory usage is correct, i.e.,
550  * that global new/delete are not used:
551  *
552  * a) Check for imports of global new/delete (see uobject.cpp for details)
553  * b) Verify that new is never imported.
554  * c) Verify that delete is only imported from object code for interface/mixin classes.
555  * d) Add global delete and delete[] only for the ICU4C library itself
556  * and define them in a way that crashes or otherwise easily shows a problem.
557  *
558  * The following implements d).
559  * The operator implementations crash; this is intentional and used for library debugging.
560  *
561  * Note: This is currently only done on Windows because
562  * some Linux/Unix compilers have problems with defining global new/delete.
563  * On Windows, U_WINDOWS is defined, and it is _MSC_VER>=1200 for MSVC 6.0 and higher.
564  */
565 #if defined(XP_CPLUSPLUS) && defined(U_WINDOWS) && U_DEBUG && U_OVERRIDE_CXX_ALLOCATION && (_MSC_VER>=1200) && !defined(U_STATIC_IMPLEMENTATION) && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_LAYOUTEX_IMPLEMENTATION))
566 
567 #ifndef U_HIDE_INTERNAL_API
568 
573 inline void *
574 operator new(size_t /*size*/) {
575  char *q=NULL;
576  *q=5; /* break it */
577  return q;
578 }
579 
580 #ifdef _Ret_bytecap_
581 /* This is only needed to suppress a Visual C++ 2008 warning for operator new[]. */
582 _Ret_bytecap_(_Size)
583 #endif
584 
589 inline void *
590 operator new[](size_t /*size*/) {
591  char *q=NULL;
592  *q=5; /* break it */
593  return q;
594 }
595 
601 inline void
602 operator delete(void * /*p*/) {
603  char *q=NULL;
604  *q=5; /* break it */
605 }
606 
612 inline void
613 operator delete[](void * /*p*/) {
614  char *q=NULL;
615  *q=5; /* break it */
616 }
617 
618 #endif /* U_HIDE_INTERNAL_API */
619 #endif
620 
621 /*===========================================================================*/
622 /* UErrorCode */
623 /*===========================================================================*/
624 
639 typedef enum UErrorCode {
640  /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird
641  * and is that way because VC++ debugger displays first encountered constant,
642  * which is not the what the code is used for
643  */
644 
703  /*
704  * the error code range 0x10000 0x10100 are reserved for Transliterator
705  */
744  /*
745  * the error code range 0x10100 0x10200 are reserved for formatting API parsing error
746  */
769  /*
770  * the error code range 0x10200 0x102ff are reserved for Break Iterator related error
771  */
789  /*
790  * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs
791  */
816  /*
817  * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes
818  */
819  U_IDNA_PROHIBITED_ERROR=0x10400,
820  U_IDNA_ERROR_START=0x10400,
821  U_IDNA_UNASSIGNED_ERROR,
822  U_IDNA_CHECK_BIDI_ERROR,
823  U_IDNA_STD3_ASCII_RULES_ERROR,
824  U_IDNA_ACE_PREFIX_ERROR,
825  U_IDNA_VERIFICATION_ERROR,
826  U_IDNA_LABEL_TOO_LONG_ERROR,
827  U_IDNA_ZERO_LENGTH_LABEL_ERROR,
828  U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR,
829  U_IDNA_ERROR_LIMIT,
830  /*
831  * Aliases for StringPrep
832  */
833  U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR,
834  U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR,
835  U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR,
836 
837  /*
838  * The error code in the range 0x10500-0x105ff are reserved for Plugin related error codes
839  */
846 } UErrorCode;
847 
848 /* Use the following to determine if an UErrorCode represents */
849 /* operational success or failure. */
850 
851 #ifdef XP_CPLUSPLUS
852 
856  static
857  inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); }
862  static
863  inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); }
864 #else
865 
869 # define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)
870 
874 # define U_FAILURE(x) ((x)>U_ZERO_ERROR)
875 #endif
876 
883 U_STABLE const char * U_EXPORT2
884 u_errorName(UErrorCode code);
885 
886 
887 #endif /* _UTYPES */