// © 2016 and later: Unicode, Inc. and others. // License & terms of use: http://www.unicode.org/copyright.html /* ********************************************************************** * Copyright (C) 1996-2016, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * * FILE NAME : UTYPES.H (formerly ptypes.h) * * Date Name Description * 12/11/96 helena Creation. * 02/27/97 aliu Added typedefs for UClassID, int8, int16, int32, * uint8, uint16, and uint32. * 04/01/97 aliu Added XP_CPLUSPLUS and modified to work under C as * well as C++. * Modified to use memcpy() for uprv_arrayCopy() fns. * 04/14/97 aliu Added TPlatformUtilities. * 05/07/97 aliu Added import/export specifiers (replacing the old * broken EXT_CLASS). Added version number for our * code. Cleaned up header. * 6/20/97 helena Java class name change. * 08/11/98 stephen UErrorCode changed from typedef to enum * 08/12/98 erm Changed T_ANALYTIC_PACKAGE_VERSION to 3 * 08/14/98 stephen Added uprv_arrayCopy() for int8_t, int16_t, int32_t * 12/09/98 jfitz Added BUFFER_OVERFLOW_ERROR (bug 1100066) * 04/20/99 stephen Cleaned up & reworked for autoconf. * Renamed to utypes.h. * 05/05/99 stephen Changed to use <inttypes.h> * 12/07/99 helena Moved copyright notice string from ucnv_bld.h here. ******************************************************************************* */ #ifndef UTYPES_H #define UTYPES_H #include "unicode/umachine.h" #include "unicode/uversion.h" #include "unicode/uconfig.h" #include <float.h> #if !U_NO_DEFAULT_INCLUDE_UTF_HEADERS # include "unicode/utf.h" #endif /*! * \file * \brief Basic definitions for ICU, for both C and C++ APIs * * This file defines basic types, constants, and enumerations directly or * indirectly by including other header files, especially utf.h for the * basic character and string definitions and umachine.h for consistent * integer and other types. */ /** * \def U_SHOW_CPLUSPLUS_API * @internal */ #ifdef __cplusplus # ifndef U_SHOW_CPLUSPLUS_API #define U_SHOW_CPLUSPLUS_API … # endif #else # undef U_SHOW_CPLUSPLUS_API #define U_SHOW_CPLUSPLUS_API … #endif /** @{ API visibility control */ /** * \def U_HIDE_DRAFT_API * Define this to 1 to request that draft API be "hidden" * @internal */ /** * \def U_HIDE_INTERNAL_API * Define this to 1 to request that internal API be "hidden" * @internal */ #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_DRAFT_API) #define U_HIDE_DRAFT_API … #endif #if !U_DEFAULT_SHOW_DRAFT && !defined(U_SHOW_INTERNAL_API) #define U_HIDE_INTERNAL_API … #endif /** @} */ /*===========================================================================*/ /* ICUDATA naming scheme */ /*===========================================================================*/ /** * \def U_ICUDATA_TYPE_LETTER * * This is a platform-dependent string containing one letter: * - b for big-endian, ASCII-family platforms * - l for little-endian, ASCII-family platforms * - e for big-endian, EBCDIC-family platforms * This letter is part of the common data file name. * @stable ICU 2.0 */ /** * \def U_ICUDATA_TYPE_LITLETTER * The non-string form of U_ICUDATA_TYPE_LETTER * @stable ICU 2.0 */ #if U_CHARSET_FAMILY # if U_IS_BIG_ENDIAN /* EBCDIC - should always be BE */ #define U_ICUDATA_TYPE_LETTER … #define U_ICUDATA_TYPE_LITLETTER … # else # error "Don't know what to do with little endian EBCDIC!" #define U_ICUDATA_TYPE_LETTER … #define U_ICUDATA_TYPE_LITLETTER … # endif #else # if U_IS_BIG_ENDIAN /* Big-endian ASCII */ #define U_ICUDATA_TYPE_LETTER … #define U_ICUDATA_TYPE_LITLETTER … # else /* Little-endian ASCII */ #define U_ICUDATA_TYPE_LETTER … #define U_ICUDATA_TYPE_LITLETTER … # endif #endif /** * A single string literal containing the icudata stub name. i.e. 'icudt18e' for * ICU 1.8.x on EBCDIC, etc.. * @stable ICU 2.0 */ #define U_ICUDATA_NAME … #ifndef U_HIDE_INTERNAL_API #define U_USRDATA_NAME … #define U_USE_USRDATA … #endif /* U_HIDE_INTERNAL_API */ /** * U_ICU_ENTRY_POINT is the name of the DLL entry point to the ICU data library. * Defined as a literal, not a string. * Tricky Preprocessor use - ## operator replaces macro parameters with the literal string * from the corresponding macro invocation, _before_ other macro substitutions. * Need a nested \#defines to get the actual version numbers rather than * the literal text U_ICU_VERSION_MAJOR_NUM into the name. * The net result will be something of the form * \#define U_ICU_ENTRY_POINT icudt19_dat * @stable ICU 2.4 */ #define U_ICUDATA_ENTRY_POINT … #ifndef U_HIDE_INTERNAL_API /** * Do not use. Note that it's OK for the 2nd argument to be undefined (literal). * @internal */ #define U_DEF2_ICUDATA_ENTRY_POINT(major,suff) … /** * Do not use. * @internal */ #ifndef U_DEF_ICUDATA_ENTRY_POINT /* affected by symbol renaming. See platform.h */ #ifndef U_LIB_SUFFIX_C_NAME #define U_DEF_ICUDATA_ENTRY_POINT … #else #define U_DEF_ICUDATA_ENTRY_POINT(major, suff) … #endif #endif #endif /* U_HIDE_INTERNAL_API */ /** * \def NULL * Define NULL if necessary, to nullptr for C++ and to ((void *)0) for C. * @stable ICU 2.0 */ #ifndef NULL #ifdef __cplusplus #define NULL … #else #define NULL … #endif #endif /*===========================================================================*/ /* Calendar/TimeZone data types */ /*===========================================================================*/ /** * Date and Time data type. * This is a primitive data type that holds the date and time * as the number of milliseconds since 1970-jan-01, 00:00 UTC. * UTC leap seconds are ignored. * @stable ICU 2.0 */ UDate; /** The number of milliseconds per second @stable ICU 2.0 */ #define U_MILLIS_PER_SECOND … /** The number of milliseconds per minute @stable ICU 2.0 */ #define U_MILLIS_PER_MINUTE … /** The number of milliseconds per hour @stable ICU 2.0 */ #define U_MILLIS_PER_HOUR … /** The number of milliseconds per day @stable ICU 2.0 */ #define U_MILLIS_PER_DAY … /** * Maximum UDate value * @stable ICU 4.8 */ #define U_DATE_MAX … /** * Minimum UDate value * @stable ICU 4.8 */ #define U_DATE_MIN … /*===========================================================================*/ /* Shared library/DLL import-export API control */ /*===========================================================================*/ /* * Control of symbol import/export. * ICU is separated into three libraries. */ /** * \def U_COMBINED_IMPLEMENTATION * Set to export library symbols from inside the ICU library * when all of ICU is in a single library. * This can be set as a compiler option while building ICU, and it * needs to be the first one tested to override U_COMMON_API, U_I18N_API, etc. * @stable ICU 2.0 */ /** * \def U_DATA_API * Set to export library symbols from inside the stubdata library, * and to import them from outside. * @stable ICU 3.0 */ /** * \def U_COMMON_API * Set to export library symbols from inside the common library, * and to import them from outside. * @stable ICU 2.0 */ /** * \def U_I18N_API * Set to export library symbols from inside the i18n library, * and to import them from outside. * @stable ICU 2.0 */ /** * \def U_LAYOUT_API * Set to export library symbols from inside the layout engine library, * and to import them from outside. * @stable ICU 2.0 */ /** * \def U_LAYOUTEX_API * Set to export library symbols from inside the layout extensions library, * and to import them from outside. * @stable ICU 2.6 */ /** * \def U_IO_API * Set to export library symbols from inside the ustdio library, * and to import them from outside. * @stable ICU 2.0 */ /** * \def U_TOOLUTIL_API * Set to export library symbols from inside the toolutil library, * and to import them from outside. * @stable ICU 3.4 */ #ifdef U_IN_DOXYGEN // This definition is required when generating the API docs. #define U_COMBINED_IMPLEMENTATION … #endif #if defined(U_COMBINED_IMPLEMENTATION) #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #elif defined(U_STATIC_IMPLEMENTATION) #define U_DATA_API #define U_COMMON_API #define U_I18N_API #define U_LAYOUT_API #define U_LAYOUTEX_API #define U_IO_API #define U_TOOLUTIL_API #elif defined(U_COMMON_IMPLEMENTATION) #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #elif defined(U_I18N_IMPLEMENTATION) #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #elif defined(U_LAYOUT_IMPLEMENTATION) #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #elif defined(U_LAYOUTEX_IMPLEMENTATION) #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #elif defined(U_IO_IMPLEMENTATION) #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #elif defined(U_TOOLUTIL_IMPLEMENTATION) #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #else #define U_DATA_API … #define U_COMMON_API … #define U_I18N_API … #define U_LAYOUT_API … #define U_LAYOUTEX_API … #define U_IO_API … #define U_TOOLUTIL_API … #endif /** * \def U_STANDARD_CPP_NAMESPACE * Control of C++ Namespace * @stable ICU 2.0 */ #ifdef __cplusplus #define U_STANDARD_CPP_NAMESPACE … #else #define U_STANDARD_CPP_NAMESPACE #endif /*===========================================================================*/ /* UErrorCode */ /*===========================================================================*/ /** * Standard ICU4C error code type, a substitute for exceptions. * * Initialize the UErrorCode with U_ZERO_ERROR, and check for success or * failure using U_SUCCESS() or U_FAILURE(): * * UErrorCode errorCode = U_ZERO_ERROR; * // call ICU API that needs an error code parameter. * if (U_FAILURE(errorCode)) { * // An error occurred. Handle it here. * } * * C++ code should use icu::ErrorCode, available in unicode/errorcode.h, or a * suitable subclass. * * For more information, see: * https://unicode-org.github.io/icu/userguide/dev/codingguidelines#details-about-icu-error-codes * * Note: By convention, ICU functions that take a reference (C++) or a pointer * (C) to a UErrorCode first test: * * if (U_FAILURE(errorCode)) { return immediately; } * * so that in a chain of such functions the first one that sets an error code * causes the following ones to not perform any operations. * * @stable ICU 2.0 */ UErrorCode; /* Use the following to determine if an UErrorCode represents */ /* operational success or failure. */ #ifdef __cplusplus /** * Does the error code indicate success? * @stable ICU 2.0 */ static inline UBool U_SUCCESS(UErrorCode code) { … } /** * Does the error code indicate a failure? * @stable ICU 2.0 */ static inline UBool U_FAILURE(UErrorCode code) { … } #else /** * Does the error code indicate success? * @stable ICU 2.0 */ #define U_SUCCESS … /** * Does the error code indicate a failure? * @stable ICU 2.0 */ #define U_FAILURE … #endif /** * Return a string for a UErrorCode value. * The string will be the same as the name of the error code constant * in the UErrorCode enum above. * @stable ICU 2.0 */ U_CAPI const char * U_EXPORT2 u_errorName(UErrorCode code); #endif /* _UTYPES */