| 1 |
// © 2016 and later: Unicode, Inc. and others. |
| 2 |
// License & terms of use: http://www.unicode.org/copyright.html |
| 3 |
/* |
| 4 |
******************************************************************************* |
| 5 |
* Copyright (C) 2000-2011, International Business Machines |
| 6 |
* Corporation and others. All Rights Reserved. |
| 7 |
******************************************************************************* |
| 8 |
* |
| 9 |
* file name: uversion.h |
| 10 |
* encoding: UTF-8 |
| 11 |
* tab size: 8 (not used) |
| 12 |
* indentation:4 |
| 13 |
* |
| 14 |
* Created by: Vladimir Weinstein |
| 15 |
* |
| 16 |
* Gets included by utypes.h and Windows .rc files |
| 17 |
*/ |
| 18 |
|
| 19 |
/** |
| 20 |
* \file |
| 21 |
* \brief C API: API for accessing ICU version numbers. |
| 22 |
*/ |
| 23 |
/*===========================================================================*/ |
| 24 |
/* Main ICU version information */ |
| 25 |
/*===========================================================================*/ |
| 26 |
|
| 27 |
#ifndef UVERSION_H |
| 28 |
#define UVERSION_H |
| 29 |
|
| 30 |
#include "unicode/umachine.h" |
| 31 |
|
| 32 |
/* Actual version info lives in uvernum.h */ |
| 33 |
#include "unicode/uvernum.h" |
| 34 |
|
| 35 |
/** Maximum length of the copyright string. |
| 36 |
* @stable ICU 2.4 |
| 37 |
*/ |
| 38 |
#define U_COPYRIGHT_STRING_LENGTH 128 |
| 39 |
|
| 40 |
/** An ICU version consists of up to 4 numbers from 0..255. |
| 41 |
* @stable ICU 2.4 |
| 42 |
*/ |
| 43 |
#define U_MAX_VERSION_LENGTH 4 |
| 44 |
|
| 45 |
/** In a string, ICU version fields are delimited by dots. |
| 46 |
* @stable ICU 2.4 |
| 47 |
*/ |
| 48 |
#define U_VERSION_DELIMITER '.' |
| 49 |
|
| 50 |
/** The maximum length of an ICU version string. |
| 51 |
* @stable ICU 2.4 |
| 52 |
*/ |
| 53 |
#define U_MAX_VERSION_STRING_LENGTH 20 |
| 54 |
|
| 55 |
/** The binary form of a version on ICU APIs is an array of 4 uint8_t. |
| 56 |
* To compare two versions, use memcmp(v1,v2,sizeof(UVersionInfo)). |
| 57 |
* @stable ICU 2.4 |
| 58 |
*/ |
| 59 |
typedef uint8_t UVersionInfo[U_MAX_VERSION_LENGTH]; |
| 60 |
|
| 61 |
/*===========================================================================*/ |
| 62 |
/* C++ namespace if supported. Versioned unless versioning is disabled. */ |
| 63 |
/*===========================================================================*/ |
| 64 |
|
| 65 |
/* Define C++ namespace symbols. */ |
| 66 |
#ifdef __cplusplus |
| 67 |
|
| 68 |
/** |
| 69 |
* \def U_NAMESPACE_BEGIN |
| 70 |
* This is used to begin a declaration of a public ICU C++ API within |
| 71 |
* versioned-ICU-namespace block. |
| 72 |
* |
| 73 |
* @stable ICU 2.4 |
| 74 |
*/ |
| 75 |
|
| 76 |
/** |
| 77 |
* \def U_NAMESPACE_END |
| 78 |
* This is used to end a declaration of a public ICU C++ API. |
| 79 |
* It ends the versioned-ICU-namespace block begun by U_NAMESPACE_BEGIN. |
| 80 |
* |
| 81 |
* @stable ICU 2.4 |
| 82 |
*/ |
| 83 |
|
| 84 |
/** |
| 85 |
* \def U_NAMESPACE_USE |
| 86 |
* This is used to specify that the rest of the code uses the |
| 87 |
* public ICU C++ API namespace. |
| 88 |
* @stable ICU 2.4 |
| 89 |
*/ |
| 90 |
|
| 91 |
/** |
| 92 |
* \def U_NAMESPACE_QUALIFIER |
| 93 |
* This is used to qualify that a function or class is part of |
| 94 |
* the public ICU C++ API namespace. |
| 95 |
* |
| 96 |
* This macro is unnecessary since ICU 49 requires namespace support. |
| 97 |
* You can just use "icu::" instead. |
| 98 |
* @stable ICU 2.4 |
| 99 |
*/ |
| 100 |
|
| 101 |
# if U_DISABLE_RENAMING |
| 102 |
# define U_ICU_NAMESPACE icu |
| 103 |
namespace U_ICU_NAMESPACE { } |
| 104 |
# else |
| 105 |
# define U_ICU_NAMESPACE U_ICU_ENTRY_POINT_RENAME(icu) |
| 106 |
namespace U_ICU_NAMESPACE { } |
| 107 |
namespace icu = U_ICU_NAMESPACE; |
| 108 |
# endif |
| 109 |
|
| 110 |
# define U_NAMESPACE_BEGIN namespace U_ICU_NAMESPACE { |
| 111 |
# define U_NAMESPACE_END } |
| 112 |
# define U_NAMESPACE_USE using namespace U_ICU_NAMESPACE; |
| 113 |
# define U_NAMESPACE_QUALIFIER U_ICU_NAMESPACE:: |
| 114 |
|
| 115 |
# ifndef U_USING_ICU_NAMESPACE |
| 116 |
# if defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \ |
| 117 |
defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) || \ |
| 118 |
defined(U_LAYOUTEX_IMPLEMENTATION) || defined(U_TOOLUTIL_IMPLEMENTATION) |
| 119 |
# define U_USING_ICU_NAMESPACE 0 |
| 120 |
# else |
| 121 |
# define U_USING_ICU_NAMESPACE 0 |
| 122 |
# endif |
| 123 |
# endif |
| 124 |
# if U_USING_ICU_NAMESPACE |
| 125 |
U_NAMESPACE_USE |
| 126 |
# endif |
| 127 |
|
| 128 |
#ifndef U_FORCE_HIDE_DRAFT_API |
| 129 |
/** |
| 130 |
* \def U_HEADER_NESTED_NAMESPACE |
| 131 |
* Nested namespace used inside U_ICU_NAMESPACE for header-only APIs. |
| 132 |
* Different when used inside ICU to prevent public use of internal instantiations: |
| 133 |
* "header" when compiling calling code; "internal" when compiling ICU library code. |
| 134 |
* |
| 135 |
* When compiling for Windows, where DLL exports of APIs are explicit, |
| 136 |
* this is always "header". Header-only types are not marked for export, |
| 137 |
* which on Windows already avoids callers linking with library instantiations. |
| 138 |
* |
| 139 |
* @draft ICU 76 |
| 140 |
* @see U_HEADER_ONLY_NAMESPACE |
| 141 |
*/ |
| 142 |
|
| 143 |
/** |
| 144 |
* \def U_HEADER_ONLY_NAMESPACE |
| 145 |
* Namespace used for header-only APIs. |
| 146 |
* Different when used inside ICU to prevent public use of internal instantiations. |
| 147 |
* "U_ICU_NAMESPACE::header" or "U_ICU_NAMESPACE::internal", |
| 148 |
* see U_HEADER_NESTED_NAMESPACE for details. |
| 149 |
* |
| 150 |
* @draft ICU 76 |
| 151 |
*/ |
| 152 |
|
| 153 |
/** |
| 154 |
* \def U_ICU_NAMESPACE_OR_INTERNAL |
| 155 |
* Namespace used for header-only APIs that used to be regular C++ APIs. |
| 156 |
* Different when used inside ICU to prevent public use of internal instantiations. |
| 157 |
* Similar to U_HEADER_ONLY_NAMESPACE, but the public definition is the same as U_ICU_NAMESPACE. |
| 158 |
* "U_ICU_NAMESPACE" or "U_ICU_NAMESPACE::internal". |
| 159 |
* |
| 160 |
* @draft ICU 77 |
| 161 |
*/ |
| 162 |
|
| 163 |
// The first test is the same as for defining U_EXPORT for Windows. |
| 164 |
#if defined(_MSC_VER) || (UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllexport__) && \ |
| 165 |
UPRV_HAS_DECLSPEC_ATTRIBUTE(__dllimport__)) |
| 166 |
# define U_HEADER_NESTED_NAMESPACE header |
| 167 |
# define U_ICU_NAMESPACE_OR_INTERNAL U_ICU_NAMESPACE |
| 168 |
#elif defined(U_COMBINED_IMPLEMENTATION) || defined(U_COMMON_IMPLEMENTATION) || \ |
| 169 |
defined(U_I18N_IMPLEMENTATION) || defined(U_IO_IMPLEMENTATION) || \ |
| 170 |
defined(U_LAYOUTEX_IMPLEMENTATION) || defined(U_TOOLUTIL_IMPLEMENTATION) |
| 171 |
# define U_HEADER_NESTED_NAMESPACE internal |
| 172 |
# define U_ICU_NAMESPACE_OR_INTERNAL U_ICU_NAMESPACE::internal |
| 173 |
namespace U_ICU_NAMESPACE_OR_INTERNAL {} |
| 174 |
using namespace U_ICU_NAMESPACE_OR_INTERNAL; |
| 175 |
#else |
| 176 |
# define U_HEADER_NESTED_NAMESPACE header |
| 177 |
# define U_ICU_NAMESPACE_OR_INTERNAL U_ICU_NAMESPACE |
| 178 |
#endif |
| 179 |
|
| 180 |
#define U_HEADER_ONLY_NAMESPACE U_ICU_NAMESPACE::U_HEADER_NESTED_NAMESPACE |
| 181 |
|
| 182 |
namespace U_HEADER_ONLY_NAMESPACE {} |
| 183 |
#endif // U_FORCE_HIDE_DRAFT_API |
| 184 |
|
| 185 |
#endif /* __cplusplus */ |
| 186 |
|
| 187 |
/*===========================================================================*/ |
| 188 |
/* General version helper functions. Definitions in putil.c */ |
| 189 |
/*===========================================================================*/ |
| 190 |
|
| 191 |
/** |
| 192 |
* Parse a string with dotted-decimal version information and |
| 193 |
* fill in a UVersionInfo structure with the result. |
| 194 |
* Definition of this function lives in putil.c |
| 195 |
* |
| 196 |
* @param versionArray The destination structure for the version information. |
| 197 |
* @param versionString A string with dotted-decimal version information, |
| 198 |
* with up to four non-negative number fields with |
| 199 |
* values of up to 255 each. |
| 200 |
* @stable ICU 2.4 |
| 201 |
*/ |
| 202 |
U_CAPI void U_EXPORT2 |
| 203 |
u_versionFromString(UVersionInfo versionArray, const char *versionString); |
| 204 |
|
| 205 |
/** |
| 206 |
* Parse a Unicode string with dotted-decimal version information and |
| 207 |
* fill in a UVersionInfo structure with the result. |
| 208 |
* Definition of this function lives in putil.c |
| 209 |
* |
| 210 |
* @param versionArray The destination structure for the version information. |
| 211 |
* @param versionString A Unicode string with dotted-decimal version |
| 212 |
* information, with up to four non-negative number |
| 213 |
* fields with values of up to 255 each. |
| 214 |
* @stable ICU 4.2 |
| 215 |
*/ |
| 216 |
U_CAPI void U_EXPORT2 |
| 217 |
u_versionFromUString(UVersionInfo versionArray, const UChar *versionString); |
| 218 |
|
| 219 |
|
| 220 |
/** |
| 221 |
* Write a string with dotted-decimal version information according |
| 222 |
* to the input UVersionInfo. |
| 223 |
* Definition of this function lives in putil.c |
| 224 |
* |
| 225 |
* @param versionArray The version information to be written as a string. |
| 226 |
* @param versionString A string buffer that will be filled in with |
| 227 |
* a string corresponding to the numeric version |
| 228 |
* information in versionArray. |
| 229 |
* The buffer size must be at least U_MAX_VERSION_STRING_LENGTH. |
| 230 |
* @stable ICU 2.4 |
| 231 |
*/ |
| 232 |
U_CAPI void U_EXPORT2 |
| 233 |
u_versionToString(const UVersionInfo versionArray, char *versionString); |
| 234 |
|
| 235 |
/** |
| 236 |
* Gets the ICU release version. The version array stores the version information |
| 237 |
* for ICU. For example, release "1.3.31.2" is then represented as 0x01031F02. |
| 238 |
* Definition of this function lives in putil.c |
| 239 |
* |
| 240 |
* @param versionArray the version # information, the result will be filled in |
| 241 |
* @stable ICU 2.0 |
| 242 |
*/ |
| 243 |
U_CAPI void U_EXPORT2 |
| 244 |
u_getVersion(UVersionInfo versionArray); |
| 245 |
#endif |