utypes.h 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729
  1. /*
  2. **********************************************************************
  3. * Copyright (C) 1996-2015, 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. #ifndef UTYPES_H
  32. #define UTYPES_H
  33. #include "umachine.h"
  34. #include "uversion.h"
  35. #include "uconfig.h"
  36. #include <float.h>
  37. #if !U_NO_DEFAULT_INCLUDE_UTF_HEADERS
  38. # include "utf.h"
  39. #endif
  40. /*!
  41. * \file
  42. * \brief Basic definitions for ICU, for both C and C++ APIs
  43. *
  44. * This file defines basic types, constants, and enumerations directly or
  45. * indirectly by including other header files, especially utf.h for the
  46. * basic character and string definitions and umachine.h for consistent
  47. * integer and other types.
  48. */
  49. /**
  50. * \def U_SHOW_CPLUSPLUS_API
  51. * @internal
  52. */
  53. #ifdef __cplusplus
  54. # ifndef U_SHOW_CPLUSPLUS_API
  55. # define U_SHOW_CPLUSPLUS_API 1
  56. # endif
  57. #else
  58. # undef U_SHOW_CPLUSPLUS_API
  59. # define U_SHOW_CPLUSPLUS_API 0
  60. #endif
  61. /** @{ API visibility control */
  62. /**
  63. * \def U_HIDE_DRAFT_API
  64. * Define this to 1 to request that draft API be "hidden"
  65. * @internal
  66. */
  67. /**
  68. * \def U_HIDE_INTERNAL_API
  69. * Define this to 1 to request that internal API be "hidden"
  70. * @internal
  71. */
  72. #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_DRAFT_API)
  73. #define U_HIDE_DRAFT_API 1
  74. #endif
  75. #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_INTERNAL_API)
  76. #define U_HIDE_INTERNAL_API 1
  77. #endif
  78. /** @} */
  79. /*===========================================================================*/
  80. /* ICUDATA naming scheme */
  81. /*===========================================================================*/
  82. /**
  83. * \def U_ICUDATA_TYPE_LETTER
  84. *
  85. * This is a platform-dependent string containing one letter:
  86. * - b for big-endian, ASCII-family platforms
  87. * - l for little-endian, ASCII-family platforms
  88. * - e for big-endian, EBCDIC-family platforms
  89. * This letter is part of the common data file name.
  90. * @stable ICU 2.0
  91. */
  92. /**
  93. * \def U_ICUDATA_TYPE_LITLETTER
  94. * The non-string form of U_ICUDATA_TYPE_LETTER
  95. * @stable ICU 2.0
  96. */
  97. #if U_CHARSET_FAMILY
  98. # if U_IS_BIG_ENDIAN
  99. /* EBCDIC - should always be BE */
  100. # define U_ICUDATA_TYPE_LETTER "e"
  101. # define U_ICUDATA_TYPE_LITLETTER e
  102. # else
  103. # error "Don't know what to do with little endian EBCDIC!"
  104. # define U_ICUDATA_TYPE_LETTER "x"
  105. # define U_ICUDATA_TYPE_LITLETTER x
  106. # endif
  107. #else
  108. # if U_IS_BIG_ENDIAN
  109. /* Big-endian ASCII */
  110. # define U_ICUDATA_TYPE_LETTER "b"
  111. # define U_ICUDATA_TYPE_LITLETTER b
  112. # else
  113. /* Little-endian ASCII */
  114. # define U_ICUDATA_TYPE_LETTER "l"
  115. # define U_ICUDATA_TYPE_LITLETTER l
  116. # endif
  117. #endif
  118. /**
  119. * A single string literal containing the icudata stub name. i.e. 'icudt18e' for
  120. * ICU 1.8.x on EBCDIC, etc..
  121. * @stable ICU 2.0
  122. */
  123. #define U_ICUDATA_NAME "icudt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER
  124. #ifndef U_HIDE_INTERNAL_API
  125. #define U_USRDATA_NAME "usrdt" U_ICU_VERSION_SHORT U_ICUDATA_TYPE_LETTER /**< @internal */
  126. #define U_USE_USRDATA 1 /**< @internal */
  127. #endif /* U_HIDE_INTERNAL_API */
  128. /**
  129. * U_ICU_ENTRY_POINT is the name of the DLL entry point to the ICU data library.
  130. * Defined as a literal, not a string.
  131. * Tricky Preprocessor use - ## operator replaces macro paramters with the literal string
  132. * from the corresponding macro invocation, _before_ other macro substitutions.
  133. * Need a nested \#defines to get the actual version numbers rather than
  134. * the literal text U_ICU_VERSION_MAJOR_NUM into the name.
  135. * The net result will be something of the form
  136. * \#define U_ICU_ENTRY_POINT icudt19_dat
  137. * @stable ICU 2.4
  138. */
  139. #define U_ICUDATA_ENTRY_POINT U_DEF2_ICUDATA_ENTRY_POINT(U_ICU_VERSION_MAJOR_NUM,U_LIB_SUFFIX_C_NAME)
  140. #ifndef U_HIDE_INTERNAL_API
  141. /**
  142. * Do not use. Note that it's OK for the 2nd argument to be undefined (literal).
  143. * @internal
  144. */
  145. #define U_DEF2_ICUDATA_ENTRY_POINT(major,suff) U_DEF_ICUDATA_ENTRY_POINT(major,suff)
  146. /**
  147. * Do not use.
  148. * @internal
  149. */
  150. #ifndef U_DEF_ICUDATA_ENTRY_POINT
  151. /* affected by symbol renaming. See platform.h */
  152. #ifndef U_LIB_SUFFIX_C_NAME
  153. #define U_DEF_ICUDATA_ENTRY_POINT(major, suff) icudt##major##_dat
  154. #else
  155. #define U_DEF_ICUDATA_ENTRY_POINT(major, suff) icudt##suff ## major##_dat
  156. #endif
  157. #endif
  158. #endif /* U_HIDE_INTERNAL_API */
  159. /**
  160. * \def NULL
  161. * Define NULL if necessary, to 0 for C++ and to ((void *)0) for C.
  162. * @stable ICU 2.0
  163. */
  164. #ifndef NULL
  165. #ifdef __cplusplus
  166. #define NULL 0
  167. #else
  168. #define NULL ((void *)0)
  169. #endif
  170. #endif
  171. /*===========================================================================*/
  172. /* Calendar/TimeZone data types */
  173. /*===========================================================================*/
  174. /**
  175. * Date and Time data type.
  176. * This is a primitive data type that holds the date and time
  177. * as the number of milliseconds since 1970-jan-01, 00:00 UTC.
  178. * UTC leap seconds are ignored.
  179. * @stable ICU 2.0
  180. */
  181. typedef double UDate;
  182. /** The number of milliseconds per second @stable ICU 2.0 */
  183. #define U_MILLIS_PER_SECOND (1000)
  184. /** The number of milliseconds per minute @stable ICU 2.0 */
  185. #define U_MILLIS_PER_MINUTE (60000)
  186. /** The number of milliseconds per hour @stable ICU 2.0 */
  187. #define U_MILLIS_PER_HOUR (3600000)
  188. /** The number of milliseconds per day @stable ICU 2.0 */
  189. #define U_MILLIS_PER_DAY (86400000)
  190. /**
  191. * Maximum UDate value
  192. * @stable ICU 4.8
  193. */
  194. #define U_DATE_MAX DBL_MAX
  195. /**
  196. * Minimum UDate value
  197. * @stable ICU 4.8
  198. */
  199. #define U_DATE_MIN -U_DATE_MAX
  200. /*===========================================================================*/
  201. /* Shared library/DLL import-export API control */
  202. /*===========================================================================*/
  203. /*
  204. * Control of symbol import/export.
  205. * ICU is separated into three libraries.
  206. */
  207. /**
  208. * \def U_COMBINED_IMPLEMENTATION
  209. * Set to export library symbols from inside the ICU library
  210. * when all of ICU is in a single library.
  211. * This can be set as a compiler option while building ICU, and it
  212. * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc.
  213. * @stable ICU 2.0
  214. */
  215. /**
  216. * \def U_DATA_API
  217. * Set to export library symbols from inside the stubdata library,
  218. * and to import them from outside.
  219. * @stable ICU 3.0
  220. */
  221. /**
  222. * \def U_COMMON_API
  223. * Set to export library symbols from inside the common library,
  224. * and to import them from outside.
  225. * @stable ICU 2.0
  226. */
  227. /**
  228. * \def U_I18N_API
  229. * Set to export library symbols from inside the i18n library,
  230. * and to import them from outside.
  231. * @stable ICU 2.0
  232. */
  233. /**
  234. * \def U_LAYOUT_API
  235. * Set to export library symbols from inside the layout engine library,
  236. * and to import them from outside.
  237. * @stable ICU 2.0
  238. */
  239. /**
  240. * \def U_LAYOUTEX_API
  241. * Set to export library symbols from inside the layout extensions library,
  242. * and to import them from outside.
  243. * @stable ICU 2.6
  244. */
  245. /**
  246. * \def U_IO_API
  247. * Set to export library symbols from inside the ustdio library,
  248. * and to import them from outside.
  249. * @stable ICU 2.0
  250. */
  251. /**
  252. * \def U_TOOLUTIL_API
  253. * Set to export library symbols from inside the toolutil library,
  254. * and to import them from outside.
  255. * @stable ICU 3.4
  256. */
  257. #if defined(U_COMBINED_IMPLEMENTATION)
  258. #define U_DATA_API U_EXPORT
  259. #define U_COMMON_API U_EXPORT
  260. #define U_I18N_API U_EXPORT
  261. #define U_LAYOUT_API U_EXPORT
  262. #define U_LAYOUTEX_API U_EXPORT
  263. #define U_IO_API U_EXPORT
  264. #define U_TOOLUTIL_API U_EXPORT
  265. #elif defined(U_STATIC_IMPLEMENTATION)
  266. #define U_DATA_API
  267. #define U_COMMON_API
  268. #define U_I18N_API
  269. #define U_LAYOUT_API
  270. #define U_LAYOUTEX_API
  271. #define U_IO_API
  272. #define U_TOOLUTIL_API
  273. #elif defined(U_COMMON_IMPLEMENTATION)
  274. #define U_DATA_API U_IMPORT
  275. #define U_COMMON_API U_EXPORT
  276. #define U_I18N_API U_IMPORT
  277. #define U_LAYOUT_API U_IMPORT
  278. #define U_LAYOUTEX_API U_IMPORT
  279. #define U_IO_API U_IMPORT
  280. #define U_TOOLUTIL_API U_IMPORT
  281. #elif defined(U_I18N_IMPLEMENTATION)
  282. #define U_DATA_API U_IMPORT
  283. #define U_COMMON_API U_IMPORT
  284. #define U_I18N_API U_EXPORT
  285. #define U_LAYOUT_API U_IMPORT
  286. #define U_LAYOUTEX_API U_IMPORT
  287. #define U_IO_API U_IMPORT
  288. #define U_TOOLUTIL_API U_IMPORT
  289. #elif defined(U_LAYOUT_IMPLEMENTATION)
  290. #define U_DATA_API U_IMPORT
  291. #define U_COMMON_API U_IMPORT
  292. #define U_I18N_API U_IMPORT
  293. #define U_LAYOUT_API U_EXPORT
  294. #define U_LAYOUTEX_API U_IMPORT
  295. #define U_IO_API U_IMPORT
  296. #define U_TOOLUTIL_API U_IMPORT
  297. #elif defined(U_LAYOUTEX_IMPLEMENTATION)
  298. #define U_DATA_API U_IMPORT
  299. #define U_COMMON_API U_IMPORT
  300. #define U_I18N_API U_IMPORT
  301. #define U_LAYOUT_API U_IMPORT
  302. #define U_LAYOUTEX_API U_EXPORT
  303. #define U_IO_API U_IMPORT
  304. #define U_TOOLUTIL_API U_IMPORT
  305. #elif defined(U_IO_IMPLEMENTATION)
  306. #define U_DATA_API U_IMPORT
  307. #define U_COMMON_API U_IMPORT
  308. #define U_I18N_API U_IMPORT
  309. #define U_LAYOUT_API U_IMPORT
  310. #define U_LAYOUTEX_API U_IMPORT
  311. #define U_IO_API U_EXPORT
  312. #define U_TOOLUTIL_API U_IMPORT
  313. #elif defined(U_TOOLUTIL_IMPLEMENTATION)
  314. #define U_DATA_API U_IMPORT
  315. #define U_COMMON_API U_IMPORT
  316. #define U_I18N_API U_IMPORT
  317. #define U_LAYOUT_API U_IMPORT
  318. #define U_LAYOUTEX_API U_IMPORT
  319. #define U_IO_API U_IMPORT
  320. #define U_TOOLUTIL_API U_EXPORT
  321. #else
  322. #define U_DATA_API U_IMPORT
  323. #define U_COMMON_API U_IMPORT
  324. #define U_I18N_API U_IMPORT
  325. #define U_LAYOUT_API U_IMPORT
  326. #define U_LAYOUTEX_API U_IMPORT
  327. #define U_IO_API U_IMPORT
  328. #define U_TOOLUTIL_API U_IMPORT
  329. #endif
  330. /**
  331. * \def U_STANDARD_CPP_NAMESPACE
  332. * Control of C++ Namespace
  333. * @stable ICU 2.0
  334. */
  335. #ifdef __cplusplus
  336. #define U_STANDARD_CPP_NAMESPACE ::
  337. #else
  338. #define U_STANDARD_CPP_NAMESPACE
  339. #endif
  340. /*===========================================================================*/
  341. /* Global delete operator */
  342. /*===========================================================================*/
  343. /*
  344. * The ICU4C library must not use the global new and delete operators.
  345. * These operators here are defined to enable testing for this.
  346. * See Jitterbug 2581 for details of why this is necessary.
  347. *
  348. * Verification that ICU4C's memory usage is correct, i.e.,
  349. * that global new/delete are not used:
  350. *
  351. * a) Check for imports of global new/delete (see uobject.cpp for details)
  352. * b) Verify that new is never imported.
  353. * c) Verify that delete is only imported from object code for interface/mixin classes.
  354. * d) Add global delete and delete[] only for the ICU4C library itself
  355. * and define them in a way that crashes or otherwise easily shows a problem.
  356. *
  357. * The following implements d).
  358. * The operator implementations crash; this is intentional and used for library debugging.
  359. *
  360. * Note: This is currently only done on Windows because
  361. * some Linux/Unix compilers have problems with defining global new/delete.
  362. * On Windows, it is _MSC_VER>=1200 for MSVC 6.0 and higher.
  363. */
  364. #if defined(__cplusplus) && 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))
  365. #ifndef U_HIDE_INTERNAL_API
  366. /**
  367. * Global operator new, defined only inside ICU4C, must not be used.
  368. * Crashes intentionally.
  369. * @internal
  370. */
  371. inline void *
  372. operator new(size_t /*size*/) {
  373. char *q=NULL;
  374. *q=5; /* break it */
  375. return q;
  376. }
  377. #ifdef _Ret_bytecap_
  378. /* This is only needed to suppress a Visual C++ 2008 warning for operator new[]. */
  379. _Ret_bytecap_(_Size)
  380. #endif
  381. /**
  382. * Global operator new[], defined only inside ICU4C, must not be used.
  383. * Crashes intentionally.
  384. * @internal
  385. */
  386. inline void *
  387. operator new[](size_t /*size*/) {
  388. char *q=NULL;
  389. *q=5; /* break it */
  390. return q;
  391. }
  392. /**
  393. * Global operator delete, defined only inside ICU4C, must not be used.
  394. * Crashes intentionally.
  395. * @internal
  396. */
  397. inline void
  398. operator delete(void * /*p*/) {
  399. char *q=NULL;
  400. *q=5; /* break it */
  401. }
  402. /**
  403. * Global operator delete[], defined only inside ICU4C, must not be used.
  404. * Crashes intentionally.
  405. * @internal
  406. */
  407. inline void
  408. operator delete[](void * /*p*/) {
  409. char *q=NULL;
  410. *q=5; /* break it */
  411. }
  412. #endif /* U_HIDE_INTERNAL_API */
  413. #endif
  414. /*===========================================================================*/
  415. /* UErrorCode */
  416. /*===========================================================================*/
  417. /**
  418. * Error code to replace exception handling, so that the code is compatible with all C++ compilers,
  419. * and to use the same mechanism for C and C++.
  420. *
  421. * \par
  422. * ICU functions that take a reference (C++) or a pointer (C) to a UErrorCode
  423. * first test if(U_FAILURE(errorCode)) { return immediately; }
  424. * so that in a chain of such functions the first one that sets an error code
  425. * causes the following ones to not perform any operations.
  426. *
  427. * \par
  428. * Error codes should be tested using U_FAILURE() and U_SUCCESS().
  429. * @stable ICU 2.0
  430. */
  431. typedef enum UErrorCode {
  432. /* The ordering of U_ERROR_INFO_START Vs U_USING_FALLBACK_WARNING looks weird
  433. * and is that way because VC++ debugger displays first encountered constant,
  434. * which is not the what the code is used for
  435. */
  436. U_USING_FALLBACK_WARNING = -128, /**< A resource bundle lookup returned a fallback result (not an error) */
  437. U_ERROR_WARNING_START = -128, /**< Start of information results (semantically successful) */
  438. U_USING_DEFAULT_WARNING = -127, /**< A resource bundle lookup returned a result from the root locale (not an error) */
  439. U_SAFECLONE_ALLOCATED_WARNING = -126, /**< A SafeClone operation required allocating memory (informational only) */
  440. U_STATE_OLD_WARNING = -125, /**< ICU has to use compatibility layer to construct the service. Expect performance/memory usage degradation. Consider upgrading */
  441. U_STRING_NOT_TERMINATED_WARNING = -124,/**< An output string could not be NUL-terminated because output length==destCapacity. */
  442. U_SORT_KEY_TOO_SHORT_WARNING = -123, /**< Number of levels requested in getBound is higher than the number of levels in the sort key */
  443. U_AMBIGUOUS_ALIAS_WARNING = -122, /**< This converter alias can go to different converter implementations */
  444. 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 */
  445. U_PLUGIN_CHANGED_LEVEL_WARNING = -120, /**< A plugin caused a level change. May not be an error, but later plugins may not load. */
  446. U_ERROR_WARNING_LIMIT, /**< This must always be the last warning value to indicate the limit for UErrorCode warnings (last warning code +1) */
  447. U_ZERO_ERROR = 0, /**< No error, no warning. */
  448. U_ILLEGAL_ARGUMENT_ERROR = 1, /**< Start of codes indicating failure */
  449. U_MISSING_RESOURCE_ERROR = 2, /**< The requested resource cannot be found */
  450. U_INVALID_FORMAT_ERROR = 3, /**< Data format is not what is expected */
  451. U_FILE_ACCESS_ERROR = 4, /**< The requested file cannot be found */
  452. U_INTERNAL_PROGRAM_ERROR = 5, /**< Indicates a bug in the library code */
  453. U_MESSAGE_PARSE_ERROR = 6, /**< Unable to parse a message (message format) */
  454. U_MEMORY_ALLOCATION_ERROR = 7, /**< Memory allocation error */
  455. U_INDEX_OUTOFBOUNDS_ERROR = 8, /**< Trying to access the index that is out of bounds */
  456. U_PARSE_ERROR = 9, /**< Equivalent to Java ParseException */
  457. U_INVALID_CHAR_FOUND = 10, /**< Character conversion: Unmappable input sequence. In other APIs: Invalid character. */
  458. U_TRUNCATED_CHAR_FOUND = 11, /**< Character conversion: Incomplete input sequence. */
  459. U_ILLEGAL_CHAR_FOUND = 12, /**< Character conversion: Illegal input sequence/combination of input units. */
  460. U_INVALID_TABLE_FORMAT = 13, /**< Conversion table file found, but corrupted */
  461. U_INVALID_TABLE_FILE = 14, /**< Conversion table file not found */
  462. U_BUFFER_OVERFLOW_ERROR = 15, /**< A result would not fit in the supplied buffer */
  463. U_UNSUPPORTED_ERROR = 16, /**< Requested operation not supported in current context */
  464. U_RESOURCE_TYPE_MISMATCH = 17, /**< an operation is requested over a resource that does not support it */
  465. U_ILLEGAL_ESCAPE_SEQUENCE = 18, /**< ISO-2022 illlegal escape sequence */
  466. U_UNSUPPORTED_ESCAPE_SEQUENCE = 19, /**< ISO-2022 unsupported escape sequence */
  467. U_NO_SPACE_AVAILABLE = 20, /**< No space available for in-buffer expansion for Arabic shaping */
  468. U_CE_NOT_FOUND_ERROR = 21, /**< Currently used only while setting variable top, but can be used generally */
  469. U_PRIMARY_TOO_LONG_ERROR = 22, /**< User tried to set variable top to a primary that is longer than two bytes */
  470. U_STATE_TOO_OLD_ERROR = 23, /**< ICU cannot construct a service from this state, as it is no longer supported */
  471. U_TOO_MANY_ALIASES_ERROR = 24, /**< There are too many aliases in the path to the requested resource.
  472. It is very possible that a circular alias definition has occured */
  473. U_ENUM_OUT_OF_SYNC_ERROR = 25, /**< UEnumeration out of sync with underlying collection */
  474. U_INVARIANT_CONVERSION_ERROR = 26, /**< Unable to convert a UChar* string to char* with the invariant converter. */
  475. U_INVALID_STATE_ERROR = 27, /**< Requested operation can not be completed with ICU in its current state */
  476. U_COLLATOR_VERSION_MISMATCH = 28, /**< Collator version is not compatible with the base version */
  477. U_USELESS_COLLATOR_ERROR = 29, /**< Collator is options only and no base is specified */
  478. U_NO_WRITE_PERMISSION = 30, /**< Attempt to modify read-only or constant data. */
  479. U_STANDARD_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for standard errors */
  480. /*
  481. * the error code range 0x10000 0x10100 are reserved for Transliterator
  482. */
  483. U_BAD_VARIABLE_DEFINITION=0x10000,/**< Missing '$' or duplicate variable name */
  484. U_PARSE_ERROR_START = 0x10000, /**< Start of Transliterator errors */
  485. U_MALFORMED_RULE, /**< Elements of a rule are misplaced */
  486. U_MALFORMED_SET, /**< A UnicodeSet pattern is invalid*/
  487. U_MALFORMED_SYMBOL_REFERENCE, /**< UNUSED as of ICU 2.4 */
  488. U_MALFORMED_UNICODE_ESCAPE, /**< A Unicode escape pattern is invalid*/
  489. U_MALFORMED_VARIABLE_DEFINITION, /**< A variable definition is invalid */
  490. U_MALFORMED_VARIABLE_REFERENCE, /**< A variable reference is invalid */
  491. U_MISMATCHED_SEGMENT_DELIMITERS, /**< UNUSED as of ICU 2.4 */
  492. U_MISPLACED_ANCHOR_START, /**< A start anchor appears at an illegal position */
  493. U_MISPLACED_CURSOR_OFFSET, /**< A cursor offset occurs at an illegal position */
  494. U_MISPLACED_QUANTIFIER, /**< A quantifier appears after a segment close delimiter */
  495. U_MISSING_OPERATOR, /**< A rule contains no operator */
  496. U_MISSING_SEGMENT_CLOSE, /**< UNUSED as of ICU 2.4 */
  497. U_MULTIPLE_ANTE_CONTEXTS, /**< More than one ante context */
  498. U_MULTIPLE_CURSORS, /**< More than one cursor */
  499. U_MULTIPLE_POST_CONTEXTS, /**< More than one post context */
  500. U_TRAILING_BACKSLASH, /**< A dangling backslash */
  501. U_UNDEFINED_SEGMENT_REFERENCE, /**< A segment reference does not correspond to a defined segment */
  502. U_UNDEFINED_VARIABLE, /**< A variable reference does not correspond to a defined variable */
  503. U_UNQUOTED_SPECIAL, /**< A special character was not quoted or escaped */
  504. U_UNTERMINATED_QUOTE, /**< A closing single quote is missing */
  505. U_RULE_MASK_ERROR, /**< A rule is hidden by an earlier more general rule */
  506. U_MISPLACED_COMPOUND_FILTER, /**< A compound filter is in an invalid location */
  507. U_MULTIPLE_COMPOUND_FILTERS, /**< More than one compound filter */
  508. U_INVALID_RBT_SYNTAX, /**< A "::id" rule was passed to the RuleBasedTransliterator parser */
  509. U_INVALID_PROPERTY_PATTERN, /**< UNUSED as of ICU 2.4 */
  510. U_MALFORMED_PRAGMA, /**< A 'use' pragma is invlalid */
  511. U_UNCLOSED_SEGMENT, /**< A closing ')' is missing */
  512. U_ILLEGAL_CHAR_IN_SEGMENT, /**< UNUSED as of ICU 2.4 */
  513. U_VARIABLE_RANGE_EXHAUSTED, /**< Too many stand-ins generated for the given variable range */
  514. U_VARIABLE_RANGE_OVERLAP, /**< The variable range overlaps characters used in rules */
  515. U_ILLEGAL_CHARACTER, /**< A special character is outside its allowed context */
  516. U_INTERNAL_TRANSLITERATOR_ERROR, /**< Internal transliterator system error */
  517. U_INVALID_ID, /**< A "::id" rule specifies an unknown transliterator */
  518. U_INVALID_FUNCTION, /**< A "&fn()" rule specifies an unknown transliterator */
  519. U_PARSE_ERROR_LIMIT, /**< The limit for Transliterator errors */
  520. /*
  521. * the error code range 0x10100 0x10200 are reserved for formatting API parsing error
  522. */
  523. U_UNEXPECTED_TOKEN=0x10100, /**< Syntax error in format pattern */
  524. U_FMT_PARSE_ERROR_START=0x10100, /**< Start of format library errors */
  525. U_MULTIPLE_DECIMAL_SEPARATORS, /**< More than one decimal separator in number pattern */
  526. U_MULTIPLE_DECIMAL_SEPERATORS = U_MULTIPLE_DECIMAL_SEPARATORS, /**< Typo: kept for backward compatibility. Use U_MULTIPLE_DECIMAL_SEPARATORS */
  527. U_MULTIPLE_EXPONENTIAL_SYMBOLS, /**< More than one exponent symbol in number pattern */
  528. U_MALFORMED_EXPONENTIAL_PATTERN, /**< Grouping symbol in exponent pattern */
  529. U_MULTIPLE_PERCENT_SYMBOLS, /**< More than one percent symbol in number pattern */
  530. U_MULTIPLE_PERMILL_SYMBOLS, /**< More than one permill symbol in number pattern */
  531. U_MULTIPLE_PAD_SPECIFIERS, /**< More than one pad symbol in number pattern */
  532. U_PATTERN_SYNTAX_ERROR, /**< Syntax error in format pattern */
  533. U_ILLEGAL_PAD_POSITION, /**< Pad symbol misplaced in number pattern */
  534. U_UNMATCHED_BRACES, /**< Braces do not match in message pattern */
  535. U_UNSUPPORTED_PROPERTY, /**< UNUSED as of ICU 2.4 */
  536. U_UNSUPPORTED_ATTRIBUTE, /**< UNUSED as of ICU 2.4 */
  537. U_ARGUMENT_TYPE_MISMATCH, /**< Argument name and argument index mismatch in MessageFormat functions */
  538. U_DUPLICATE_KEYWORD, /**< Duplicate keyword in PluralFormat */
  539. U_UNDEFINED_KEYWORD, /**< Undefined Plural keyword */
  540. U_DEFAULT_KEYWORD_MISSING, /**< Missing DEFAULT rule in plural rules */
  541. U_DECIMAL_NUMBER_SYNTAX_ERROR, /**< Decimal number syntax error */
  542. U_FORMAT_INEXACT_ERROR, /**< Cannot format a number exactly and rounding mode is ROUND_UNNECESSARY @stable ICU 4.8 */
  543. U_FMT_PARSE_ERROR_LIMIT, /**< The limit for format library errors */
  544. /*
  545. * the error code range 0x10200 0x102ff are reserved for Break Iterator related error
  546. */
  547. U_BRK_INTERNAL_ERROR=0x10200, /**< An internal error (bug) was detected. */
  548. U_BRK_ERROR_START=0x10200, /**< Start of codes indicating Break Iterator failures */
  549. U_BRK_HEX_DIGITS_EXPECTED, /**< Hex digits expected as part of a escaped char in a rule. */
  550. U_BRK_SEMICOLON_EXPECTED, /**< Missing ';' at the end of a RBBI rule. */
  551. U_BRK_RULE_SYNTAX, /**< Syntax error in RBBI rule. */
  552. U_BRK_UNCLOSED_SET, /**< UnicodeSet witing an RBBI rule missing a closing ']'. */
  553. U_BRK_ASSIGN_ERROR, /**< Syntax error in RBBI rule assignment statement. */
  554. U_BRK_VARIABLE_REDFINITION, /**< RBBI rule $Variable redefined. */
  555. U_BRK_MISMATCHED_PAREN, /**< Mis-matched parentheses in an RBBI rule. */
  556. U_BRK_NEW_LINE_IN_QUOTED_STRING, /**< Missing closing quote in an RBBI rule. */
  557. U_BRK_UNDEFINED_VARIABLE, /**< Use of an undefined $Variable in an RBBI rule. */
  558. U_BRK_INIT_ERROR, /**< Initialization failure. Probable missing ICU Data. */
  559. U_BRK_RULE_EMPTY_SET, /**< Rule contains an empty Unicode Set. */
  560. U_BRK_UNRECOGNIZED_OPTION, /**< !!option in RBBI rules not recognized. */
  561. U_BRK_MALFORMED_RULE_TAG, /**< The {nnn} tag on a rule is mal formed */
  562. U_BRK_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for Break Iterator failures */
  563. /*
  564. * The error codes in the range 0x10300-0x103ff are reserved for regular expression related errrs
  565. */
  566. U_REGEX_INTERNAL_ERROR=0x10300, /**< An internal error (bug) was detected. */
  567. U_REGEX_ERROR_START=0x10300, /**< Start of codes indicating Regexp failures */
  568. U_REGEX_RULE_SYNTAX, /**< Syntax error in regexp pattern. */
  569. U_REGEX_INVALID_STATE, /**< RegexMatcher in invalid state for requested operation */
  570. U_REGEX_BAD_ESCAPE_SEQUENCE, /**< Unrecognized backslash escape sequence in pattern */
  571. U_REGEX_PROPERTY_SYNTAX, /**< Incorrect Unicode property */
  572. U_REGEX_UNIMPLEMENTED, /**< Use of regexp feature that is not yet implemented. */
  573. U_REGEX_MISMATCHED_PAREN, /**< Incorrectly nested parentheses in regexp pattern. */
  574. U_REGEX_NUMBER_TOO_BIG, /**< Decimal number is too large. */
  575. U_REGEX_BAD_INTERVAL, /**< Error in {min,max} interval */
  576. U_REGEX_MAX_LT_MIN, /**< In {min,max}, max is less than min. */
  577. U_REGEX_INVALID_BACK_REF, /**< Back-reference to a non-existent capture group. */
  578. U_REGEX_INVALID_FLAG, /**< Invalid value for match mode flags. */
  579. U_REGEX_LOOK_BEHIND_LIMIT, /**< Look-Behind pattern matches must have a bounded maximum length. */
  580. U_REGEX_SET_CONTAINS_STRING, /**< Regexps cannot have UnicodeSets containing strings.*/
  581. #ifndef U_HIDE_DEPRECATED_API
  582. U_REGEX_OCTAL_TOO_BIG, /**< Octal character constants must be <= 0377. @deprecated ICU 54. This error cannot occur. */
  583. #endif /* U_HIDE_DEPRECATED_API */
  584. U_REGEX_MISSING_CLOSE_BRACKET=U_REGEX_SET_CONTAINS_STRING+2, /**< Missing closing bracket on a bracket expression. */
  585. U_REGEX_INVALID_RANGE, /**< In a character range [x-y], x is greater than y. */
  586. U_REGEX_STACK_OVERFLOW, /**< Regular expression backtrack stack overflow. */
  587. U_REGEX_TIME_OUT, /**< Maximum allowed match time exceeded */
  588. U_REGEX_STOPPED_BY_CALLER, /**< Matching operation aborted by user callback fn. */
  589. #ifndef U_HIDE_DRAFT_API
  590. U_REGEX_PATTERN_TOO_BIG, /**< Pattern exceeds limits on size or complexity. @draft ICU 55 */
  591. U_REGEX_INVALID_CAPTURE_GROUP_NAME, /**< Invalid capture group name. @draft ICU 55 */
  592. #endif /* U_HIDE_DRAFT_API */
  593. U_REGEX_ERROR_LIMIT=U_REGEX_STOPPED_BY_CALLER+3, /**< This must always be the last value to indicate the limit for regexp errors */
  594. /*
  595. * The error code in the range 0x10400-0x104ff are reserved for IDNA related error codes
  596. */
  597. U_IDNA_PROHIBITED_ERROR=0x10400,
  598. U_IDNA_ERROR_START=0x10400,
  599. U_IDNA_UNASSIGNED_ERROR,
  600. U_IDNA_CHECK_BIDI_ERROR,
  601. U_IDNA_STD3_ASCII_RULES_ERROR,
  602. U_IDNA_ACE_PREFIX_ERROR,
  603. U_IDNA_VERIFICATION_ERROR,
  604. U_IDNA_LABEL_TOO_LONG_ERROR,
  605. U_IDNA_ZERO_LENGTH_LABEL_ERROR,
  606. U_IDNA_DOMAIN_NAME_TOO_LONG_ERROR,
  607. U_IDNA_ERROR_LIMIT,
  608. /*
  609. * Aliases for StringPrep
  610. */
  611. U_STRINGPREP_PROHIBITED_ERROR = U_IDNA_PROHIBITED_ERROR,
  612. U_STRINGPREP_UNASSIGNED_ERROR = U_IDNA_UNASSIGNED_ERROR,
  613. U_STRINGPREP_CHECK_BIDI_ERROR = U_IDNA_CHECK_BIDI_ERROR,
  614. /*
  615. * The error code in the range 0x10500-0x105ff are reserved for Plugin related error codes
  616. */
  617. U_PLUGIN_ERROR_START=0x10500, /**< Start of codes indicating plugin failures */
  618. U_PLUGIN_TOO_HIGH=0x10500, /**< The plugin's level is too high to be loaded right now. */
  619. U_PLUGIN_DIDNT_SET_LEVEL, /**< The plugin didn't call uplug_setPlugLevel in response to a QUERY */
  620. U_PLUGIN_ERROR_LIMIT, /**< This must always be the last value to indicate the limit for plugin errors */
  621. U_ERROR_LIMIT=U_PLUGIN_ERROR_LIMIT /**< This must always be the last value to indicate the limit for UErrorCode (last error code +1) */
  622. } UErrorCode;
  623. /* Use the following to determine if an UErrorCode represents */
  624. /* operational success or failure. */
  625. #ifdef __cplusplus
  626. /**
  627. * Does the error code indicate success?
  628. * @stable ICU 2.0
  629. */
  630. static
  631. inline UBool U_SUCCESS(UErrorCode code) { return (UBool)(code<=U_ZERO_ERROR); }
  632. /**
  633. * Does the error code indicate a failure?
  634. * @stable ICU 2.0
  635. */
  636. static
  637. inline UBool U_FAILURE(UErrorCode code) { return (UBool)(code>U_ZERO_ERROR); }
  638. #else
  639. /**
  640. * Does the error code indicate success?
  641. * @stable ICU 2.0
  642. */
  643. # define U_SUCCESS(x) ((x)<=U_ZERO_ERROR)
  644. /**
  645. * Does the error code indicate a failure?
  646. * @stable ICU 2.0
  647. */
  648. # define U_FAILURE(x) ((x)>U_ZERO_ERROR)
  649. #endif
  650. /**
  651. * Return a string for a UErrorCode value.
  652. * The string will be the same as the name of the error code constant
  653. * in the UErrorCode enum above.
  654. * @stable ICU 2.0
  655. */
  656. U_STABLE const char * U_EXPORT2
  657. u_errorName(UErrorCode code);
  658. #endif /* _UTYPES */