Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

utypes.h

Go to the documentation of this file.
00001 /* 00002 ********************************************************************** 00003 * Copyright (C) 1996-2003, International Business Machines 00004 * Corporation and others. All Rights Reserved. 00005 ********************************************************************** 00006 * 00007 * FILE NAME : UTYPES.H (formerly ptypes.h) 00008 * 00009 * Date Name Description 00010 * 12/11/96 helena Creation. 00011 * 02/27/97 aliu Added typedefs for UClassID, int8, int16, int32, 00012 * uint8, uint16, and uint32. 00013 * 04/01/97 aliu Added XP_CPLUSPLUS and modified to work under C as 00014 * well as C++. 00015 * Modified to use memcpy() for uprv_arrayCopy() fns. 00016 * 04/14/97 aliu Added TPlatformUtilities. 00017 * 05/07/97 aliu Added import/export specifiers (replacing the old 00018 * broken EXT_CLASS). Added version number for our 00019 * code. Cleaned up header. 00020 * 6/20/97 helena Java class name change. 00021 * 08/11/98 stephen UErrorCode changed from typedef to enum 00022 * 08/12/98 erm Changed T_ANALYTIC_PACKAGE_VERSION to 3 00023 * 08/14/98 stephen Added uprv_arrayCopy() for int8_t, int16_t, int32_t 00024 * 12/09/98 jfitz Added BUFFER_OVERFLOW_ERROR (bug 1100066) 00025 * 04/20/99 stephen Cleaned up & reworked for autoconf. 00026 * Renamed to utypes.h. 00027 * 05/05/99 stephen Changed to use <inttypes.h> 00028 * 12/07/99 helena Moved copyright notice string from ucnv_bld.h here. 00029 ******************************************************************************* 00030 */ 00031 00032 #ifndef UTYPES_H 00033 #define UTYPES_H 00034 00035 00036 #include "unicode/umachine.h" 00037 #include "unicode/utf.h" 00038 #include "unicode/uversion.h" 00039 #include "unicode/uconfig.h" 00040 00051 /*===========================================================================*/ 00052 /* char Character set family */ 00053 /*===========================================================================*/ 00054 00059 #define U_ASCII_FAMILY 0 00060 00065 #define U_EBCDIC_FAMILY 1 00066 00110 #ifndef U_CHARSET_FAMILY 00111 # define U_CHARSET_FAMILY 0 00112 #endif 00113 00114 /*===========================================================================*/ 00115 /* ICUDATA naming scheme */ 00116 /*===========================================================================*/ 00117 00134 #if U_CHARSET_FAMILY 00135 # if U_IS_BIG_ENDIAN 00136 /* EBCDIC - should always be BE */ 00137 # define U_ICUDATA_TYPE_LETTER "e" 00138 # define U_ICUDATA_TYPE_LITLETTER e 00139 # else 00140 # error "Don't know what to do with little endian EBCDIC!" 00141 # define U_ICUDATA_TYPE_LETTER "x" 00142 # define U_ICUDATA_TYPE_LITLETTER x 00143 # endif 00144 #else 00145 # if U_IS_BIG_ENDIAN 00146 /* Big-endian ASCII */ 00147 # define U_ICUDATA_TYPE_LETTER "b" 00148 # define U_ICUDATA_TYPE_LITLETTER b 00149 # else 00150 /* Little-endian ASCII */ 00151 # define U_ICUDATA_TYPE_LETTER "l" 00152 # define U_ICUDATA_TYPE_LITLETTER l 00153 # endif 00154 #endif 00155 00161 #define U_ICUDATA_NAME "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER 00162 00163 00175 #define U_ICUDATA_ENTRY_POINT U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM, U_ICU_VERSION_MINOR_NUM) 00176 00179 #define U_DEF2_ICUDATA_ENTRY_POINT(major, minor) U_DEF_ICUDATA_ENTRY_POINT(major, minor) 00180 00183 #define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt##major##minor##_dat 00184 00196 #if defined(OS390) && (__COMPILER_VER__ < 0x41020000) && defined(XP_CPLUSPLUS) 00197 # define U_CALLCONV __cdecl 00198 #else 00199 # define U_CALLCONV U_EXPORT2 00200 #endif 00201 00207 #ifndef NULL 00208 #ifdef XP_CPLUSPLUS 00209 #define NULL 0 00210 #else 00211 #define NULL ((void *)0) 00212 #endif 00213 #endif 00214 00215 /*===========================================================================*/ 00216 /* Calendar/TimeZone data types */ 00217 /*===========================================================================*/ 00218 00226 typedef double UDate; 00227 00229 #define U_MILLIS_PER_SECOND (1000) 00230 00231 #define U_MILLIS_PER_MINUTE (60000) 00232 00233 #define U_MILLIS_PER_HOUR (3600000) 00234 00235 #define U_MILLIS_PER_DAY (86400000) 00236 00237 00238 /*===========================================================================*/ 00239 /* UClassID-based RTTI */ 00240 /*===========================================================================*/ 00241 00284 typedef void* UClassID; 00285 00286 /*===========================================================================*/ 00287 /* Shared library/DLL import-export API control */ 00288 /*===========================================================================*/ 00289 00290 /* 00291 * Control of symbol import/export. 00292 * ICU is separated into three libraries. 00293 */ 00294 00295 /* 00296 * \def U_COMBINED_IMPLEMENTATION 00297 * Set to export library symbols from inside the ICU library 00298 * when all of ICU is in a single library. 00299 * This can be set as a compiler option while building ICU, and it 00300 * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc. 00301 * @stable ICU 2.0 00302 */ 00303 00339 #if defined(U_COMBINED_IMPLEMENTATION) 00340 #define U_COMMON_API U_EXPORT 00341 #define U_I18N_API U_EXPORT 00342 #define U_LAYOUT_API U_EXPORT 00343 #define U_LAYOUTEX_API U_EXPORT 00344 #define U_USTDIO_API U_EXPORT 00345 #elif defined(U_STATIC_IMPLEMENTATION) 00346 #define U_COMMON_API 00347 #define U_I18N_API 00348 #define U_LAYOUT_API 00349 #define U_LAYOUTEX_API 00350 #define U_USTDIO_API 00351 #elif defined(U_COMMON_IMPLEMENTATION) 00352 #define U_COMMON_API U_EXPORT 00353 #define U_I18N_API U_IMPORT 00354 #define U_LAYOUT_API U_IMPORT 00355 #define U_LAYOUTEX_API U_IMPORT 00356 #define U_USTDIO_API U_IMPORT 00357 #elif defined(U_I18N_IMPLEMENTATION) 00358 #define U_COMMON_API U_IMPORT 00359 #define U_I18N_API U_EXPORT 00360 #define U_LAYOUT_API U_IMPORT 00361 #define U_LAYOUTEX_API U_IMPORT 00362 #define U_USTDIO_API U_IMPORT 00363 #elif defined(U_LAYOUT_IMPLEMENTATION) 00364 #define U_COMMON_API U_IMPORT 00365 #define U_I18N_API U_IMPORT 00366 #define U_LAYOUT_API U_EXPORT 00367 #define U_LAYOUTEX_API U_IMPORT 00368 #define U_USTDIO_API U_IMPORT 00369 #elif defined(U_LAYOUTEX_IMPLEMENTATION) 00370 #define U_COMMON_API U_IMPORT 00371 #define U_I18N_API U_IMPORT 00372 #define U_LAYOUT_API U_IMPORT 00373 #define U_LAYOUTEX_API U_EXPORT 00374 #define U_USTDIO_API U_IMPORT 00375 #elif defined(U_USTDIO_IMPLEMENTATION) 00376 #define U_COMMON_API U_IMPORT 00377 #define U_I18N_API U_IMPORT 00378 #define U_LAYOUT_API U_IMPORT 00379 #define U_LAYOUTEX_API U_IMPORT 00380 #define U_USTDIO_API U_EXPORT 00381 #else 00382 #define U_COMMON_API U_IMPORT 00383 #define U_I18N_API U_IMPORT 00384 #define U_LAYOUT_API U_IMPORT 00385 #define U_LAYOUTEX_API U_IMPORT 00386 #define U_USTDIO_API U_IMPORT 00387 #endif 00388 00394 #ifdef __cplusplus 00395 #define U_STANDARD_CPP_NAMESPACE :: 00396 #else 00397 #define U_STANDARD_CPP_NAMESPACE 00398 #endif 00399 00400 /*===========================================================================*/ 00401 /* Global delete operator */ 00402 /*===========================================================================*/ 00403 00404 /* 00405 * The ICU4C library must not use the global new and delete operators. 00406 * These operators here are defined to enable testing for this. 00407 * See Jitterbug 2581 for details of why this is necessary. 00408 * 00409 * Verification that ICU4C's memory usage is correct, i.e., 00410 * that global new/delete are not used: 00411 * 00412 * a) Check for imports of global new/delete (see uobject.cpp for details) 00413 * b) Verify that new is never imported. 00414 * c) Verify that delete is only imported from object code for interface/mixin classes. 00415 * d) Add global delete and delete[] only for the ICU4C library itself 00416 * and define them in a way that crashes or otherwise easily shows a problem. 00417 * 00418 * The following implements d). 00419 * The operator implementations crash; this is intentional and used for library debugging. 00420 * 00421 * Note: This is currently only done on Windows because 00422 * some Linux/Unix compilers have problems with defining global new/delete. 00423 * On Windows, WIN32 is defined, and it is _MSC_Ver>=1200 for MSVC 6.0 and higher. 00424 */ 00425 #if defined(XP_CPLUSPLUS) && defined(WIN32) && (_MSC_Ver>=1200) && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_USTDIO_IMPLEMENTATION)) 00426 00432 inline void * 00433 operator new(size_t /*size*/) { 00434 char *q=NULL; 00435 *q=5; /* break it */ 00436 return q; 00437 } 00438 00444 inline void * 00445 operator new[](size_t /*size*/) { 00446 char *q=NULL; 00447 *q=5; /* break it */ 00448 return q; 00449 } 00450 00456 inline void 00457 operator delete(void * /*p*/) { 00458 char *q=NULL; 00459 *q=5; /* break it */ 00460 } 00461 00467 inline void 00468 operator delete[](void * /*p*/) { 00469 char *q=NULL; 00470 *q=5; /* break it */ 00471 } 00472 00473 #endif 00474 00475 /*===========================================================================*/ 00476 /* UErrorCode */ 00477 /*===========================================================================*/ 00478 00493 typedef enum UErrorCode { 00494 /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird 00495 * and is that way because VC++ debugger displays first encountered constant, 00496 * which is not the what the code is used for 00497 */ 00498 00499 U_USING_FALLBACK_WARNING = -128, 00501 U_ERROR_WARNING_START = -128, 00503 U_USING_DEFAULT_WARNING = -127, 00505 U_SAFECLONE_ALLOCATED_WARNING = -126, 00507 U_STATE_OLD_WARNING = -125, 00509 U_STRING_NOT_TERMINATED_WARNING = -124, 00511 U_SORT_KEY_TOO_SHORT_WARNING = -123, 00513 U_AMBIGUOUS_ALIAS_WARNING = -122, 00515 U_DIFFERENT_UCA_VERSION = -121, 00517 U_ERROR_WARNING_LIMIT, 00520 U_ZERO_ERROR = 0, 00522 U_ILLEGAL_ARGUMENT_ERROR = 1, 00523 U_MISSING_RESOURCE_ERROR = 2, 00524 U_INVALID_FORMAT_ERROR = 3, 00525 U_FILE_ACCESS_ERROR = 4, 00526 U_INTERNAL_PROGRAM_ERROR = 5, 00527 U_MESSAGE_PARSE_ERROR = 6, 00528 U_MEMORY_ALLOCATION_ERROR = 7, 00529 U_INDEX_OUTOFBOUNDS_ERROR = 8, 00530 U_PARSE_ERROR = 9, 00531 U_INVALID_CHAR_FOUND = 10, 00532 U_TRUNCATED_CHAR_FOUND = 11, 00533 U_ILLEGAL_CHAR_FOUND = 12, 00534 U_INVALID_TABLE_FORMAT = 13, 00535 U_INVALID_TABLE_FILE = 14, 00536 U_BUFFER_OVERFLOW_ERROR = 15, 00537 U_UNSUPPORTED_ERROR = 16, 00538 U_RESOURCE_TYPE_MISMATCH = 17, 00539 U_ILLEGAL_ESCAPE_SEQUENCE = 18, 00540 U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, 00541 U_NO_SPACE_AVAILABLE = 20, 00542 U_CE_NOT_FOUND_ERROR = 21, 00543 U_PRIMARY_TOO_LONG_ERROR = 22, 00544 U_STATE_TOO_OLD_ERROR = 23, 00545 U_TOO_MANY_ALIASES_ERROR = 24, 00547 U_ENUM_OUT_OF_SYNC_ERROR = 25, 00548 U_INVARIANT_CONVERSION_ERROR = 26, 00549 U_INVALID_STATE_ERROR = 27, 00551 U_STANDARD_ERROR_LIMIT, 00552 /* 00553 * the error code range 0x10000 0x10100 are reserved for Transliterator 00554 */ 00555 U_BAD_VARIABLE_DEFINITION=0x10000, 00556 U_PARSE_ERROR_START = 0x10000, 00557 U_MALFORMED_RULE, 00558 U_MALFORMED_SET, 00559 U_MALFORMED_SYMBOL_REFERENCE, 00560 U_MALFORMED_UNICODE_ESCAPE, 00561 U_MALFORMED_VARIABLE_DEFINITION, 00562 U_MALFORMED_VARIABLE_REFERENCE, 00563 U_MISMATCHED_SEGMENT_DELIMITERS, 00564 U_MISPLACED_ANCHOR_START, 00565 U_MISPLACED_CURSOR_OFFSET, 00566 U_MISPLACED_QUANTIFIER, 00567 U_MISSING_OPERATOR, 00568 U_MISSING_SEGMENT_CLOSE, 00569 U_MULTIPLE_ANTE_CONTEXTS, 00570 U_MULTIPLE_CURSORS, 00571 U_MULTIPLE_POST_CONTEXTS, 00572 U_TRAILING_BACKSLASH, 00573 U_UNDEFINED_SEGMENT_REFERENCE, 00574 U_UNDEFINED_VARIABLE, 00575 U_UNQUOTED_SPECIAL, 00576 U_UNTERMINATED_QUOTE, 00577 U_RULE_MASK_ERROR, 00578 U_MISPLACED_COMPOUND_FILTER, 00579 U_MULTIPLE_COMPOUND_FILTERS, 00580 U_INVALID_RBT_SYNTAX, 00581 U_INVALID_PROPERTY_PATTERN, 00582 U_MALFORMED_PRAGMA, 00583 U_UNCLOSED_SEGMENT, 00584 U_ILLEGAL_CHAR_IN_SEGMENT, 00585 U_VARIABLE_RANGE_EXHAUSTED, 00586 U_VARIABLE_RANGE_OVERLAP, 00587 U_ILLEGAL_CHARACTER, 00588 U_INTERNAL_TRANSLITERATOR_ERROR, 00589 U_INVALID_ID, 00590 U_INVALID_FUNCTION, 00591 U_PARSE_ERROR_LIMIT, 00593 /* 00594 * the error code range 0x10100 0x10200 are reserved for formatting API parsing error 00595 */ 00596 U_UNEXPECTED_TOKEN=0x10100, 00597 U_FMT_PARSE_ERROR_START=0x10100, 00598 U_MULTIPLE_DECIMAL_SEPARATORS, 00599 U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, 00600 U_MULTIPLE_EXPONENTIAL_SYMBOLS, 00601 U_MALFORMED_EXPONENTIAL_PATTERN, 00602 U_MULTIPLE_PERCENT_SYMBOLS, 00603 U_MULTIPLE_PERMILL_SYMBOLS, 00604 U_MULTIPLE_PAD_SPECIFIERS, 00605 U_PATTERN_SYNTAX_ERROR, 00606 U_ILLEGAL_PAD_POSITION, 00607 U_UNMATCHED_BRACES, 00608 U_UNSUPPORTED_PROPERTY, 00609 U_UNSUPPORTED_ATTRIBUTE, 00610 U_FMT_PARSE_ERROR_LIMIT, 00612 /* 00613 * the error code range 0x10200 0x102ff are reserved for Break Iterator related error 00614 */ 00615 U_BRK_ERROR_START=0x10200, 00616 U_BRK_INTERNAL_ERROR, 00617 U_BRK_HEX_DIGITS_EXPECTED, 00618 U_BRK_SEMICOLON_EXPECTED, 00619 U_BRK_RULE_SYNTAX, 00620 U_BRK_UNCLOSED_SET, 00621 U_BRK_ASSIGN_ERROR, 00622 U_BRK_VARIABLE_REDFINITION, 00623 U_BRK_MISMATCHED_PAREN, 00624 U_BRK_NEW_LINE_IN_QUOTED_STRING, 00625 U_BRK_UNDEFINED_VARIABLE, 00626 U_BRK_INIT_ERROR, 00627 U_BRK_RULE_EMPTY_SET, 00628 U_BRK_UNRECOGNIZED_OPTION, 00629 U_BRK_ERROR_LIMIT, 00631 /* 00632 * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs 00633 */ 00634 U_REGEX_ERROR_START=0x10300, 00635 U_REGEX_INTERNAL_ERROR, 00636 U_REGEX_RULE_SYNTAX, 00637 U_REGEX_INVALID_STATE, 00638 U_REGEX_BAD_ESCAPE_SEQUENCE, 00639 U_REGEX_PROPERTY_SYNTAX, 00640 U_REGEX_UNIMPLEMENTED, 00641 U_REGEX_MISMATCHED_PAREN, 00642 U_REGEX_NUMBER_TOO_BIG, 00643 U_REGEX_BAD_INTERVAL, 00644 U_REGEX_MAX_LT_MIN, 00645 U_REGEX_INVALID_BACK_REF, 00646 U_REGEX_INVALID_FLAG, 00647 U_REGEX_LOOK_BEHIND_LIMIT, 00648 U_REGEX_SET_CONTAINS_STRING, 00649 U_REGEX_ERROR_LIMIT, 00651 /* 00652 * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes 00653 */ 00654 U_IDNA_ERROR_START=0x10400, 00655 U_IDNA_PROHIBITED_ERROR, 00656 U_IDNA_UNASSIGNED_ERROR, 00657 U_IDNA_CHECK_BIDI_ERROR, 00658 U_IDNA_STD3_ASCII_RULES_ERROR, 00659 U_IDNA_ACE_PREFIX_ERROR, 00660 U_IDNA_VERIFICATION_ERROR, 00661 U_IDNA_LABEL_TOO_LONG_ERROR, 00662 U_IDNA_ERROR_LIMIT, 00663 /* 00664 * Aliases for StringPrep 00665 */ 00666 U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR, 00667 U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR, 00668 U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR, 00669 00670 00671 U_ERROR_LIMIT=U_IDNA_ERROR_LIMIT 00672 } UErrorCode; 00673 00674 /* Use the following to determine if an UErrorCode represents */ 00675 /* operational success or failure. */ 00676 00677 #ifdef XP_CPLUSPLUS 00678 00682 static 00683 inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); } 00688 static 00689 inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); } 00690 #else 00691 00695 # define U_SUCCESS(x) ((x)<=U_ZERO_ERROR) 00696 00700 # define U_FAILURE(x) ((x)>U_ZERO_ERROR) 00701 #endif 00702 00709 U_CAPI const char * U_EXPORT2 00710 u_errorName(UErrorCode code); 00711 00712 00713 00714 /*===========================================================================*/ 00715 /* Include header for platform utilies */ 00716 /*===========================================================================*/ 00717 00718 #include "unicode/putil.h" 00719 00720 #endif /* _UTYPES */

Generated on Wed Jul 28 09:15:54 2004 for ICU 2.8 by doxygen 1.3.7