intl/icu/source/common/uprops.h

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 *******************************************************************************
michael@0 3 *
michael@0 4 * Copyright (C) 2002-2012, International Business Machines
michael@0 5 * Corporation and others. All Rights Reserved.
michael@0 6 *
michael@0 7 *******************************************************************************
michael@0 8 * file name: uprops.h
michael@0 9 * encoding: US-ASCII
michael@0 10 * tab size: 8 (not used)
michael@0 11 * indentation:4
michael@0 12 *
michael@0 13 * created on: 2002feb24
michael@0 14 * created by: Markus W. Scherer
michael@0 15 *
michael@0 16 * Constants for mostly non-core Unicode character properties
michael@0 17 * stored in uprops.icu.
michael@0 18 */
michael@0 19
michael@0 20 #ifndef __UPROPS_H__
michael@0 21 #define __UPROPS_H__
michael@0 22
michael@0 23 #include "unicode/utypes.h"
michael@0 24 #include "unicode/uset.h"
michael@0 25 #include "uset_imp.h"
michael@0 26 #include "udataswp.h"
michael@0 27
michael@0 28 /* indexes[] entries */
michael@0 29 enum {
michael@0 30 UPROPS_PROPS32_INDEX,
michael@0 31 UPROPS_EXCEPTIONS_INDEX,
michael@0 32 UPROPS_EXCEPTIONS_TOP_INDEX,
michael@0 33
michael@0 34 UPROPS_ADDITIONAL_TRIE_INDEX,
michael@0 35 UPROPS_ADDITIONAL_VECTORS_INDEX,
michael@0 36 UPROPS_ADDITIONAL_VECTORS_COLUMNS_INDEX,
michael@0 37
michael@0 38 UPROPS_SCRIPT_EXTENSIONS_INDEX,
michael@0 39
michael@0 40 UPROPS_RESERVED_INDEX_7,
michael@0 41 UPROPS_RESERVED_INDEX_8,
michael@0 42
michael@0 43 /* size of the data file (number of 32-bit units after the header) */
michael@0 44 UPROPS_DATA_TOP_INDEX,
michael@0 45
michael@0 46 /* maximum values for code values in vector word 0 */
michael@0 47 UPROPS_MAX_VALUES_INDEX=10,
michael@0 48 /* maximum values for code values in vector word 2 */
michael@0 49 UPROPS_MAX_VALUES_2_INDEX,
michael@0 50
michael@0 51 UPROPS_INDEX_COUNT=16
michael@0 52 };
michael@0 53
michael@0 54 /* definitions for the main properties words */
michael@0 55 enum {
michael@0 56 /* general category shift==0 0 (5 bits) */
michael@0 57 /* reserved 5 (1 bit) */
michael@0 58 UPROPS_NUMERIC_TYPE_VALUE_SHIFT=6 /* 6 (10 bits) */
michael@0 59 };
michael@0 60
michael@0 61 #define GET_CATEGORY(props) ((props)&0x1f)
michael@0 62 #define CAT_MASK(props) U_MASK(GET_CATEGORY(props))
michael@0 63
michael@0 64 #define GET_NUMERIC_TYPE_VALUE(props) ((props)>>UPROPS_NUMERIC_TYPE_VALUE_SHIFT)
michael@0 65
michael@0 66 /* constants for the storage form of numeric types and values */
michael@0 67 enum {
michael@0 68 /** No numeric value. */
michael@0 69 UPROPS_NTV_NONE=0,
michael@0 70 /** Decimal digits: nv=0..9 */
michael@0 71 UPROPS_NTV_DECIMAL_START=1,
michael@0 72 /** Other digits: nv=0..9 */
michael@0 73 UPROPS_NTV_DIGIT_START=11,
michael@0 74 /** Small integers: nv=0..154 */
michael@0 75 UPROPS_NTV_NUMERIC_START=21,
michael@0 76 /** Fractions: ((ntv>>4)-12) / ((ntv&0xf)+1) = -1..17 / 1..16 */
michael@0 77 UPROPS_NTV_FRACTION_START=0xb0,
michael@0 78 /**
michael@0 79 * Large integers:
michael@0 80 * ((ntv>>5)-14) * 10^((ntv&0x1f)+2) = (1..9)*(10^2..10^33)
michael@0 81 * (only one significant decimal digit)
michael@0 82 */
michael@0 83 UPROPS_NTV_LARGE_START=0x1e0,
michael@0 84 /**
michael@0 85 * Sexagesimal numbers:
michael@0 86 * ((ntv>>2)-0xbf) * 60^((ntv&3)+1) = (1..9)*(60^1..60^4)
michael@0 87 */
michael@0 88 UPROPS_NTV_BASE60_START=0x300,
michael@0 89 /** No numeric value (yet). */
michael@0 90 UPROPS_NTV_RESERVED_START=UPROPS_NTV_BASE60_START+36, /* 0x300+9*4=0x324 */
michael@0 91
michael@0 92 UPROPS_NTV_MAX_SMALL_INT=UPROPS_NTV_FRACTION_START-UPROPS_NTV_NUMERIC_START-1
michael@0 93 };
michael@0 94
michael@0 95 #define UPROPS_NTV_GET_TYPE(ntv) \
michael@0 96 ((ntv==UPROPS_NTV_NONE) ? U_NT_NONE : \
michael@0 97 (ntv<UPROPS_NTV_DIGIT_START) ? U_NT_DECIMAL : \
michael@0 98 (ntv<UPROPS_NTV_NUMERIC_START) ? U_NT_DIGIT : \
michael@0 99 U_NT_NUMERIC)
michael@0 100
michael@0 101 /* number of properties vector words */
michael@0 102 #define UPROPS_VECTOR_WORDS 3
michael@0 103
michael@0 104 /*
michael@0 105 * Properties in vector word 0
michael@0 106 * Bits
michael@0 107 * 31..24 DerivedAge version major/minor one nibble each
michael@0 108 * 23..22 3..1: Bits 7..0 = Script_Extensions index
michael@0 109 * 3: Script value from Script_Extensions
michael@0 110 * 2: Script=Inherited
michael@0 111 * 1: Script=Common
michael@0 112 * 0: Script=bits 7..0
michael@0 113 * 21..20 reserved
michael@0 114 * 19..17 East Asian Width
michael@0 115 * 16.. 8 UBlockCode
michael@0 116 * 7.. 0 UScriptCode, or index to Script_Extensions
michael@0 117 */
michael@0 118
michael@0 119 /* derived age: one nibble each for major and minor version numbers */
michael@0 120 #define UPROPS_AGE_MASK 0xff000000
michael@0 121 #define UPROPS_AGE_SHIFT 24
michael@0 122
michael@0 123 /* Script_Extensions: mask includes Script */
michael@0 124 #define UPROPS_SCRIPT_X_MASK 0x00c000ff
michael@0 125 #define UPROPS_SCRIPT_X_SHIFT 22
michael@0 126
michael@0 127 #define UPROPS_EA_MASK 0x000e0000
michael@0 128 #define UPROPS_EA_SHIFT 17
michael@0 129
michael@0 130 #define UPROPS_BLOCK_MASK 0x0001ff00
michael@0 131 #define UPROPS_BLOCK_SHIFT 8
michael@0 132
michael@0 133 #define UPROPS_SCRIPT_MASK 0x000000ff
michael@0 134
michael@0 135 /* UPROPS_SCRIPT_X_WITH_COMMON must be the lowest value that involves Script_Extensions. */
michael@0 136 #define UPROPS_SCRIPT_X_WITH_COMMON 0x400000
michael@0 137 #define UPROPS_SCRIPT_X_WITH_INHERITED 0x800000
michael@0 138 #define UPROPS_SCRIPT_X_WITH_OTHER 0xc00000
michael@0 139
michael@0 140 /*
michael@0 141 * Properties in vector word 1
michael@0 142 * Each bit encodes one binary property.
michael@0 143 * The following constants represent the bit number, use 1<<UPROPS_XYZ.
michael@0 144 * UPROPS_BINARY_1_TOP<=32!
michael@0 145 *
michael@0 146 * Keep this list of property enums in sync with
michael@0 147 * propListNames[] in icu/source/tools/genprops/props2.c!
michael@0 148 *
michael@0 149 * ICU 2.6/uprops format version 3.2 stores full properties instead of "Other_".
michael@0 150 */
michael@0 151 enum {
michael@0 152 UPROPS_WHITE_SPACE,
michael@0 153 UPROPS_DASH,
michael@0 154 UPROPS_HYPHEN,
michael@0 155 UPROPS_QUOTATION_MARK,
michael@0 156 UPROPS_TERMINAL_PUNCTUATION,
michael@0 157 UPROPS_MATH,
michael@0 158 UPROPS_HEX_DIGIT,
michael@0 159 UPROPS_ASCII_HEX_DIGIT,
michael@0 160 UPROPS_ALPHABETIC,
michael@0 161 UPROPS_IDEOGRAPHIC,
michael@0 162 UPROPS_DIACRITIC,
michael@0 163 UPROPS_EXTENDER,
michael@0 164 UPROPS_NONCHARACTER_CODE_POINT,
michael@0 165 UPROPS_GRAPHEME_EXTEND,
michael@0 166 UPROPS_GRAPHEME_LINK,
michael@0 167 UPROPS_IDS_BINARY_OPERATOR,
michael@0 168 UPROPS_IDS_TRINARY_OPERATOR,
michael@0 169 UPROPS_RADICAL,
michael@0 170 UPROPS_UNIFIED_IDEOGRAPH,
michael@0 171 UPROPS_DEFAULT_IGNORABLE_CODE_POINT,
michael@0 172 UPROPS_DEPRECATED,
michael@0 173 UPROPS_LOGICAL_ORDER_EXCEPTION,
michael@0 174 UPROPS_XID_START,
michael@0 175 UPROPS_XID_CONTINUE,
michael@0 176 UPROPS_ID_START, /* ICU 2.6, uprops format version 3.2 */
michael@0 177 UPROPS_ID_CONTINUE,
michael@0 178 UPROPS_GRAPHEME_BASE,
michael@0 179 UPROPS_S_TERM, /* new in ICU 3.0 and Unicode 4.0.1 */
michael@0 180 UPROPS_VARIATION_SELECTOR,
michael@0 181 UPROPS_PATTERN_SYNTAX, /* new in ICU 3.4 and Unicode 4.1 */
michael@0 182 UPROPS_PATTERN_WHITE_SPACE,
michael@0 183 UPROPS_RESERVED, /* reserved & unused */
michael@0 184 UPROPS_BINARY_1_TOP /* ==32 - full! */
michael@0 185 };
michael@0 186
michael@0 187 /*
michael@0 188 * Properties in vector word 2
michael@0 189 * Bits
michael@0 190 * 31..26 reserved
michael@0 191 * 25..20 Line Break
michael@0 192 * 19..15 Sentence Break
michael@0 193 * 14..10 Word Break
michael@0 194 * 9.. 5 Grapheme Cluster Break
michael@0 195 * 4.. 0 Decomposition Type
michael@0 196 */
michael@0 197 #define UPROPS_LB_MASK 0x03f00000
michael@0 198 #define UPROPS_LB_SHIFT 20
michael@0 199
michael@0 200 #define UPROPS_SB_MASK 0x000f8000
michael@0 201 #define UPROPS_SB_SHIFT 15
michael@0 202
michael@0 203 #define UPROPS_WB_MASK 0x00007c00
michael@0 204 #define UPROPS_WB_SHIFT 10
michael@0 205
michael@0 206 #define UPROPS_GCB_MASK 0x000003e0
michael@0 207 #define UPROPS_GCB_SHIFT 5
michael@0 208
michael@0 209 #define UPROPS_DT_MASK 0x0000001f
michael@0 210
michael@0 211 /**
michael@0 212 * Gets the main properties value for a code point.
michael@0 213 * Implemented in uchar.c for uprops.cpp.
michael@0 214 */
michael@0 215 U_CFUNC uint32_t
michael@0 216 u_getMainProperties(UChar32 c);
michael@0 217
michael@0 218 /**
michael@0 219 * Get a properties vector word for a code point.
michael@0 220 * Implemented in uchar.c for uprops.cpp.
michael@0 221 * @return 0 if no data or illegal argument
michael@0 222 */
michael@0 223 U_CFUNC uint32_t
michael@0 224 u_getUnicodeProperties(UChar32 c, int32_t column);
michael@0 225
michael@0 226 /**
michael@0 227 * Get the the maximum values for some enum/int properties.
michael@0 228 * Use the same column numbers as for u_getUnicodeProperties().
michael@0 229 * The returned value will contain maximum values stored in the same bit fields
michael@0 230 * as where the enum values are stored in the u_getUnicodeProperties()
michael@0 231 * return values for the same columns.
michael@0 232 *
michael@0 233 * Valid columns are those for properties words that contain enumerated values.
michael@0 234 * (ICU 2.6: columns 0 and 2)
michael@0 235 * For other column numbers, this function will return 0.
michael@0 236 *
michael@0 237 * @internal
michael@0 238 */
michael@0 239 U_CFUNC int32_t
michael@0 240 uprv_getMaxValues(int32_t column);
michael@0 241
michael@0 242 /**
michael@0 243 * Checks if c is alphabetic, or a decimal digit; implements UCHAR_POSIX_ALNUM.
michael@0 244 * @internal
michael@0 245 */
michael@0 246 U_CFUNC UBool
michael@0 247 u_isalnumPOSIX(UChar32 c);
michael@0 248
michael@0 249 /**
michael@0 250 * Checks if c is in
michael@0 251 * [^\p{space}\p{gc=Control}\p{gc=Surrogate}\p{gc=Unassigned}]
michael@0 252 * with space=\p{Whitespace} and Control=Cc.
michael@0 253 * Implements UCHAR_POSIX_GRAPH.
michael@0 254 * @internal
michael@0 255 */
michael@0 256 U_CFUNC UBool
michael@0 257 u_isgraphPOSIX(UChar32 c);
michael@0 258
michael@0 259 /**
michael@0 260 * Checks if c is in \p{graph}\p{blank} - \p{cntrl}.
michael@0 261 * Implements UCHAR_POSIX_PRINT.
michael@0 262 * @internal
michael@0 263 */
michael@0 264 U_CFUNC UBool
michael@0 265 u_isprintPOSIX(UChar32 c);
michael@0 266
michael@0 267 /** Turn a bit index into a bit flag. @internal */
michael@0 268 #define FLAG(n) ((uint32_t)1<<(n))
michael@0 269
michael@0 270 /** Flags for general categories in the order of UCharCategory. @internal */
michael@0 271 #define _Cn FLAG(U_GENERAL_OTHER_TYPES)
michael@0 272 #define _Lu FLAG(U_UPPERCASE_LETTER)
michael@0 273 #define _Ll FLAG(U_LOWERCASE_LETTER)
michael@0 274 #define _Lt FLAG(U_TITLECASE_LETTER)
michael@0 275 #define _Lm FLAG(U_MODIFIER_LETTER)
michael@0 276 /* #define _Lo FLAG(U_OTHER_LETTER) -- conflicts with MS Visual Studio 9.0 xiosbase */
michael@0 277 #define _Mn FLAG(U_NON_SPACING_MARK)
michael@0 278 #define _Me FLAG(U_ENCLOSING_MARK)
michael@0 279 #define _Mc FLAG(U_COMBINING_SPACING_MARK)
michael@0 280 #define _Nd FLAG(U_DECIMAL_DIGIT_NUMBER)
michael@0 281 #define _Nl FLAG(U_LETTER_NUMBER)
michael@0 282 #define _No FLAG(U_OTHER_NUMBER)
michael@0 283 #define _Zs FLAG(U_SPACE_SEPARATOR)
michael@0 284 #define _Zl FLAG(U_LINE_SEPARATOR)
michael@0 285 #define _Zp FLAG(U_PARAGRAPH_SEPARATOR)
michael@0 286 #define _Cc FLAG(U_CONTROL_CHAR)
michael@0 287 #define _Cf FLAG(U_FORMAT_CHAR)
michael@0 288 #define _Co FLAG(U_PRIVATE_USE_CHAR)
michael@0 289 #define _Cs FLAG(U_SURROGATE)
michael@0 290 #define _Pd FLAG(U_DASH_PUNCTUATION)
michael@0 291 #define _Ps FLAG(U_START_PUNCTUATION)
michael@0 292 /* #define _Pe FLAG(U_END_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 xlocnum */
michael@0 293 /* #define _Pc FLAG(U_CONNECTOR_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 streambuf */
michael@0 294 #define _Po FLAG(U_OTHER_PUNCTUATION)
michael@0 295 #define _Sm FLAG(U_MATH_SYMBOL)
michael@0 296 #define _Sc FLAG(U_CURRENCY_SYMBOL)
michael@0 297 #define _Sk FLAG(U_MODIFIER_SYMBOL)
michael@0 298 #define _So FLAG(U_OTHER_SYMBOL)
michael@0 299 #define _Pi FLAG(U_INITIAL_PUNCTUATION)
michael@0 300 /* #define _Pf FLAG(U_FINAL_PUNCTUATION) -- conflicts with MS Visual Studio 9.0 streambuf */
michael@0 301
michael@0 302 /** Some code points. @internal */
michael@0 303 enum {
michael@0 304 TAB =0x0009,
michael@0 305 LF =0x000a,
michael@0 306 FF =0x000c,
michael@0 307 CR =0x000d,
michael@0 308 U_A =0x0041,
michael@0 309 U_F =0x0046,
michael@0 310 U_Z =0x005a,
michael@0 311 U_a =0x0061,
michael@0 312 U_f =0x0066,
michael@0 313 U_z =0x007a,
michael@0 314 DEL =0x007f,
michael@0 315 NL =0x0085,
michael@0 316 NBSP =0x00a0,
michael@0 317 CGJ =0x034f,
michael@0 318 FIGURESP=0x2007,
michael@0 319 HAIRSP =0x200a,
michael@0 320 ZWNJ =0x200c,
michael@0 321 ZWJ =0x200d,
michael@0 322 RLM =0x200f,
michael@0 323 NNBSP =0x202f,
michael@0 324 WJ =0x2060,
michael@0 325 INHSWAP =0x206a,
michael@0 326 NOMDIG =0x206f,
michael@0 327 U_FW_A =0xff21,
michael@0 328 U_FW_F =0xff26,
michael@0 329 U_FW_Z =0xff3a,
michael@0 330 U_FW_a =0xff41,
michael@0 331 U_FW_f =0xff46,
michael@0 332 U_FW_z =0xff5a,
michael@0 333 ZWNBSP =0xfeff
michael@0 334 };
michael@0 335
michael@0 336 /**
michael@0 337 * Get the maximum length of a (regular/1.0/extended) character name.
michael@0 338 * @return 0 if no character names available.
michael@0 339 */
michael@0 340 U_CAPI int32_t U_EXPORT2
michael@0 341 uprv_getMaxCharNameLength(void);
michael@0 342
michael@0 343 /**
michael@0 344 * Fills set with characters that are used in Unicode character names.
michael@0 345 * Includes all characters that are used in regular/Unicode 1.0/extended names.
michael@0 346 * Just empties the set if no character names are available.
michael@0 347 * @param sa USetAdder to receive characters.
michael@0 348 */
michael@0 349 U_CAPI void U_EXPORT2
michael@0 350 uprv_getCharNameCharacters(const USetAdder *sa);
michael@0 351
michael@0 352 /**
michael@0 353 * Constants for which data and implementation files provide which properties.
michael@0 354 * Used by UnicodeSet for service-specific property enumeration.
michael@0 355 * @internal
michael@0 356 */
michael@0 357 enum UPropertySource {
michael@0 358 /** No source, not a supported property. */
michael@0 359 UPROPS_SRC_NONE,
michael@0 360 /** From uchar.c/uprops.icu main trie */
michael@0 361 UPROPS_SRC_CHAR,
michael@0 362 /** From uchar.c/uprops.icu properties vectors trie */
michael@0 363 UPROPS_SRC_PROPSVEC,
michael@0 364 /** From unames.c/unames.icu */
michael@0 365 UPROPS_SRC_NAMES,
michael@0 366 /** From ucase.c/ucase.icu */
michael@0 367 UPROPS_SRC_CASE,
michael@0 368 /** From ubidi_props.c/ubidi.icu */
michael@0 369 UPROPS_SRC_BIDI,
michael@0 370 /** From uchar.c/uprops.icu main trie as well as properties vectors trie */
michael@0 371 UPROPS_SRC_CHAR_AND_PROPSVEC,
michael@0 372 /** From ucase.c/ucase.icu as well as unorm.cpp/unorm.icu */
michael@0 373 UPROPS_SRC_CASE_AND_NORM,
michael@0 374 /** From normalizer2impl.cpp/nfc.nrm */
michael@0 375 UPROPS_SRC_NFC,
michael@0 376 /** From normalizer2impl.cpp/nfkc.nrm */
michael@0 377 UPROPS_SRC_NFKC,
michael@0 378 /** From normalizer2impl.cpp/nfkc_cf.nrm */
michael@0 379 UPROPS_SRC_NFKC_CF,
michael@0 380 /** From normalizer2impl.cpp/nfc.nrm canonical iterator data */
michael@0 381 UPROPS_SRC_NFC_CANON_ITER,
michael@0 382 /** One more than the highest UPropertySource (UPROPS_SRC_) constant. */
michael@0 383 UPROPS_SRC_COUNT
michael@0 384 };
michael@0 385 typedef enum UPropertySource UPropertySource;
michael@0 386
michael@0 387 /**
michael@0 388 * @see UPropertySource
michael@0 389 * @internal
michael@0 390 */
michael@0 391 U_CFUNC UPropertySource U_EXPORT2
michael@0 392 uprops_getSource(UProperty which);
michael@0 393
michael@0 394 /**
michael@0 395 * Enumerate uprops.icu's main data trie and add the
michael@0 396 * start of each range of same properties to the set.
michael@0 397 * @internal
michael@0 398 */
michael@0 399 U_CFUNC void U_EXPORT2
michael@0 400 uchar_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
michael@0 401
michael@0 402 /**
michael@0 403 * Enumerate uprops.icu's properties vectors trie and add the
michael@0 404 * start of each range of same properties to the set.
michael@0 405 * @internal
michael@0 406 */
michael@0 407 U_CFUNC void U_EXPORT2
michael@0 408 upropsvec_addPropertyStarts(const USetAdder *sa, UErrorCode *pErrorCode);
michael@0 409
michael@0 410 /**
michael@0 411 * Return a set of characters for property enumeration.
michael@0 412 * For each two consecutive characters (start, limit) in the set,
michael@0 413 * all of the properties for start..limit-1 are all the same.
michael@0 414 *
michael@0 415 * @param sa USetAdder to receive result. Existing contents are lost.
michael@0 416 * @internal
michael@0 417 */
michael@0 418 /*U_CFUNC void U_EXPORT2
michael@0 419 uprv_getInclusions(const USetAdder *sa, UErrorCode *pErrorCode);
michael@0 420 */
michael@0 421
michael@0 422 /**
michael@0 423 * Swap the ICU Unicode character names file. See uchar.c.
michael@0 424 * @internal
michael@0 425 */
michael@0 426 U_CAPI int32_t U_EXPORT2
michael@0 427 uchar_swapNames(const UDataSwapper *ds,
michael@0 428 const void *inData, int32_t length, void *outData,
michael@0 429 UErrorCode *pErrorCode);
michael@0 430
michael@0 431 #ifdef __cplusplus
michael@0 432
michael@0 433 U_NAMESPACE_BEGIN
michael@0 434
michael@0 435 class UnicodeSet;
michael@0 436
michael@0 437 // implemented in uniset_props.cpp
michael@0 438 U_CFUNC UnicodeSet *
michael@0 439 uniset_getUnicode32Instance(UErrorCode &errorCode);
michael@0 440
michael@0 441 U_NAMESPACE_END
michael@0 442
michael@0 443 #endif
michael@0 444
michael@0 445 #endif

mercurial