annotate modules/javafx.web/src/main/native/Source/ThirdParty/icu/source/common/bmpset.h @ 10550:fee4ef5c87df

8178360: Build and integrate ICU from source Reviewed-by: kcr, arajkumar
author ghb
date Tue, 04 Jul 2017 09:09:49 +0530
parents
children 20a8447c71c6
rev   line source
ghb@10550 1 /*
ghb@10550 2 ******************************************************************************
ghb@10550 3 *
ghb@10550 4 * Copyright (C) 2007, International Business Machines
ghb@10550 5 * Corporation and others. All Rights Reserved.
ghb@10550 6 *
ghb@10550 7 ******************************************************************************
ghb@10550 8 * file name: bmpset.h
ghb@10550 9 * encoding: US-ASCII
ghb@10550 10 * tab size: 8 (not used)
ghb@10550 11 * indentation:4
ghb@10550 12 *
ghb@10550 13 * created on: 2007jan29
ghb@10550 14 * created by: Markus W. Scherer
ghb@10550 15 */
ghb@10550 16
ghb@10550 17 #ifndef __BMPSET_H__
ghb@10550 18 #define __BMPSET_H__
ghb@10550 19
ghb@10550 20 #include "unicode/utypes.h"
ghb@10550 21 #include "unicode/uniset.h"
ghb@10550 22
ghb@10550 23 U_NAMESPACE_BEGIN
ghb@10550 24
ghb@10550 25 /*
ghb@10550 26 * Helper class for frozen UnicodeSets, implements contains() and span()
ghb@10550 27 * optimized for BMP code points. Structured to be UTF-8-friendly.
ghb@10550 28 *
ghb@10550 29 * ASCII: Look up bytes.
ghb@10550 30 * 2-byte characters: Bits organized vertically.
ghb@10550 31 * 3-byte characters: Use zero/one/mixed data per 64-block in U+0000..U+FFFF,
ghb@10550 32 * with mixed for illegal ranges.
ghb@10550 33 * Supplementary characters: Call contains() on the parent set.
ghb@10550 34 */
ghb@10550 35 class BMPSet : public UMemory {
ghb@10550 36 public:
ghb@10550 37 BMPSet(const int32_t *parentList, int32_t parentListLength);
ghb@10550 38 BMPSet(const BMPSet &otherBMPSet, const int32_t *newParentList, int32_t newParentListLength);
ghb@10550 39 virtual ~BMPSet();
ghb@10550 40
ghb@10550 41 virtual UBool contains(UChar32 c) const;
ghb@10550 42
ghb@10550 43 /*
ghb@10550 44 * Span the initial substring for which each character c has spanCondition==contains(c).
ghb@10550 45 * It must be s<limit and spanCondition==0 or 1.
ghb@10550 46 * @return The string pointer which limits the span.
ghb@10550 47 */
ghb@10550 48 const UChar *span(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const;
ghb@10550 49
ghb@10550 50 /*
ghb@10550 51 * Span the trailing substring for which each character c has spanCondition==contains(c).
ghb@10550 52 * It must be s<limit and spanCondition==0 or 1.
ghb@10550 53 * @return The string pointer which starts the span.
ghb@10550 54 */
ghb@10550 55 const UChar *spanBack(const UChar *s, const UChar *limit, USetSpanCondition spanCondition) const;
ghb@10550 56
ghb@10550 57 /*
ghb@10550 58 * Span the initial substring for which each character c has spanCondition==contains(c).
ghb@10550 59 * It must be length>0 and spanCondition==0 or 1.
ghb@10550 60 * @return The string pointer which limits the span.
ghb@10550 61 */
ghb@10550 62 const uint8_t *spanUTF8(const uint8_t *s, int32_t length, USetSpanCondition spanCondition) const;
ghb@10550 63
ghb@10550 64 /*
ghb@10550 65 * Span the trailing substring for which each character c has spanCondition==contains(c).
ghb@10550 66 * It must be length>0 and spanCondition==0 or 1.
ghb@10550 67 * @return The start of the span.
ghb@10550 68 */
ghb@10550 69 int32_t spanBackUTF8(const uint8_t *s, int32_t length, USetSpanCondition spanCondition) const;
ghb@10550 70
ghb@10550 71 private:
ghb@10550 72 void initBits();
ghb@10550 73 void overrideIllegal();
ghb@10550 74
ghb@10550 75 /**
ghb@10550 76 * Same as UnicodeSet::findCodePoint(UChar32 c) const except that the
ghb@10550 77 * binary search is restricted for finding code points in a certain range.
ghb@10550 78 *
ghb@10550 79 * For restricting the search for finding in the range start..end,
ghb@10550 80 * pass in
ghb@10550 81 * lo=findCodePoint(start) and
ghb@10550 82 * hi=findCodePoint(end)
ghb@10550 83 * with 0<=lo<=hi<len.
ghb@10550 84 * findCodePoint(c) defaults to lo=0 and hi=len-1.
ghb@10550 85 *
ghb@10550 86 * @param c a character in a subrange of MIN_VALUE..MAX_VALUE
ghb@10550 87 * @param lo The lowest index to be returned.
ghb@10550 88 * @param hi The highest index to be returned.
ghb@10550 89 * @return the smallest integer i in the range lo..hi,
ghb@10550 90 * inclusive, such that c < list[i]
ghb@10550 91 */
ghb@10550 92 int32_t findCodePoint(UChar32 c, int32_t lo, int32_t hi) const;
ghb@10550 93
ghb@10550 94 inline UBool containsSlow(UChar32 c, int32_t lo, int32_t hi) const;
ghb@10550 95
ghb@10550 96 /*
ghb@10550 97 * One byte per ASCII character, or trail byte in lead position.
ghb@10550 98 * 0 or 1 for ASCII characters.
ghb@10550 99 * The value for trail bytes is the result of contains(FFFD)
ghb@10550 100 * for faster validity checking at runtime.
ghb@10550 101 */
ghb@10550 102 UBool asciiBytes[0xc0];
ghb@10550 103
ghb@10550 104 /*
ghb@10550 105 * One bit per code point from U+0000..U+07FF.
ghb@10550 106 * The bits are organized vertically; consecutive code points
ghb@10550 107 * correspond to the same bit positions in consecutive table words.
ghb@10550 108 * With code point parts
ghb@10550 109 * lead=c{10..6}
ghb@10550 110 * trail=c{5..0}
ghb@10550 111 * it is set.contains(c)==(table7FF[trail] bit lead)
ghb@10550 112 *
ghb@10550 113 * Bits for 0..7F (non-shortest forms) are set to the result of contains(FFFD)
ghb@10550 114 * for faster validity checking at runtime.
ghb@10550 115 */
ghb@10550 116 uint32_t table7FF[64];
ghb@10550 117
ghb@10550 118 /*
ghb@10550 119 * One bit per 64 BMP code points.
ghb@10550 120 * The bits are organized vertically; consecutive 64-code point blocks
ghb@10550 121 * correspond to the same bit position in consecutive table words.
ghb@10550 122 * With code point parts
ghb@10550 123 * lead=c{15..12}
ghb@10550 124 * t1=c{11..6}
ghb@10550 125 * test bits (lead+16) and lead in bmpBlockBits[t1].
ghb@10550 126 * If the upper bit is 0, then the lower bit indicates if contains(c)
ghb@10550 127 * for all code points in the 64-block.
ghb@10550 128 * If the upper bit is 1, then the block is mixed and set.contains(c)
ghb@10550 129 * must be called.
ghb@10550 130 *
ghb@10550 131 * Bits for 0..7FF (non-shortest forms) and D800..DFFF are set to
ghb@10550 132 * the result of contains(FFFD) for faster validity checking at runtime.
ghb@10550 133 */
ghb@10550 134 uint32_t bmpBlockBits[64];
ghb@10550 135
ghb@10550 136 /*
ghb@10550 137 * Inversion list indexes for restricted binary searches in
ghb@10550 138 * findCodePoint(), from
ghb@10550 139 * findCodePoint(U+0800, U+1000, U+2000, .., U+F000, U+10000).
ghb@10550 140 * U+0800 is the first 3-byte-UTF-8 code point. Code points below U+0800 are
ghb@10550 141 * always looked up in the bit tables.
ghb@10550 142 * The last pair of indexes is for finding supplementary code points.
ghb@10550 143 */
ghb@10550 144 int32_t list4kStarts[18];
ghb@10550 145
ghb@10550 146 /*
ghb@10550 147 * The inversion list of the parent set, for the slower contains() implementation
ghb@10550 148 * for mixed BMP blocks and for supplementary code points.
ghb@10550 149 * The list is terminated with list[listLength-1]=0x110000.
ghb@10550 150 */
ghb@10550 151 const int32_t *list;
ghb@10550 152 int32_t listLength;
ghb@10550 153 };
ghb@10550 154
ghb@10550 155 inline UBool BMPSet::containsSlow(UChar32 c, int32_t lo, int32_t hi) const {
ghb@10550 156 return (UBool)(findCodePoint(c, lo, hi) & 1);
ghb@10550 157 }
ghb@10550 158
ghb@10550 159 U_NAMESPACE_END
ghb@10550 160
ghb@10550 161 #endif