utypes.h

Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 1996-2005, 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 
00041 #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_DRAFT_API)
00042 #define U_HIDE_DRAFT_API 1
00043 #endif
00044 
00045 #ifdef U_HIDE_DRAFT_API
00046 #include "unicode/udraft.h"
00047 #endif
00048 
00049 #ifdef U_HIDE_DEPRECATED_API
00050 #include "unicode/udeprctd.h"
00051 #endif
00052 
00053 #ifdef U_HIDE_DEPRECATED_API
00054 #include "unicode/uobslete.h"
00055 #endif
00056 
00057 
00068 /*===========================================================================*/
00069 /* char Character set family                                                 */
00070 /*===========================================================================*/
00071 
00076 #define U_ASCII_FAMILY 0
00077 
00082 #define U_EBCDIC_FAMILY 1
00083 
00127 #ifndef U_CHARSET_FAMILY
00128 #   define U_CHARSET_FAMILY 0
00129 #endif
00130 
00131 /*===========================================================================*/
00132 /* ICUDATA naming scheme                                                     */
00133 /*===========================================================================*/
00134 
00151 #if U_CHARSET_FAMILY
00152 #   if U_IS_BIG_ENDIAN
00153    /* EBCDIC - should always be BE */
00154 #     define U_ICUDATA_TYPE_LETTER "e"
00155 #     define U_ICUDATA_TYPE_LITLETTER e
00156 #   else
00157 #     error "Don't know what to do with little endian EBCDIC!"
00158 #     define U_ICUDATA_TYPE_LETTER "x"
00159 #     define U_ICUDATA_TYPE_LITLETTER x
00160 #   endif
00161 #else
00162 #   if U_IS_BIG_ENDIAN
00163       /* Big-endian ASCII */
00164 #     define U_ICUDATA_TYPE_LETTER "b"
00165 #     define U_ICUDATA_TYPE_LITLETTER b
00166 #   else
00167       /* Little-endian ASCII */
00168 #     define U_ICUDATA_TYPE_LETTER "l"
00169 #     define U_ICUDATA_TYPE_LITLETTER l
00170 #   endif
00171 #endif
00172 
00178 #define U_ICUDATA_NAME    "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER
00179 
00180 
00192 #define U_ICUDATA_ENTRY_POINT  U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM, U_ICU_VERSION_MINOR_NUM)
00193 
00196 #define U_DEF2_ICUDATA_ENTRY_POINT(major, minor) U_DEF_ICUDATA_ENTRY_POINT(major, minor)
00197 
00200 #define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt##major##minor##_dat
00201 
00213 #if defined(OS390) && (__COMPILER_VER__ < 0x41020000) && defined(XP_CPLUSPLUS)
00214 #    define U_CALLCONV __cdecl
00215 #else
00216 #    define U_CALLCONV U_EXPORT2
00217 #endif
00218 
00224 #ifndef NULL
00225 #ifdef XP_CPLUSPLUS
00226 #define NULL    0
00227 #else
00228 #define NULL    ((void *)0)
00229 #endif
00230 #endif
00231 
00232 /*===========================================================================*/
00233 /* Calendar/TimeZone data types                                              */
00234 /*===========================================================================*/
00235 
00243 typedef double UDate;
00244 
00246 #define U_MILLIS_PER_SECOND        (1000)
00247 
00248 #define U_MILLIS_PER_MINUTE       (60000)
00249 
00250 #define U_MILLIS_PER_HOUR       (3600000)
00251 
00252 #define U_MILLIS_PER_DAY       (86400000)
00253 
00254 
00255 /*===========================================================================*/
00256 /* UClassID-based RTTI */
00257 /*===========================================================================*/
00258 
00301 typedef void* UClassID;
00302 
00303 /*===========================================================================*/
00304 /* Shared library/DLL import-export API control                              */
00305 /*===========================================================================*/
00306 
00307 /*
00308  * Control of symbol import/export.
00309  * ICU is separated into three libraries.
00310  */
00311 
00312 /*
00313  * \def U_COMBINED_IMPLEMENTATION
00314  * Set to export library symbols from inside the ICU library
00315  * when all of ICU is in a single library.
00316  * This can be set as a compiler option while building ICU, and it
00317  * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc.
00318  * @stable ICU 2.0
00319  */
00320 
00370 #if defined(U_COMBINED_IMPLEMENTATION)
00371 #define U_DATA_API     U_EXPORT
00372 #define U_COMMON_API   U_EXPORT
00373 #define U_I18N_API     U_EXPORT
00374 #define U_LAYOUT_API   U_EXPORT
00375 #define U_LAYOUTEX_API U_EXPORT
00376 #define U_IO_API       U_EXPORT
00377 #define U_TOOLUTIL_API U_EXPORT
00378 #elif defined(U_STATIC_IMPLEMENTATION)
00379 #define U_DATA_API
00380 #define U_COMMON_API
00381 #define U_I18N_API
00382 #define U_LAYOUT_API
00383 #define U_LAYOUTEX_API
00384 #define U_IO_API
00385 #define U_TOOLUTIL_API
00386 #elif defined(U_COMMON_IMPLEMENTATION)
00387 #define U_DATA_API     U_IMPORT
00388 #define U_COMMON_API   U_EXPORT
00389 #define U_I18N_API     U_IMPORT
00390 #define U_LAYOUT_API   U_IMPORT
00391 #define U_LAYOUTEX_API U_IMPORT
00392 #define U_IO_API       U_IMPORT
00393 #define U_TOOLUTIL_API U_IMPORT
00394 #elif defined(U_I18N_IMPLEMENTATION)
00395 #define U_DATA_API     U_IMPORT
00396 #define U_COMMON_API   U_IMPORT
00397 #define U_I18N_API     U_EXPORT
00398 #define U_LAYOUT_API   U_IMPORT
00399 #define U_LAYOUTEX_API U_IMPORT
00400 #define U_IO_API       U_IMPORT
00401 #define U_TOOLUTIL_API U_IMPORT
00402 #elif defined(U_LAYOUT_IMPLEMENTATION)
00403 #define U_DATA_API     U_IMPORT
00404 #define U_COMMON_API   U_IMPORT
00405 #define U_I18N_API     U_IMPORT
00406 #define U_LAYOUT_API   U_EXPORT
00407 #define U_LAYOUTEX_API U_IMPORT
00408 #define U_IO_API       U_IMPORT
00409 #define U_TOOLUTIL_API U_IMPORT
00410 #elif defined(U_LAYOUTEX_IMPLEMENTATION)
00411 #define U_DATA_API     U_IMPORT
00412 #define U_COMMON_API   U_IMPORT
00413 #define U_I18N_API     U_IMPORT
00414 #define U_LAYOUT_API   U_IMPORT
00415 #define U_LAYOUTEX_API U_EXPORT
00416 #define U_IO_API       U_IMPORT
00417 #define U_TOOLUTIL_API U_IMPORT
00418 #elif defined(U_IO_IMPLEMENTATION)
00419 #define U_DATA_API     U_IMPORT
00420 #define U_COMMON_API   U_IMPORT
00421 #define U_I18N_API     U_IMPORT
00422 #define U_LAYOUT_API   U_IMPORT
00423 #define U_LAYOUTEX_API U_IMPORT
00424 #define U_IO_API       U_EXPORT
00425 #define U_TOOLUTIL_API U_IMPORT
00426 #elif defined(U_TOOLUTIL_IMPLEMENTATION)
00427 #define U_DATA_API     U_IMPORT
00428 #define U_COMMON_API   U_IMPORT
00429 #define U_I18N_API     U_IMPORT
00430 #define U_LAYOUT_API   U_IMPORT
00431 #define U_LAYOUTEX_API U_IMPORT
00432 #define U_IO_API       U_IMPORT
00433 #define U_TOOLUTIL_API U_EXPORT
00434 #else
00435 #define U_DATA_API     U_IMPORT
00436 #define U_COMMON_API   U_IMPORT
00437 #define U_I18N_API     U_IMPORT
00438 #define U_LAYOUT_API   U_IMPORT
00439 #define U_LAYOUTEX_API U_IMPORT
00440 #define U_IO_API       U_IMPORT
00441 #define U_TOOLUTIL_API U_IMPORT
00442 #endif
00443 
00449 #ifdef __cplusplus
00450 #define U_STANDARD_CPP_NAMESPACE        ::
00451 #else
00452 #define U_STANDARD_CPP_NAMESPACE
00453 #endif
00454 
00455 
00456 /*===========================================================================*/
00457 /* Global delete operator                                                    */
00458 /*===========================================================================*/
00459 
00460 /*
00461  * The ICU4C library must not use the global new and delete operators.
00462  * These operators here are defined to enable testing for this.
00463  * See Jitterbug 2581 for details of why this is necessary.
00464  *
00465  * Verification that ICU4C's memory usage is correct, i.e.,
00466  * that global new/delete are not used:
00467  *
00468  * a) Check for imports of global new/delete (see uobject.cpp for details)
00469  * b) Verify that new is never imported.
00470  * c) Verify that delete is only imported from object code for interface/mixin classes.
00471  * d) Add global delete and delete[] only for the ICU4C library itself
00472  *    and define them in a way that crashes or otherwise easily shows a problem.
00473  *
00474  * The following implements d).
00475  * The operator implementations crash; this is intentional and used for library debugging.
00476  *
00477  * Note: This is currently only done on Windows because
00478  * some Linux/Unix compilers have problems with defining global new/delete.
00479  * On Windows, WIN32 is defined, and it is _MSC_Ver>=1200 for MSVC 6.0 and higher.
00480  */
00481 #if defined(XP_CPLUSPLUS) && defined(U_WINDOWS) && (_MSC_Ver>=1200) && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_USTDIO_IMPLEMENTATION))
00482 
00488 inline void *
00489 operator new(size_t /*size*/) {
00490     char *q=NULL;
00491     *q=5; /* break it */
00492     return q;
00493 }
00494 
00500 inline void *
00501 operator new[](size_t /*size*/) {
00502     char *q=NULL;
00503     *q=5; /* break it */
00504     return q;
00505 }
00506 
00512 inline void
00513 operator delete(void * /*p*/) {
00514     char *q=NULL;
00515     *q=5; /* break it */
00516 }
00517 
00523 inline void
00524 operator delete[](void * /*p*/) {
00525     char *q=NULL;
00526     *q=5; /* break it */
00527 }
00528 
00529 #endif
00530 
00531 /*===========================================================================*/
00532 /* UErrorCode */
00533 /*===========================================================================*/
00534 
00549 typedef enum UErrorCode {
00550     /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird
00551      * and is that way because VC++ debugger displays first encountered constant,
00552      * which is not the what the code is used for
00553      */
00554 
00555     U_USING_FALLBACK_WARNING  = -128,   
00557     U_ERROR_WARNING_START     = -128,   
00559     U_USING_DEFAULT_WARNING   = -127,   
00561     U_SAFECLONE_ALLOCATED_WARNING = -126, 
00563     U_STATE_OLD_WARNING       = -125,   
00565     U_STRING_NOT_TERMINATED_WARNING = -124,
00567     U_SORT_KEY_TOO_SHORT_WARNING = -123, 
00569     U_AMBIGUOUS_ALIAS_WARNING = -122,   
00571     U_DIFFERENT_UCA_VERSION = -121,     
00573     U_ERROR_WARNING_LIMIT,              
00576     U_ZERO_ERROR              =  0,     
00578     U_ILLEGAL_ARGUMENT_ERROR  =  1,     
00579     U_MISSING_RESOURCE_ERROR  =  2,     
00580     U_INVALID_FORMAT_ERROR    =  3,     
00581     U_FILE_ACCESS_ERROR       =  4,     
00582     U_INTERNAL_PROGRAM_ERROR  =  5,     
00583     U_MESSAGE_PARSE_ERROR     =  6,     
00584     U_MEMORY_ALLOCATION_ERROR =  7,     
00585     U_INDEX_OUTOFBOUNDS_ERROR =  8,     
00586     U_PARSE_ERROR             =  9,     
00587     U_INVALID_CHAR_FOUND      = 10,     
00588     U_TRUNCATED_CHAR_FOUND    = 11,     
00589     U_ILLEGAL_CHAR_FOUND      = 12,     
00590     U_INVALID_TABLE_FORMAT    = 13,     
00591     U_INVALID_TABLE_FILE      = 14,     
00592     U_BUFFER_OVERFLOW_ERROR   = 15,     
00593     U_UNSUPPORTED_ERROR       = 16,     
00594     U_RESOURCE_TYPE_MISMATCH  = 17,     
00595     U_ILLEGAL_ESCAPE_SEQUENCE = 18,     
00596     U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, 
00597     U_NO_SPACE_AVAILABLE      = 20,     
00598     U_CE_NOT_FOUND_ERROR      = 21,     
00599     U_PRIMARY_TOO_LONG_ERROR  = 22,     
00600     U_STATE_TOO_OLD_ERROR     = 23,     
00601     U_TOO_MANY_ALIASES_ERROR  = 24,     
00603     U_ENUM_OUT_OF_SYNC_ERROR  = 25,     
00604     U_INVARIANT_CONVERSION_ERROR = 26,  
00605     U_INVALID_STATE_ERROR     = 27,     
00606     U_COLLATOR_VERSION_MISMATCH = 28,   
00607     U_USELESS_COLLATOR_ERROR  = 29,     
00608     U_NO_WRITE_PERMISSION     = 30,     
00610     U_STANDARD_ERROR_LIMIT,             
00611     /*
00612      * the error code range 0x10000 0x10100 are reserved for Transliterator
00613      */
00614     U_BAD_VARIABLE_DEFINITION=0x10000,
00615     U_PARSE_ERROR_START = 0x10000,    
00616     U_MALFORMED_RULE,                 
00617     U_MALFORMED_SET,                  
00618     U_MALFORMED_SYMBOL_REFERENCE,     
00619     U_MALFORMED_UNICODE_ESCAPE,       
00620     U_MALFORMED_VARIABLE_DEFINITION,  
00621     U_MALFORMED_VARIABLE_REFERENCE,   
00622     U_MISMATCHED_SEGMENT_DELIMITERS,  
00623     U_MISPLACED_ANCHOR_START,         
00624     U_MISPLACED_CURSOR_OFFSET,        
00625     U_MISPLACED_QUANTIFIER,           
00626     U_MISSING_OPERATOR,               
00627     U_MISSING_SEGMENT_CLOSE,          
00628     U_MULTIPLE_ANTE_CONTEXTS,         
00629     U_MULTIPLE_CURSORS,               
00630     U_MULTIPLE_POST_CONTEXTS,         
00631     U_TRAILING_BACKSLASH,             
00632     U_UNDEFINED_SEGMENT_REFERENCE,    
00633     U_UNDEFINED_VARIABLE,             
00634     U_UNQUOTED_SPECIAL,               
00635     U_UNTERMINATED_QUOTE,             
00636     U_RULE_MASK_ERROR,                
00637     U_MISPLACED_COMPOUND_FILTER,      
00638     U_MULTIPLE_COMPOUND_FILTERS,      
00639     U_INVALID_RBT_SYNTAX,             
00640     U_INVALID_PROPERTY_PATTERN,       
00641     U_MALFORMED_PRAGMA,               
00642     U_UNCLOSED_SEGMENT,               
00643     U_ILLEGAL_CHAR_IN_SEGMENT,        
00644     U_VARIABLE_RANGE_EXHAUSTED,       
00645     U_VARIABLE_RANGE_OVERLAP,         
00646     U_ILLEGAL_CHARACTER,              
00647     U_INTERNAL_TRANSLITERATOR_ERROR,  
00648     U_INVALID_ID,                     
00649     U_INVALID_FUNCTION,               
00650     U_PARSE_ERROR_LIMIT,              
00652     /*
00653      * the error code range 0x10100 0x10200 are reserved for formatting API parsing error
00654      */
00655     U_UNEXPECTED_TOKEN=0x10100,       
00656     U_FMT_PARSE_ERROR_START=0x10100,  
00657     U_MULTIPLE_DECIMAL_SEPARATORS,    
00658     U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, 
00659     U_MULTIPLE_EXPONENTIAL_SYMBOLS,   
00660     U_MALFORMED_EXPONENTIAL_PATTERN,  
00661     U_MULTIPLE_PERCENT_SYMBOLS,       
00662     U_MULTIPLE_PERMILL_SYMBOLS,       
00663     U_MULTIPLE_PAD_SPECIFIERS,        
00664     U_PATTERN_SYNTAX_ERROR,           
00665     U_ILLEGAL_PAD_POSITION,           
00666     U_UNMATCHED_BRACES,               
00667     U_UNSUPPORTED_PROPERTY,           
00668     U_UNSUPPORTED_ATTRIBUTE,          
00669     U_FMT_PARSE_ERROR_LIMIT,          
00671     /*
00672      * the error code range 0x10200 0x102ff are reserved for Break Iterator related error
00673      */
00674     U_BRK_ERROR_START=0x10200,             
00675     U_BRK_INTERNAL_ERROR,                  
00676     U_BRK_HEX_DIGITS_EXPECTED,             
00677     U_BRK_SEMICOLON_EXPECTED,              
00678     U_BRK_RULE_SYNTAX,                     
00679     U_BRK_UNCLOSED_SET,                    
00680     U_BRK_ASSIGN_ERROR,                    
00681     U_BRK_VARIABLE_REDFINITION,            
00682     U_BRK_MISMATCHED_PAREN,                
00683     U_BRK_NEW_LINE_IN_QUOTED_STRING,       
00684     U_BRK_UNDEFINED_VARIABLE,              
00685     U_BRK_INIT_ERROR,                      
00686     U_BRK_RULE_EMPTY_SET,                  
00687     U_BRK_UNRECOGNIZED_OPTION,             
00688     U_BRK_MALFORMED_RULE_TAG,              
00689     U_BRK_ERROR_LIMIT,                     
00691     /*
00692      * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs
00693      */
00694     U_REGEX_ERROR_START=0x10300,          
00695     U_REGEX_INTERNAL_ERROR,               
00696     U_REGEX_RULE_SYNTAX,                  
00697     U_REGEX_INVALID_STATE,                
00698     U_REGEX_BAD_ESCAPE_SEQUENCE,          
00699     U_REGEX_PROPERTY_SYNTAX,              
00700     U_REGEX_UNIMPLEMENTED,                
00701     U_REGEX_MISMATCHED_PAREN,             
00702     U_REGEX_NUMBER_TOO_BIG,               
00703     U_REGEX_BAD_INTERVAL,                 
00704     U_REGEX_MAX_LT_MIN,                   
00705     U_REGEX_INVALID_BACK_REF,             
00706     U_REGEX_INVALID_FLAG,                 
00707     U_REGEX_LOOK_BEHIND_LIMIT,            
00708     U_REGEX_SET_CONTAINS_STRING,          
00709     U_REGEX_ERROR_LIMIT,                  
00711     /*
00712      * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes
00713      */
00714     U_IDNA_ERROR_START=0x10400,
00715     U_IDNA_PROHIBITED_ERROR,
00716     U_IDNA_UNASSIGNED_ERROR,
00717     U_IDNA_CHECK_BIDI_ERROR,
00718     U_IDNA_STD3_ASCII_RULES_ERROR,
00719     U_IDNA_ACE_PREFIX_ERROR,
00720     U_IDNA_VERIFICATION_ERROR,
00721     U_IDNA_LABEL_TOO_LONG_ERROR,
00722     U_IDNA_ERROR_LIMIT,
00723     /*
00724      * Aliases for StringPrep
00725      */
00726     U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR,
00727     U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR,
00728     U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR,
00729 
00730 
00731     U_ERROR_LIMIT=U_IDNA_ERROR_LIMIT      
00732 } UErrorCode;
00733 
00734 /* Use the following to determine if an UErrorCode represents */
00735 /* operational success or failure. */
00736 
00737 #ifdef XP_CPLUSPLUS
00738 
00742     static
00743     inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); }
00748     static
00749     inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); }
00750 #else
00751 
00755 #   define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)
00756 
00760 #   define U_FAILURE(x) ((x)>U_ZERO_ERROR)
00761 #endif
00762 
00769 U_STABLE const char * U_EXPORT2
00770 u_errorName(UErrorCode code);
00771 
00772 
00773 #endif /* _UTYPES */

Generated on Sat Feb 11 17:42:28 2006 for ICU 3.4 by  doxygen 1.4.6