utypes.h

Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 1996-2006, 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 #ifdef U_HIDE_INTERNAL_API
00058 #include "unicode/uintrnal.h"
00059 #endif
00060 
00061 #ifdef U_HIDE_SYSTEM_API
00062 #include "unicode/usystem.h"
00063 #endif
00064 
00075 /*===========================================================================*/
00076 /* char Character set family                                                 */
00077 /*===========================================================================*/
00078 
00083 #define U_ASCII_FAMILY 0
00084 
00089 #define U_EBCDIC_FAMILY 1
00090 
00134 #ifndef U_CHARSET_FAMILY
00135 #   define U_CHARSET_FAMILY 0
00136 #endif
00137 
00138 /*===========================================================================*/
00139 /* ICUDATA naming scheme                                                     */
00140 /*===========================================================================*/
00141 
00158 #if U_CHARSET_FAMILY
00159 #   if U_IS_BIG_ENDIAN
00160    /* EBCDIC - should always be BE */
00161 #     define U_ICUDATA_TYPE_LETTER "e"
00162 #     define U_ICUDATA_TYPE_LITLETTER e
00163 #   else
00164 #     error "Don't know what to do with little endian EBCDIC!"
00165 #     define U_ICUDATA_TYPE_LETTER "x"
00166 #     define U_ICUDATA_TYPE_LITLETTER x
00167 #   endif
00168 #else
00169 #   if U_IS_BIG_ENDIAN
00170       /* Big-endian ASCII */
00171 #     define U_ICUDATA_TYPE_LETTER "b"
00172 #     define U_ICUDATA_TYPE_LITLETTER b
00173 #   else
00174       /* Little-endian ASCII */
00175 #     define U_ICUDATA_TYPE_LETTER "l"
00176 #     define U_ICUDATA_TYPE_LITLETTER l
00177 #   endif
00178 #endif
00179 
00185 #define U_ICUDATA_NAME    "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER
00186 
00187 
00199 #define U_ICUDATA_ENTRY_POINT  U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM, U_ICU_VERSION_MINOR_NUM)
00200 
00205 #define U_DEF2_ICUDATA_ENTRY_POINT(major, minor) U_DEF_ICUDATA_ENTRY_POINT(major, minor)
00206 
00210 #define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt##major##minor##_dat
00211 
00223 #if defined(OS390) && (__COMPILER_VER__ < 0x41020000) && defined(XP_CPLUSPLUS)
00224 #    define U_CALLCONV __cdecl
00225 #else
00226 #    define U_CALLCONV U_EXPORT2
00227 #endif
00228 
00234 #ifndef NULL
00235 #ifdef XP_CPLUSPLUS
00236 #define NULL    0
00237 #else
00238 #define NULL    ((void *)0)
00239 #endif
00240 #endif
00241 
00242 /*===========================================================================*/
00243 /* Calendar/TimeZone data types                                              */
00244 /*===========================================================================*/
00245 
00253 typedef double UDate;
00254 
00256 #define U_MILLIS_PER_SECOND        (1000)
00257 
00258 #define U_MILLIS_PER_MINUTE       (60000)
00259 
00260 #define U_MILLIS_PER_HOUR       (3600000)
00261 
00262 #define U_MILLIS_PER_DAY       (86400000)
00263 
00264 
00265 /*===========================================================================*/
00266 /* UClassID-based RTTI */
00267 /*===========================================================================*/
00268 
00311 typedef void* UClassID;
00312 
00313 /*===========================================================================*/
00314 /* Shared library/DLL import-export API control                              */
00315 /*===========================================================================*/
00316 
00317 /*
00318  * Control of symbol import/export.
00319  * ICU is separated into three libraries.
00320  */
00321 
00322 /*
00323  * \def U_COMBINED_IMPLEMENTATION
00324  * Set to export library symbols from inside the ICU library
00325  * when all of ICU is in a single library.
00326  * This can be set as a compiler option while building ICU, and it
00327  * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc.
00328  * @stable ICU 2.0
00329  */
00330 
00380 #if defined(U_COMBINED_IMPLEMENTATION)
00381 #define U_DATA_API     U_EXPORT
00382 #define U_COMMON_API   U_EXPORT
00383 #define U_I18N_API     U_EXPORT
00384 #define U_LAYOUT_API   U_EXPORT
00385 #define U_LAYOUTEX_API U_EXPORT
00386 #define U_IO_API       U_EXPORT
00387 #define U_TOOLUTIL_API U_EXPORT
00388 #elif defined(U_STATIC_IMPLEMENTATION)
00389 #define U_DATA_API
00390 #define U_COMMON_API
00391 #define U_I18N_API
00392 #define U_LAYOUT_API
00393 #define U_LAYOUTEX_API
00394 #define U_IO_API
00395 #define U_TOOLUTIL_API
00396 #elif defined(U_COMMON_IMPLEMENTATION)
00397 #define U_DATA_API     U_IMPORT
00398 #define U_COMMON_API   U_EXPORT
00399 #define U_I18N_API     U_IMPORT
00400 #define U_LAYOUT_API   U_IMPORT
00401 #define U_LAYOUTEX_API U_IMPORT
00402 #define U_IO_API       U_IMPORT
00403 #define U_TOOLUTIL_API U_IMPORT
00404 #elif defined(U_I18N_IMPLEMENTATION)
00405 #define U_DATA_API     U_IMPORT
00406 #define U_COMMON_API   U_IMPORT
00407 #define U_I18N_API     U_EXPORT
00408 #define U_LAYOUT_API   U_IMPORT
00409 #define U_LAYOUTEX_API U_IMPORT
00410 #define U_IO_API       U_IMPORT
00411 #define U_TOOLUTIL_API U_IMPORT
00412 #elif defined(U_LAYOUT_IMPLEMENTATION)
00413 #define U_DATA_API     U_IMPORT
00414 #define U_COMMON_API   U_IMPORT
00415 #define U_I18N_API     U_IMPORT
00416 #define U_LAYOUT_API   U_EXPORT
00417 #define U_LAYOUTEX_API U_IMPORT
00418 #define U_IO_API       U_IMPORT
00419 #define U_TOOLUTIL_API U_IMPORT
00420 #elif defined(U_LAYOUTEX_IMPLEMENTATION)
00421 #define U_DATA_API     U_IMPORT
00422 #define U_COMMON_API   U_IMPORT
00423 #define U_I18N_API     U_IMPORT
00424 #define U_LAYOUT_API   U_IMPORT
00425 #define U_LAYOUTEX_API U_EXPORT
00426 #define U_IO_API       U_IMPORT
00427 #define U_TOOLUTIL_API U_IMPORT
00428 #elif defined(U_IO_IMPLEMENTATION)
00429 #define U_DATA_API     U_IMPORT
00430 #define U_COMMON_API   U_IMPORT
00431 #define U_I18N_API     U_IMPORT
00432 #define U_LAYOUT_API   U_IMPORT
00433 #define U_LAYOUTEX_API U_IMPORT
00434 #define U_IO_API       U_EXPORT
00435 #define U_TOOLUTIL_API U_IMPORT
00436 #elif defined(U_TOOLUTIL_IMPLEMENTATION)
00437 #define U_DATA_API     U_IMPORT
00438 #define U_COMMON_API   U_IMPORT
00439 #define U_I18N_API     U_IMPORT
00440 #define U_LAYOUT_API   U_IMPORT
00441 #define U_LAYOUTEX_API U_IMPORT
00442 #define U_IO_API       U_IMPORT
00443 #define U_TOOLUTIL_API U_EXPORT
00444 #else
00445 #define U_DATA_API     U_IMPORT
00446 #define U_COMMON_API   U_IMPORT
00447 #define U_I18N_API     U_IMPORT
00448 #define U_LAYOUT_API   U_IMPORT
00449 #define U_LAYOUTEX_API U_IMPORT
00450 #define U_IO_API       U_IMPORT
00451 #define U_TOOLUTIL_API U_IMPORT
00452 #endif
00453 
00459 #ifdef __cplusplus
00460 #define U_STANDARD_CPP_NAMESPACE        ::
00461 #else
00462 #define U_STANDARD_CPP_NAMESPACE
00463 #endif
00464 
00465 
00466 /*===========================================================================*/
00467 /* Global delete operator                                                    */
00468 /*===========================================================================*/
00469 
00470 /*
00471  * The ICU4C library must not use the global new and delete operators.
00472  * These operators here are defined to enable testing for this.
00473  * See Jitterbug 2581 for details of why this is necessary.
00474  *
00475  * Verification that ICU4C's memory usage is correct, i.e.,
00476  * that global new/delete are not used:
00477  *
00478  * a) Check for imports of global new/delete (see uobject.cpp for details)
00479  * b) Verify that new is never imported.
00480  * c) Verify that delete is only imported from object code for interface/mixin classes.
00481  * d) Add global delete and delete[] only for the ICU4C library itself
00482  *    and define them in a way that crashes or otherwise easily shows a problem.
00483  *
00484  * The following implements d).
00485  * The operator implementations crash; this is intentional and used for library debugging.
00486  *
00487  * Note: This is currently only done on Windows because
00488  * some Linux/Unix compilers have problems with defining global new/delete.
00489  * On Windows, WIN32 is defined, and it is _MSC_VER>=1200 for MSVC 6.0 and higher.
00490  */
00491 #if defined(XP_CPLUSPLUS) && defined(U_WINDOWS) && (_MSC_VER>=1200) && U_DEBUG && (defined(U_COMMON_IMPLEMENTATION) || defined(U_I18N_IMPLEMENTATION) || defined(U_LAYOUT_IMPLEMENTATION) || defined(U_USTDIO_IMPLEMENTATION))
00492 
00493 #ifndef U_HIDE_INTERNAL_API
00494 
00499 inline void *
00500 operator new(size_t /*size*/) {
00501     char *q=NULL;
00502     *q=5; /* break it */
00503     return q;
00504 }
00505 
00511 inline void *
00512 operator new[](size_t /*size*/) {
00513     char *q=NULL;
00514     *q=5; /* break it */
00515     return q;
00516 }
00517 
00523 inline void
00524 operator delete(void * /*p*/) {
00525     char *q=NULL;
00526     *q=5; /* break it */
00527 }
00528 
00534 inline void
00535 operator delete[](void * /*p*/) {
00536     char *q=NULL;
00537     *q=5; /* break it */
00538 }
00539 
00540 #endif /* U_HIDE_INTERNAL_API */
00541 #endif
00542 
00543 /*===========================================================================*/
00544 /* UErrorCode */
00545 /*===========================================================================*/
00546 
00561 typedef enum UErrorCode {
00562     /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird
00563      * and is that way because VC++ debugger displays first encountered constant,
00564      * which is not the what the code is used for
00565      */
00566 
00567     U_USING_FALLBACK_WARNING  = -128,   
00569     U_ERROR_WARNING_START     = -128,   
00571     U_USING_DEFAULT_WARNING   = -127,   
00573     U_SAFECLONE_ALLOCATED_WARNING = -126, 
00575     U_STATE_OLD_WARNING       = -125,   
00577     U_STRING_NOT_TERMINATED_WARNING = -124,
00579     U_SORT_KEY_TOO_SHORT_WARNING = -123, 
00581     U_AMBIGUOUS_ALIAS_WARNING = -122,   
00583     U_DIFFERENT_UCA_VERSION = -121,     
00585     U_ERROR_WARNING_LIMIT,              
00588     U_ZERO_ERROR              =  0,     
00590     U_ILLEGAL_ARGUMENT_ERROR  =  1,     
00591     U_MISSING_RESOURCE_ERROR  =  2,     
00592     U_INVALID_FORMAT_ERROR    =  3,     
00593     U_FILE_ACCESS_ERROR       =  4,     
00594     U_INTERNAL_PROGRAM_ERROR  =  5,     
00595     U_MESSAGE_PARSE_ERROR     =  6,     
00596     U_MEMORY_ALLOCATION_ERROR =  7,     
00597     U_INDEX_OUTOFBOUNDS_ERROR =  8,     
00598     U_PARSE_ERROR             =  9,     
00599     U_INVALID_CHAR_FOUND      = 10,     
00600     U_TRUNCATED_CHAR_FOUND    = 11,     
00601     U_ILLEGAL_CHAR_FOUND      = 12,     
00602     U_INVALID_TABLE_FORMAT    = 13,     
00603     U_INVALID_TABLE_FILE      = 14,     
00604     U_BUFFER_OVERFLOW_ERROR   = 15,     
00605     U_UNSUPPORTED_ERROR       = 16,     
00606     U_RESOURCE_TYPE_MISMATCH  = 17,     
00607     U_ILLEGAL_ESCAPE_SEQUENCE = 18,     
00608     U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, 
00609     U_NO_SPACE_AVAILABLE      = 20,     
00610     U_CE_NOT_FOUND_ERROR      = 21,     
00611     U_PRIMARY_TOO_LONG_ERROR  = 22,     
00612     U_STATE_TOO_OLD_ERROR     = 23,     
00613     U_TOO_MANY_ALIASES_ERROR  = 24,     
00615     U_ENUM_OUT_OF_SYNC_ERROR  = 25,     
00616     U_INVARIANT_CONVERSION_ERROR = 26,  
00617     U_INVALID_STATE_ERROR     = 27,     
00618     U_COLLATOR_VERSION_MISMATCH = 28,   
00619     U_USELESS_COLLATOR_ERROR  = 29,     
00620     U_NO_WRITE_PERMISSION     = 30,     
00622     U_STANDARD_ERROR_LIMIT,             
00623     /*
00624      * the error code range 0x10000 0x10100 are reserved for Transliterator
00625      */
00626     U_BAD_VARIABLE_DEFINITION=0x10000,
00627     U_PARSE_ERROR_START = 0x10000,    
00628     U_MALFORMED_RULE,                 
00629     U_MALFORMED_SET,                  
00630     U_MALFORMED_SYMBOL_REFERENCE,     
00631     U_MALFORMED_UNICODE_ESCAPE,       
00632     U_MALFORMED_VARIABLE_DEFINITION,  
00633     U_MALFORMED_VARIABLE_REFERENCE,   
00634     U_MISMATCHED_SEGMENT_DELIMITERS,  
00635     U_MISPLACED_ANCHOR_START,         
00636     U_MISPLACED_CURSOR_OFFSET,        
00637     U_MISPLACED_QUANTIFIER,           
00638     U_MISSING_OPERATOR,               
00639     U_MISSING_SEGMENT_CLOSE,          
00640     U_MULTIPLE_ANTE_CONTEXTS,         
00641     U_MULTIPLE_CURSORS,               
00642     U_MULTIPLE_POST_CONTEXTS,         
00643     U_TRAILING_BACKSLASH,             
00644     U_UNDEFINED_SEGMENT_REFERENCE,    
00645     U_UNDEFINED_VARIABLE,             
00646     U_UNQUOTED_SPECIAL,               
00647     U_UNTERMINATED_QUOTE,             
00648     U_RULE_MASK_ERROR,                
00649     U_MISPLACED_COMPOUND_FILTER,      
00650     U_MULTIPLE_COMPOUND_FILTERS,      
00651     U_INVALID_RBT_SYNTAX,             
00652     U_INVALID_PROPERTY_PATTERN,       
00653     U_MALFORMED_PRAGMA,               
00654     U_UNCLOSED_SEGMENT,               
00655     U_ILLEGAL_CHAR_IN_SEGMENT,        
00656     U_VARIABLE_RANGE_EXHAUSTED,       
00657     U_VARIABLE_RANGE_OVERLAP,         
00658     U_ILLEGAL_CHARACTER,              
00659     U_INTERNAL_TRANSLITERATOR_ERROR,  
00660     U_INVALID_ID,                     
00661     U_INVALID_FUNCTION,               
00662     U_PARSE_ERROR_LIMIT,              
00664     /*
00665      * the error code range 0x10100 0x10200 are reserved for formatting API parsing error
00666      */
00667     U_UNEXPECTED_TOKEN=0x10100,       
00668     U_FMT_PARSE_ERROR_START=0x10100,  
00669     U_MULTIPLE_DECIMAL_SEPARATORS,    
00670     U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, 
00671     U_MULTIPLE_EXPONENTIAL_SYMBOLS,   
00672     U_MALFORMED_EXPONENTIAL_PATTERN,  
00673     U_MULTIPLE_PERCENT_SYMBOLS,       
00674     U_MULTIPLE_PERMILL_SYMBOLS,       
00675     U_MULTIPLE_PAD_SPECIFIERS,        
00676     U_PATTERN_SYNTAX_ERROR,           
00677     U_ILLEGAL_PAD_POSITION,           
00678     U_UNMATCHED_BRACES,               
00679     U_UNSUPPORTED_PROPERTY,           
00680     U_UNSUPPORTED_ATTRIBUTE,          
00681     U_FMT_PARSE_ERROR_LIMIT,          
00683     /*
00684      * the error code range 0x10200 0x102ff are reserved for Break Iterator related error
00685      */
00686     U_BRK_INTERNAL_ERROR=0x10200,          
00687     U_BRK_ERROR_START=0x10200,             
00688     U_BRK_HEX_DIGITS_EXPECTED,             
00689     U_BRK_SEMICOLON_EXPECTED,              
00690     U_BRK_RULE_SYNTAX,                     
00691     U_BRK_UNCLOSED_SET,                    
00692     U_BRK_ASSIGN_ERROR,                    
00693     U_BRK_VARIABLE_REDFINITION,            
00694     U_BRK_MISMATCHED_PAREN,                
00695     U_BRK_NEW_LINE_IN_QUOTED_STRING,       
00696     U_BRK_UNDEFINED_VARIABLE,              
00697     U_BRK_INIT_ERROR,                      
00698     U_BRK_RULE_EMPTY_SET,                  
00699     U_BRK_UNRECOGNIZED_OPTION,             
00700     U_BRK_MALFORMED_RULE_TAG,              
00701     U_BRK_ERROR_LIMIT,                     
00703     /*
00704      * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs
00705      */
00706     U_REGEX_INTERNAL_ERROR=0x10300,       
00707     U_REGEX_ERROR_START=0x10300,          
00708     U_REGEX_RULE_SYNTAX,                  
00709     U_REGEX_INVALID_STATE,                
00710     U_REGEX_BAD_ESCAPE_SEQUENCE,          
00711     U_REGEX_PROPERTY_SYNTAX,              
00712     U_REGEX_UNIMPLEMENTED,                
00713     U_REGEX_MISMATCHED_PAREN,             
00714     U_REGEX_NUMBER_TOO_BIG,               
00715     U_REGEX_BAD_INTERVAL,                 
00716     U_REGEX_MAX_LT_MIN,                   
00717     U_REGEX_INVALID_BACK_REF,             
00718     U_REGEX_INVALID_FLAG,                 
00719     U_REGEX_LOOK_BEHIND_LIMIT,            
00720     U_REGEX_SET_CONTAINS_STRING,          
00721     U_REGEX_ERROR_LIMIT,                  
00723     /*
00724      * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes
00725      */
00726     U_IDNA_PROHIBITED_ERROR=0x10400,
00727     U_IDNA_ERROR_START=0x10400,
00728     U_IDNA_UNASSIGNED_ERROR,
00729     U_IDNA_CHECK_BIDI_ERROR,
00730     U_IDNA_STD3_ASCII_RULES_ERROR,
00731     U_IDNA_ACE_PREFIX_ERROR,
00732     U_IDNA_VERIFICATION_ERROR,
00733     U_IDNA_LABEL_TOO_LONG_ERROR,
00734     U_IDNA_ZERO_LENGTH_LABEL_ERROR,
00735     U_IDNA_ERROR_LIMIT,
00736     /*
00737      * Aliases for StringPrep
00738      */
00739     U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR,
00740     U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR,
00741     U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR,
00742 
00743 
00744     U_ERROR_LIMIT=U_IDNA_ERROR_LIMIT      
00745 } UErrorCode;
00746 
00747 /* Use the following to determine if an UErrorCode represents */
00748 /* operational success or failure. */
00749 
00750 #ifdef XP_CPLUSPLUS
00751 
00755     static
00756     inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); }
00761     static
00762     inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); }
00763 #else
00764 
00768 #   define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)
00769 
00773 #   define U_FAILURE(x) ((x)>U_ZERO_ERROR)
00774 #endif
00775 
00782 U_STABLE const char * U_EXPORT2
00783 u_errorName(UErrorCode code);
00784 
00785 
00786 #endif /* _UTYPES */

Generated on Mon Aug 13 07:17:25 2007 for ICU 3.6 by  doxygen 1.5.2