1 /* 2 ********************************************************************** 3 * Copyright (C) 1996-2009, 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 41 /** 42 * \def U_HIDE_DRAFT_API 43 * Define this to 1 to request that draft API be "hidden" 44 */ 45 #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_DRAFT_API) 46 #define U_HIDE_DRAFT_API 1 47 #endif 48 49 #ifdef U_HIDE_DRAFT_API 50 #include "unicode/udraft.h" 51 #endif 52 53 #ifdef U_HIDE_DEPRECATED_API 54 #include "unicode/udeprctd.h" 55 #endif 56 57 #ifdef U_HIDE_DEPRECATED_API 58 #include "unicode/uobslete.h" 59 #endif 60 61 #ifdef U_HIDE_INTERNAL_API 62 #include "unicode/uintrnal.h" 63 #endif 64 65 #ifdef U_HIDE_SYSTEM_API 66 #include "unicode/usystem.h" 67 #endif 68 69 /*! 70 * \file 71 * \brief Basic definitions for ICU, for both C and C++ APIs 72 * 73 * This file defines basic types, constants, and enumerations directly or 74 * indirectly by including other header files, especially utf.h for the 75 * basic character and string definitions and umachine.h for consistent 76 * integer and other types. 77 */ 78 79 /*===========================================================================*/ 80 /* char Character set family */ 81 /*===========================================================================*/ 82 83 /** 84 * U_CHARSET_FAMILY is equal to this value when the platform is an ASCII based platform. 85 * @stable ICU 2.0 86 */ 87 #define U_ASCII_FAMILY 0 88 89 /** 90 * U_CHARSET_FAMILY is equal to this value when the platform is an EBCDIC based platform. 91 * @stable ICU 2.0 92 */ 93 #define U_EBCDIC_FAMILY 1 94 95 /** 96 * \def U_CHARSET_FAMILY 97 * 98 * <p>These definitions allow to specify the encoding of text 99 * in the char data type as defined by the platform and the compiler. 100 * It is enough to determine the code point values of "invariant characters", 101 * which are the ones shared by all encodings that are in use 102 * on a given platform.</p> 103 * 104 * <p>Those "invariant characters" should be all the uppercase and lowercase 105 * latin letters, the digits, the space, and "basic punctuation". 106 * Also, '\\n', '\\r', '\\t' should be available.</p> 107 * 108 * <p>The list of "invariant characters" is:<br> 109 * \code 110 * A-Z a-z 0-9 SPACE " % & ' ( ) * + , - . / : ; < = > ? _ 111 * \endcode 112 * <br> 113 * (52 letters + 10 numbers + 20 punc/sym/space = 82 total)</p> 114 * 115 * <p>This matches the IBM Syntactic Character Set (CS 640).</p> 116 * 117 * <p>In other words, all the graphic characters in 7-bit ASCII should 118 * be safely accessible except the following:</p> 119 * 120 * \code 121 * '\' <backslash> 122 * '[' <left bracket> 123 * ']' <right bracket> 124 * '{' <left brace> 125 * '}' <right brace> 126 * '^' <circumflex> 127 * '~' <tilde> 128 * '!' <exclamation mark> 129 * '#' <number sign> 130 * '|' <vertical line> 131 * '$' <dollar sign> 132 * '@' <commercial at> 133 * '`' <grave accent> 134 * \endcode 135 * @stable ICU 2.0 136 */ 137 138 #ifndef U_CHARSET_FAMILY 139 # define U_CHARSET_FAMILY 0 140 #endif 141 142 /** 143 * \def U_CHARSET_IS_UTF8 144 * 145 * Hardcode the default charset to UTF-8. 146 * 147 * If this is set to 1, then 148 * - ICU will assume that all non-invariant char*, StringPiece, std::string etc. 149 * contain UTF-8 text, regardless of what the system API uses 150 * - some ICU code will use fast functions like u_strFromUTF8() 151 * rather than the more general and more heavy-weight conversion API (ucnv.h) 152 * - ucnv_getDefaultName() always returns "UTF-8" 153 * - ucnv_setDefaultName() is disabled and will not change the default charset 154 * - static builds of ICU are smaller 155 * - more functionality is available with the UCONFIG_NO_CONVERSION build-time 156 * configuration option (see unicode/uconfig.h) 157 * - the UCONFIG_NO_CONVERSION build option in uconfig.h is more usable 158 * 159 * @draft ICU 4.2 160 * @see UCONFIG_NO_CONVERSION 161 */ 162 #ifndef U_CHARSET_IS_UTF8 163 # define U_CHARSET_IS_UTF8 0 164 #endif 165 166 /*===========================================================================*/ 167 /* ICUDATA naming scheme */ 168 /*===========================================================================*/ 169 170 /** 171 * \def U_ICUDATA_TYPE_LETTER 172 * 173 * This is a platform-dependent string containing one letter: 174 * - b for big-endian, ASCII-family platforms 175 * - l for little-endian, ASCII-family platforms 176 * - e for big-endian, EBCDIC-family platforms 177 * This letter is part of the common data file name. 178 * @stable ICU 2.0 179 */ 180 181 /** 182 * \def U_ICUDATA_TYPE_LITLETTER 183 * The non-string form of U_ICUDATA_TYPE_LETTER 184 * @stable ICU 2.0 185 */ 186 #if U_CHARSET_FAMILY 187 # if U_IS_BIG_ENDIAN 188 /* EBCDIC - should always be BE */ 189 # define U_ICUDATA_TYPE_LETTER "e" 190 # define U_ICUDATA_TYPE_LITLETTER e 191 # else 192 # error "Don't know what to do with little endian EBCDIC!" 193 # define U_ICUDATA_TYPE_LETTER "x" 194 # define U_ICUDATA_TYPE_LITLETTER x 195 # endif 196 #else 197 # if U_IS_BIG_ENDIAN 198 /* Big-endian ASCII */ 199 # define U_ICUDATA_TYPE_LETTER "b" 200 # define U_ICUDATA_TYPE_LITLETTER b 201 # else 202 /* Little-endian ASCII */ 203 # define U_ICUDATA_TYPE_LETTER "l" 204 # define U_ICUDATA_TYPE_LITLETTER l 205 # endif 206 #endif 207 208 /** 209 * A single string literal containing the icudata stub name. i.e. 'icudt18e' for 210 * ICU 1.8.x on EBCDIC, etc.. 211 * @stable ICU 2.0 212 */ 213 #define U_ICUDATA_NAME "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER 214 215 216 /** 217 * U_ICU_ENTRY_POINT is the name of the DLL entry point to the ICU data library. 218 * Defined as a literal, not a string. 219 * Tricky Preprocessor use - ## operator replaces macro paramters with the literal string 220 * from the corresponding macro invocation, _before_ other macro substitutions. 221 * Need a nested \#defines to get the actual version numbers rather than 222 * the literal text U_ICU_VERSION_MAJOR_NUM into the name. 223 * The net result will be something of the form 224 * \#define U_ICU_ENTRY_POINT icudt19_dat 225 * @stable ICU 2.4 226 */ 227 #define U_ICUDATA_ENTRY_POINT U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM, U_ICU_VERSION_MINOR_NUM) 228 229 /** 230 * Do not use. 231 * @internal 232 */ 233 #define U_DEF2_ICUDATA_ENTRY_POINT(major, minor) U_DEF_ICUDATA_ENTRY_POINT(major, minor) 234 /** 235 * Do not use. 236 * @internal 237 */ 238 #define U_DEF_ICUDATA_ENTRY_POINT(major, minor) icudt##major##minor##_dat 239 240 /** 241 * \def U_CALLCONV 242 * Similar to U_CDECL_BEGIN/U_CDECL_END, this qualifier is necessary 243 * in callback function typedefs to make sure that the calling convention 244 * is compatible. 245 * 246 * This is only used for non-ICU-API functions. 247 * When a function is a public ICU API, 248 * you must use the U_CAPI and U_EXPORT2 qualifiers. 249 * @stable ICU 2.0 250 */ 251 #if defined(OS390) && (__COMPILER_VER__ < 0x41020000) && defined(XP_CPLUSPLUS) 252 # define U_CALLCONV __cdecl 253 #else 254 # define U_CALLCONV U_EXPORT2 255 #endif 256 257 /** 258 * \def NULL 259 * Define NULL if necessary, to 0 for C++ and to ((void *)0) for C. 260 * @stable ICU 2.0 261 */ 262 #ifndef NULL 263 #ifdef XP_CPLUSPLUS 264 #define NULL 0 265 #else 266 #define NULL ((void *)0) 267 #endif 268 #endif 269 270 /*===========================================================================*/ 271 /* Calendar/TimeZone data types */ 272 /*===========================================================================*/ 273 274 /** 275 * Date and Time data type. 276 * This is a primitive data type that holds the date and time 277 * as the number of milliseconds since 1970-jan-01, 00:00 UTC. 278 * UTC leap seconds are ignored. 279 * @stable ICU 2.0 280 */ 281 typedef double UDate; 282 283 /** The number of milliseconds per second @stable ICU 2.0 */ 284 #define U_MILLIS_PER_SECOND (1000) 285 /** The number of milliseconds per minute @stable ICU 2.0 */ 286 #define U_MILLIS_PER_MINUTE (60000) 287 /** The number of milliseconds per hour @stable ICU 2.0 */ 288 #define U_MILLIS_PER_HOUR (3600000) 289 /** The number of milliseconds per day @stable ICU 2.0 */ 290 #define U_MILLIS_PER_DAY (86400000) 291 292 293 /*===========================================================================*/ 294 /* UClassID-based RTTI */ 295 /*===========================================================================*/ 296 297 /** 298 * UClassID is used to identify classes without using RTTI, since RTTI 299 * is not yet supported by all C++ compilers. Each class hierarchy which needs 300 * to implement polymorphic clone() or operator==() defines two methods, 301 * described in detail below. UClassID values can be compared using 302 * operator==(). Nothing else should be done with them. 303 * 304 * \par 305 * getDynamicClassID() is declared in the base class of the hierarchy as 306 * a pure virtual. Each concrete subclass implements it in the same way: 307 * 308 * \code 309 * class Base { 310 * public: 311 * virtual UClassID getDynamicClassID() const = 0; 312 * } 313 * 314 * class Derived { 315 * public: 316 * virtual UClassID getDynamicClassID() const 317 * { return Derived::getStaticClassID(); } 318 * } 319 * \endcode 320 * 321 * Each concrete class implements getStaticClassID() as well, which allows 322 * clients to test for a specific type. 323 * 324 * \code 325 * class Derived { 326 * public: 327 * static UClassID U_EXPORT2 getStaticClassID(); 328 * private: 329 * static char fgClassID; 330 * } 331 * 332 * // In Derived.cpp: 333 * UClassID Derived::getStaticClassID() 334 * { return (UClassID)&Derived::fgClassID; } 335 * char Derived::fgClassID = 0; // Value is irrelevant 336 * \endcode 337 * @stable ICU 2.0 338 */ 339 typedef void* UClassID; 340 341 /*===========================================================================*/ 342 /* Shared library/DLL import-export API control */ 343 /*===========================================================================*/ 344 345 /* 346 * Control of symbol import/export. 347 * ICU is separated into three libraries. 348 */ 349 350 /* 351 * \def U_COMBINED_IMPLEMENTATION 352 * Set to export library symbols from inside the ICU library 353 * when all of ICU is in a single library. 354 * This can be set as a compiler option while building ICU, and it 355 * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc. 356 * @stable ICU 2.0 357 */ 358 359 /** 360 * \def U_DATA_API 361 * Set to export library symbols from inside the stubdata library, 362 * and to import them from outside. 363 * @stable ICU 3.0 364 */ 365 366 /** 367 * \def U_COMMON_API 368 * Set to export library symbols from inside the common library, 369 * and to import them from outside. 370 * @stable ICU 2.0 371 */ 372 373 /** 374 * \def U_I18N_API 375 * Set to export library symbols from inside the i18n library, 376 * and to import them from outside. 377 * @stable ICU 2.0 378 */ 379 380 /** 381 * \def U_LAYOUT_API 382 * Set to export library symbols from inside the layout engine library, 383 * and to import them from outside. 384 * @stable ICU 2.0 385 */ 386 387 /** 388 * \def U_LAYOUTEX_API 389 * Set to export library symbols from inside the layout extensions library, 390 * and to import them from outside. 391 * @stable ICU 2.6 392 */ 393 394 /** 395 * \def U_IO_API 396 * Set to export library symbols from inside the ustdio library, 397 * and to import them from outside. 398 * @stable ICU 2.0 399 */ 400 401 /** 402 * \def U_TOOLUTIL_API 403 * Set to export library symbols from inside the toolutil library, 404 * and to import them from outside. 405 * @stable ICU 3.4 406 */ 407 408 #if defined(U_COMBINED_IMPLEMENTATION) 409 #define U_DATA_API U_EXPORT 410 #define U_COMMON_API U_EXPORT 411 #define U_I18N_API U_EXPORT 412 #define U_LAYOUT_API U_EXPORT 413 #define U_LAYOUTEX_API U_EXPORT 414 #define U_IO_API U_EXPORT 415 #define U_TOOLUTIL_API U_EXPORT 416 #elif defined(U_STATIC_IMPLEMENTATION) 417 #define U_DATA_API 418 #define U_COMMON_API 419 #define U_I18N_API 420 #define U_LAYOUT_API 421 #define U_LAYOUTEX_API 422 #define U_IO_API 423 #define U_TOOLUTIL_API 424 #elif defined(U_COMMON_IMPLEMENTATION) 425 #define U_DATA_API U_IMPORT 426 #define U_COMMON_API U_EXPORT 427 #define U_I18N_API U_IMPORT 428 #define U_LAYOUT_API U_IMPORT 429 #define U_LAYOUTEX_API U_IMPORT 430 #define U_IO_API U_IMPORT 431 #define U_TOOLUTIL_API U_IMPORT 432 #elif defined(U_I18N_IMPLEMENTATION) 433 #define U_DATA_API U_IMPORT 434 #define U_COMMON_API U_IMPORT 435 #define U_I18N_API U_EXPORT 436 #define U_LAYOUT_API U_IMPORT 437 #define U_LAYOUTEX_API U_IMPORT 438 #define U_IO_API U_IMPORT 439 #define U_TOOLUTIL_API U_IMPORT 440 #elif defined(U_LAYOUT_IMPLEMENTATION) 441 #define U_DATA_API U_IMPORT 442 #define U_COMMON_API U_IMPORT 443 #define U_I18N_API U_IMPORT 444 #define U_LAYOUT_API U_EXPORT 445 #define U_LAYOUTEX_API U_IMPORT 446 #define U_IO_API U_IMPORT 447 #define U_TOOLUTIL_API U_IMPORT 448 #elif defined(U_LAYOUTEX_IMPLEMENTATION) 449 #define U_DATA_API U_IMPORT 450 #define U_COMMON_API U_IMPORT 451 #define U_I18N_API U_IMPORT 452 #define U_LAYOUT_API U_IMPORT 453 #define U_LAYOUTEX_API U_EXPORT 454 #define U_IO_API U_IMPORT 455 #define U_TOOLUTIL_API U_IMPORT 456 #elif defined(U_IO_IMPLEMENTATION) 457 #define U_DATA_API U_IMPORT 458 #define U_COMMON_API U_IMPORT 459 #define U_I18N_API U_IMPORT 460 #define U_LAYOUT_API U_IMPORT 461 #define U_LAYOUTEX_API U_IMPORT 462 #define U_IO_API U_EXPORT 463 #define U_TOOLUTIL_API U_IMPORT 464 #elif defined(U_TOOLUTIL_IMPLEMENTATION) 465 #define U_DATA_API U_IMPORT 466 #define U_COMMON_API U_IMPORT 467 #define U_I18N_API U_IMPORT 468 #define U_LAYOUT_API U_IMPORT 469 #define U_LAYOUTEX_API U_IMPORT 470 #define U_IO_API U_IMPORT 471 #define U_TOOLUTIL_API U_EXPORT 472 #else 473 #define U_DATA_API U_IMPORT 474 #define U_COMMON_API U_IMPORT 475 #define U_I18N_API U_IMPORT 476 #define U_LAYOUT_API U_IMPORT 477 #define U_LAYOUTEX_API U_IMPORT 478 #define U_IO_API U_IMPORT 479 #define U_TOOLUTIL_API U_IMPORT 480 #endif 481 482 /** 483 * \def U_STANDARD_CPP_NAMESPACE 484 * Control of C++ Namespace 485 * @stable ICU 2.0 486 */ 487 #ifdef __cplusplus 488 #define U_STANDARD_CPP_NAMESPACE :: 489 #else 490 #define U_STANDARD_CPP_NAMESPACE 491 #endif 492 493 494 /*===========================================================================*/ 495 /* Global delete operator */ 496 /*===========================================================================*/ 497 498 /* 499 * The ICU4C library must not use the global new and delete operators. 500 * These operators here are defined to enable testing for this. 501 * See Jitterbug 2581 for details of why this is necessary. 502 * 503 * Verification that ICU4C's memory usage is correct, i.e., 504 * that global new/delete are not used: 505 * 506 * a) Check for imports of global new/delete (see uobject.cpp for details) 507 * b) Verify that new is never imported. 508 * c) Verify that delete is only imported from object code for interface/mixin classes. 509 * d) Add global delete and delete[] only for the ICU4C library itself 510 * and define them in a way that crashes or otherwise easily shows a problem. 511 * 512 * The following implements d). 513 * The operator implementations crash; this is intentional and used for library debugging. 514 * 515 * Note: This is currently only done on Windows because 516 * some Linux/Unix compilers have problems with defining global new/delete. 517 * On Windows, U_WINDOWS is defined, and it is _MSC_VER>=1200 for MSVC 6.0 and higher. 518 */ 519 #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)) 520 521 #ifndef U_HIDE_INTERNAL_API 522 /** 523 * Global operator new, defined only inside ICU4C, must not be used. 524 * Crashes intentionally. 525 * @internal 526 */ 527 inline void * 528 operator new(size_t /*size*/) { 529 char *q=NULL; 530 *q=5; /* break it */ 531 return q; 532 } 533 534 #ifdef _Ret_bytecap_ 535 /* This is only needed to suppress a Visual C++ 2008 warning for operator new[]. */ 536 _Ret_bytecap_(_Size) 537 #endif 538 /** 539 * Global operator new[], defined only inside ICU4C, must not be used. 540 * Crashes intentionally. 541 * @internal 542 */ 543 inline void * 544 operator new[](size_t /*size*/) { 545 char *q=NULL; 546 *q=5; /* break it */ 547 return q; 548 } 549 550 /** 551 * Global operator delete, defined only inside ICU4C, must not be used. 552 * Crashes intentionally. 553 * @internal 554 */ 555 inline void 556 operator delete(void * /*p*/) { 557 char *q=NULL; 558 *q=5; /* break it */ 559 } 560 561 /** 562 * Global operator delete[], defined only inside ICU4C, must not be used. 563 * Crashes intentionally. 564 * @internal 565 */ 566 inline void 567 operator delete[](void * /*p*/) { 568 char *q=NULL; 569 *q=5; /* break it */ 570 } 571 572 #endif /* U_HIDE_INTERNAL_API */ 573 #endif 574 575 /*===========================================================================*/ 576 /* UErrorCode */ 577 /*===========================================================================*/ 578 579 /** 580 * Error code to replace exception handling, so that the code is compatible with all C++ compilers, 581 * and to use the same mechanism for C and C++. 582 * 583 * \par 584 * ICU functions that take a reference (C++) or a pointer (C) to a UErrorCode 585 * first test if(U_FAILURE(errorCode)) { return immediately; } 586 * so that in a chain of such functions the first one that sets an error code 587 * causes the following ones to not perform any operations. 588 * 589 * \par 590 * Error codes should be tested using U_FAILURE() and U_SUCCESS(). 591 * @stable ICU 2.0 592 */ 593 typedef enum UErrorCode { 594 /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird 595 * and is that way because VC++ debugger displays first encountered constant, 596 * which is not the what the code is used for 597 */ 598 599 U_USING_FALLBACK_WARNING = -128, /**< A resource bundle lookup returned a fallback result (not an error) */ 600 601 U_ERROR_WARNING_START = -128, /**< Start of information results (semantically successful) */ 602 603 U_USING_DEFAULT_WARNING = -127, /**< A resource bundle lookup returned a result from the root locale (not an error) */ 604 605 U_SAFECLONE_ALLOCATED_WARNING = -126, /**< A SafeClone operation required allocating memory (informational only) */ 606 607 U_STATE_OLD_WARNING = -125, /**< ICU has to use compatibility layer to construct the service. Expect performance/memory usage degradation. Consider upgrading */ 608 609 U_STRING_NOT_TERMINATED_WARNING = -124,/**< An output string could not be NUL-terminated because output length==destCapacity. */ 610 611 U_SORT_KEY_TOO_SHORT_WARNING = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key */ 612 613 U_AMBIGUOUS_ALIAS_WARNING = -122, /**< This converter alias can go to different converter implementations */ 614 615 U_DIFFERENT_UCA_VERSION = -121, /**< ucol_open encountered a mismatch between UCA version and collator image version, so the collator was constructed from rules. No impact to further function */ 616 617 U_ERROR_WARNING_LIMIT, /**< This must always be the last warning value to indicate the limit for UErrorCode warnings (last warning code +1) */ 618 619 620 U_ZERO_ERROR = 0, /**< No error, no warning. */ 621 622 U_ILLEGAL_ARGUMENT_ERROR = 1, /**< Start of codes indicating failure */ 623 U_MISSING_RESOURCE_ERROR = 2, /**< The requested resource cannot be found */ 624 U_INVALID_FORMAT_ERROR = 3, /**< Data format is not what is expected */ 625 U_FILE_ACCESS_ERROR = 4, /**< The requested file cannot be found */ 626 U_INTERNAL_PROGRAM_ERROR = 5, /**< Indicates a bug in the library code */ 627 U_MESSAGE_PARSE_ERROR = 6, /**< Unable to parse a message (message format) */ 628 U_MEMORY_ALLOCATION_ERROR = 7, /**< Memory allocation error */ 629 U_INDEX_OUTOFBOUNDS_ERROR = 8, /**< Trying to access the index that is out of bounds */ 630 U_PARSE_ERROR = 9, /**< Equivalent to Java ParseException */ 631 U_INVALID_CHAR_FOUND = 10, /**< Character conversion: Unmappable input sequence. In other APIs: Invalid character. */ 632 U_TRUNCATED_CHAR_FOUND = 11, /**< Character conversion: Incomplete input sequence. */ 633 U_ILLEGAL_CHAR_FOUND = 12, /**< Character conversion: Illegal input sequence/combination of input units. */ 634 U_INVALID_TABLE_FORMAT = 13, /**< Conversion table file found, but corrupted */ 635 U_INVALID_TABLE_FILE = 14, /**< Conversion table file not found */ 636 U_BUFFER_OVERFLOW_ERROR = 15, /**< A result would not fit in the supplied buffer */ 637 U_UNSUPPORTED_ERROR = 16, /**< Requested operation not supported in current context */ 638 U_RESOURCE_TYPE_MISMATCH = 17, /**< an operation is requested over a resource that does not support it */ 639 U_ILLEGAL_ESCAPE_SEQUENCE = 18, /**< ISO-2022 illlegal escape sequence */ 640 U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, /**< ISO-2022 unsupported escape sequence */ 641 U_NO_SPACE_AVAILABLE = 20, /**< No space available for in-buffer expansion for Arabic shaping */ 642 U_CE_NOT_FOUND_ERROR = 21, /**< Currently used only while setting variable top, but can be used generally */ 643 U_PRIMARY_TOO_LONG_ERROR = 22, /**< User tried to set variable top to a primary that is longer than two bytes */ 644 U_STATE_TOO_OLD_ERROR = 23, /**< ICU cannot construct a service from this state, as it is no longer supported */ 645 U_TOO_MANY_ALIASES_ERROR = 24, /**< There are too many aliases in the path to the requested resource. 646 It is very possible that a circular alias definition has occured */ 647 U_ENUM_OUT_OF_SYNC_ERROR = 25, /**< UEnumeration out of sync with underlying collection */ 648 U_INVARIANT_CONVERSION_ERROR = 26, /**< Unable to convert a UChar* string to char* with the invariant converter. */ 649 U_INVALID_STATE_ERROR = 27, /**< Requested operation can not be completed with ICU in its current state */ 650 U_COLLATOR_VERSION_MISMATCH = 28, /**< Collator version is not compatible with the base version */ 651 U_USELESS_COLLATOR_ERROR = 29, /**< Collator is options only and no base is specified */ 652 U_NO_WRITE_PERMISSION = 30, /**< Attempt to modify read-only or constant data. */ 653 654 U_STANDARD_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for standard errors */ 655 /* 656 * the error code range 0x10000 0x10100 are reserved for Transliterator 657 */ 658 U_BAD_VARIABLE_DEFINITION=0x10000,/**< Missing '$' or duplicate variable name */ 659 U_PARSE_ERROR_START = 0x10000, /**< Start of Transliterator errors */ 660 U_MALFORMED_RULE, /**< Elements of a rule are misplaced */ 661 U_MALFORMED_SET, /**< A UnicodeSet pattern is invalid*/ 662 U_MALFORMED_SYMBOL_REFERENCE, /**< UNUSED as of ICU 2.4 */ 663 U_MALFORMED_UNICODE_ESCAPE, /**< A Unicode escape pattern is invalid*/ 664 U_MALFORMED_VARIABLE_DEFINITION, /**< A variable definition is invalid */ 665 U_MALFORMED_VARIABLE_REFERENCE, /**< A variable reference is invalid */ 666 U_MISMATCHED_SEGMENT_DELIMITERS, /**< UNUSED as of ICU 2.4 */ 667 U_MISPLACED_ANCHOR_START, /**< A start anchor appears at an illegal position */ 668 U_MISPLACED_CURSOR_OFFSET, /**< A cursor offset occurs at an illegal position */ 669 U_MISPLACED_QUANTIFIER, /**< A quantifier appears after a segment close delimiter */ 670 U_MISSING_OPERATOR, /**< A rule contains no operator */ 671 U_MISSING_SEGMENT_CLOSE, /**< UNUSED as of ICU 2.4 */ 672 U_MULTIPLE_ANTE_CONTEXTS, /**< More than one ante context */ 673 U_MULTIPLE_CURSORS, /**< More than one cursor */ 674 U_MULTIPLE_POST_CONTEXTS, /**< More than one post context */ 675 U_TRAILING_BACKSLASH, /**< A dangling backslash */ 676 U_UNDEFINED_SEGMENT_REFERENCE, /**< A segment reference does not correspond to a defined segment */ 677 U_UNDEFINED_VARIABLE, /**< A variable reference does not correspond to a defined variable */ 678 U_UNQUOTED_SPECIAL, /**< A special character was not quoted or escaped */ 679 U_UNTERMINATED_QUOTE, /**< A closing single quote is missing */ 680 U_RULE_MASK_ERROR, /**< A rule is hidden by an earlier more general rule */ 681 U_MISPLACED_COMPOUND_FILTER, /**< A compound filter is in an invalid location */ 682 U_MULTIPLE_COMPOUND_FILTERS, /**< More than one compound filter */ 683 U_INVALID_RBT_SYNTAX, /**< A "::id" rule was passed to the RuleBasedTransliterator parser */ 684 U_INVALID_PROPERTY_PATTERN, /**< UNUSED as of ICU 2.4 */ 685 U_MALFORMED_PRAGMA, /**< A 'use' pragma is invlalid */ 686 U_UNCLOSED_SEGMENT, /**< A closing ')' is missing */ 687 U_ILLEGAL_CHAR_IN_SEGMENT, /**< UNUSED as of ICU 2.4 */ 688 U_VARIABLE_RANGE_EXHAUSTED, /**< Too many stand-ins generated for the given variable range */ 689 U_VARIABLE_RANGE_OVERLAP, /**< The variable range overlaps characters used in rules */ 690 U_ILLEGAL_CHARACTER, /**< A special character is outside its allowed context */ 691 U_INTERNAL_TRANSLITERATOR_ERROR, /**< Internal transliterator system error */ 692 U_INVALID_ID, /**< A "::id" rule specifies an unknown transliterator */ 693 U_INVALID_FUNCTION, /**< A "&fn()" rule specifies an unknown transliterator */ 694 U_PARSE_ERROR_LIMIT, /**< The limit for Transliterator errors */ 695 696 /* 697 * the error code range 0x10100 0x10200 are reserved for formatting API parsing error 698 */ 699 U_UNEXPECTED_TOKEN=0x10100, /**< Syntax error in format pattern */ 700 U_FMT_PARSE_ERROR_START=0x10100, /**< Start of format library errors */ 701 U_MULTIPLE_DECIMAL_SEPARATORS, /**< More than one decimal separator in number pattern */ 702 U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, /**< Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */ 703 U_MULTIPLE_EXPONENTIAL_SYMBOLS, /**< More than one exponent symbol in number pattern */ 704 U_MALFORMED_EXPONENTIAL_PATTERN, /**< Grouping symbol in exponent pattern */ 705 U_MULTIPLE_PERCENT_SYMBOLS, /**< More than one percent symbol in number pattern */ 706 U_MULTIPLE_PERMILL_SYMBOLS, /**< More than one permill symbol in number pattern */ 707 U_MULTIPLE_PAD_SPECIFIERS, /**< More than one pad symbol in number pattern */ 708 U_PATTERN_SYNTAX_ERROR, /**< Syntax error in format pattern */ 709 U_ILLEGAL_PAD_POSITION, /**< Pad symbol misplaced in number pattern */ 710 U_UNMATCHED_BRACES, /**< Braces do not match in message pattern */ 711 U_UNSUPPORTED_PROPERTY, /**< UNUSED as of ICU 2.4 */ 712 U_UNSUPPORTED_ATTRIBUTE, /**< UNUSED as of ICU 2.4 */ 713 U_ARGUMENT_TYPE_MISMATCH, /**< Argument name and argument index mismatch in MessageFormat functions */ 714 U_DUPLICATE_KEYWORD, /**< Duplicate keyword in PluralFormat */ 715 U_UNDEFINED_KEYWORD, /**< Undefined Pluarl keyword */ 716 U_DEFAULT_KEYWORD_MISSING, /**< Missing DEFAULT rule in plural rules */ 717 U_FMT_PARSE_ERROR_LIMIT, /**< The limit for format library errors */ 718 719 /* 720 * the error code range 0x10200 0x102ff are reserved for Break Iterator related error 721 */ 722 U_BRK_INTERNAL_ERROR=0x10200, /**< An internal error (bug) was detected. */ 723 U_BRK_ERROR_START=0x10200, /**< Start of codes indicating Break Iterator failures */ 724 U_BRK_HEX_DIGITS_EXPECTED, /**< Hex digits expected as part of a escaped char in a rule. */ 725 U_BRK_SEMICOLON_EXPECTED, /**< Missing ';' at the end of a RBBI rule. */ 726 U_BRK_RULE_SYNTAX, /**< Syntax error in RBBI rule. */ 727 U_BRK_UNCLOSED_SET, /**< UnicodeSet witing an RBBI rule missing a closing ']'. */ 728 U_BRK_ASSIGN_ERROR, /**< Syntax error in RBBI rule assignment statement. */ 729 U_BRK_VARIABLE_REDFINITION, /**< RBBI rule $Variable redefined. */ 730 U_BRK_MISMATCHED_PAREN, /**< Mis-matched parentheses in an RBBI rule. */ 731 U_BRK_NEW_LINE_IN_QUOTED_STRING, /**< Missing closing quote in an RBBI rule. */ 732 U_BRK_UNDEFINED_VARIABLE, /**< Use of an undefined $Variable in an RBBI rule. */ 733 U_BRK_INIT_ERROR, /**< Initialization failure. Probable missing ICU Data. */ 734 U_BRK_RULE_EMPTY_SET, /**< Rule contains an empty Unicode Set. */ 735 U_BRK_UNRECOGNIZED_OPTION, /**< !!option in RBBI rules not recognized. */ 736 U_BRK_MALFORMED_RULE_TAG, /**< The {nnn} tag on a rule is mal formed */ 737 U_BRK_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for Break Iterator failures */ 738 739 /* 740 * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs 741 */ 742 U_REGEX_INTERNAL_ERROR=0x10300, /**< An internal error (bug) was detected. */ 743 U_REGEX_ERROR_START=0x10300, /**< Start of codes indicating Regexp failures */ 744 U_REGEX_RULE_SYNTAX, /**< Syntax error in regexp pattern. */ 745 U_REGEX_INVALID_STATE, /**< RegexMatcher in invalid state for requested operation */ 746 U_REGEX_BAD_ESCAPE_SEQUENCE, /**< Unrecognized backslash escape sequence in pattern */ 747 U_REGEX_PROPERTY_SYNTAX, /**< Incorrect Unicode property */ 748 U_REGEX_UNIMPLEMENTED, /**< Use of regexp feature that is not yet implemented. */ 749 U_REGEX_MISMATCHED_PAREN, /**< Incorrectly nested parentheses in regexp pattern. */ 750 U_REGEX_NUMBER_TOO_BIG, /**< Decimal number is too large. */ 751 U_REGEX_BAD_INTERVAL, /**< Error in {min,max} interval */ 752 U_REGEX_MAX_LT_MIN, /**< In {min,max}, max is less than min. */ 753 U_REGEX_INVALID_BACK_REF, /**< Back-reference to a non-existent capture group. */ 754 U_REGEX_INVALID_FLAG, /**< Invalid value for match mode flags. */ 755 U_REGEX_LOOK_BEHIND_LIMIT, /**< Look-Behind pattern matches must have a bounded maximum length. */ 756 U_REGEX_SET_CONTAINS_STRING, /**< Regexps cannot have UnicodeSets containing strings.*/ 757 U_REGEX_OCTAL_TOO_BIG, /**< Octal character constants must be <= 0377. */ 758 U_REGEX_MISSING_CLOSE_BRACKET, /**< Missing closing bracket on a bracket expression. */ 759 U_REGEX_INVALID_RANGE, /**< In a character range [x-y], x is greater than y. */ 760 U_REGEX_STACK_OVERFLOW, /**< Regular expression backtrack stack overflow. */ 761 U_REGEX_TIME_OUT, /**< Maximum allowed match time exceeded */ 762 U_REGEX_STOPPED_BY_CALLER, /**< Matching operation aborted by user callback fn. */ 763 U_REGEX_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for regexp errors */ 764 765 /* 766 * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes 767 */ 768 U_IDNA_PROHIBITED_ERROR=0x10400, 769 U_IDNA_ERROR_START=0x10400, 770 U_IDNA_UNASSIGNED_ERROR, 771 U_IDNA_CHECK_BIDI_ERROR, 772 U_IDNA_STD3_ASCII_RULES_ERROR, 773 U_IDNA_ACE_PREFIX_ERROR, 774 U_IDNA_VERIFICATION_ERROR, 775 U_IDNA_LABEL_TOO_LONG_ERROR, 776 U_IDNA_ZERO_LENGTH_LABEL_ERROR, 777 U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR, 778 U_IDNA_ERROR_LIMIT, 779 /* 780 * Aliases for StringPrep 781 */ 782 U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR, 783 U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR, 784 U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR, 785 786 787 U_ERROR_LIMIT=U_IDNA_ERROR_LIMIT /**< This must always be the last value to indicate the limit for UErrorCode (last error code +1) */ 788 } UErrorCode; 789 790 /* Use the following to determine if an UErrorCode represents */ 791 /* operational success or failure. */ 792 793 #ifdef XP_CPLUSPLUS 794 /** 795 * Does the error code indicate success? 796 * @stable ICU 2.0 797 */ 798 static 799 inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); } 800 /** 801 * Does the error code indicate a failure? 802 * @stable ICU 2.0 803 */ 804 static 805 inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); } 806 #else 807 /** 808 * Does the error code indicate success? 809 * @stable ICU 2.0 810 */ 811 # define U_SUCCESS(x) ((x)<=U_ZERO_ERROR) 812 /** 813 * Does the error code indicate a failure? 814 * @stable ICU 2.0 815 */ 816 # define U_FAILURE(x) ((x)>U_ZERO_ERROR) 817 #endif 818 819 /** 820 * Return a string for a UErrorCode value. 821 * The string will be the same as the name of the error code constant 822 * in the UErrorCode enum above. 823 * @stable ICU 2.0 824 */ 825 U_STABLE const char * U_EXPORT2 826 u_errorName(UErrorCode code); 827 828 829 #endif /* _UTYPES */ 830