| 1 |
. |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
#ifndef __UNISETSPAN_H__ |
| 20 |
#define __UNISETSPAN_H__ |
| 21 |
|
| 22 |
#include "unicode/utypes.h" |
| 23 |
#include "unicode/uniset.h" |
| 24 |
|
| 25 |
U_NAMESPACE_BEGIN |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class UnicodeSetStringSpan : public UMemory { |
| 33 |
public: |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
enum { |
| 40 |
FWD = 0x20, |
| 41 |
BACK = 0x10, |
| 42 |
UTF16 = 8, |
| 43 |
UTF8 = 4, |
| 44 |
CONTAINED = 2, |
| 45 |
NOT_CONTAINED = 1, |
| 46 |
|
| 47 |
ALL = 0x3f, |
| 48 |
|
| 49 |
FWD_UTF16_CONTAINED = FWD | UTF16 | CONTAINED, |
| 50 |
FWD_UTF16_NOT_CONTAINED = FWD | UTF16 | NOT_CONTAINED, |
| 51 |
FWD_UTF8_CONTAINED = FWD | UTF8 | CONTAINED, |
| 52 |
FWD_UTF8_NOT_CONTAINED = FWD | UTF8 | NOT_CONTAINED, |
| 53 |
BACK_UTF16_CONTAINED = BACK | UTF16 | CONTAINED, |
| 54 |
BACK_UTF16_NOT_CONTAINED= BACK | UTF16 | NOT_CONTAINED, |
| 55 |
BACK_UTF8_CONTAINED = BACK | UTF8 | CONTAINED, |
| 56 |
BACK_UTF8_NOT_CONTAINED = BACK | UTF8 | NOT_CONTAINED |
| 57 |
}; |
| 58 |
|
| 59 |
UnicodeSetStringSpan(const UnicodeSet &set, const UVector &setStrings, uint32_t which); |
| 60 |
|
| 61 |
|
| 62 |
UnicodeSetStringSpan(const UnicodeSetStringSpan &otherStringSpan, const UVector &newParentSetStrings); |
| 63 |
|
| 64 |
~UnicodeSetStringSpan(); |
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
inline UBool needsStringSpanUTF16(); |
| 72 |
inline UBool needsStringSpanUTF8(); |
| 73 |
|
| 74 |
|
| 75 |
inline UBool contains(UChar32 c) const; |
| 76 |
|
| 77 |
int32_t span(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const; |
| 78 |
|
| 79 |
int32_t spanBack(const char16_t *s, int32_t length, USetSpanCondition spanCondition) const; |
| 80 |
|
| 81 |
int32_t spanUTF8(const uint8_t *s, int32_t length, USetSpanCondition spanCondition) const; |
| 82 |
|
| 83 |
int32_t spanBackUTF8(const uint8_t *s, int32_t length, USetSpanCondition spanCondition) const; |
| 84 |
|
| 85 |
private: |
| 86 |
|
| 87 |
enum { |
| 88 |
|
| 89 |
LONG_SPAN=0xfe, |
| 90 |
|
| 91 |
ALL_CP_CONTAINED=0xff |
| 92 |
}; |
| 93 |
|
| 94 |
|
| 95 |
|
| 96 |
void addToSpanNotSet(UChar32 c); |
| 97 |
|
| 98 |
int32_t spanNot(const char16_t *s, int32_t length) const; |
| 99 |
int32_t spanNotBack(const char16_t *s, int32_t length) const; |
| 100 |
int32_t spanNotUTF8(const uint8_t *s, int32_t length) const; |
| 101 |
int32_t spanNotBackUTF8(const uint8_t *s, int32_t length) const; |
| 102 |
|
| 103 |
|
| 104 |
UnicodeSet spanSet; |
| 105 |
|
| 106 |
|
| 107 |
|
| 108 |
UnicodeSet *pSpanNotSet; |
| 109 |
|
| 110 |
|
| 111 |
const UVector &strings; |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
int32_t *utf8Lengths; |
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
uint8_t *spanLengths; |
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
uint8_t *utf8; |
| 125 |
|
| 126 |
|
| 127 |
int32_t utf8Length; |
| 128 |
|
| 129 |
|
| 130 |
int32_t maxLength16; |
| 131 |
int32_t maxLength8; |
| 132 |
|
| 133 |
|
| 134 |
UBool all; |
| 135 |
|
| 136 |
|
| 137 |
|
| 138 |
|
| 139 |
|
| 140 |
int32_t staticLengths[32]; |
| 141 |
}; |
| 142 |
|
| 143 |
UBool UnicodeSetStringSpan::needsStringSpanUTF16() { |
| 144 |
return maxLength16 != 0; |
| 145 |
} |
| 146 |
|
| 147 |
UBool UnicodeSetStringSpan::needsStringSpanUTF8() { |
| 148 |
return maxLength8 != 0; |
| 149 |
} |
| 150 |
|
| 151 |
UBool UnicodeSetStringSpan::contains(UChar32 c) const { |
| 152 |
return spanSet.contains(c); |
| 153 |
} |
| 154 |
|
| 155 |
U_NAMESPACE_END |
| 156 |
|
| 157 |
#endif |