00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef UNICODESET_H
00011 #define UNICODESET_H
00012
00013 #include "unicode/unifilt.h"
00014 #include "unicode/utypes.h"
00015 #include "unicode/unistr.h"
00016
00017 U_NAMESPACE_BEGIN
00018
00019 class ParsePosition;
00020 class SymbolTable;
00021 class TransliterationRuleParser;
00022 class TransliterationRule;
00023 class Transliterator;
00024 class TransliteratorParser;
00025
00217 class U_I18N_API UnicodeSet : public UnicodeFilter {
00218
00219 int32_t len;
00220 int32_t capacity;
00221 int32_t bufferCapacity;
00222 UChar32* list;
00223 UChar32* buffer;
00224
00234 UnicodeString pat;
00235
00236 public:
00237
00241 static const UChar32 MIN_VALUE;
00242
00246 static const UChar32 MAX_VALUE;
00247
00248
00249
00250
00251
00252 public:
00253
00258 UnicodeSet();
00259
00267 UnicodeSet(UChar32 start, UChar32 end);
00268
00277 UnicodeSet(const UnicodeString& pattern,
00278 UErrorCode& status);
00279
00286 UnicodeSet(int8_t category, UErrorCode& status);
00287
00292 UnicodeSet(const UnicodeSet& o);
00293
00298 virtual ~UnicodeSet();
00299
00304 UnicodeSet& operator=(const UnicodeSet& o);
00305
00317 virtual UBool operator==(const UnicodeSet& o) const;
00318
00324 UBool operator!=(const UnicodeSet& o) const;
00325
00332 virtual UnicodeFunctor* clone() const;
00333
00341 virtual int32_t hashCode(void) const;
00342
00343
00344
00345
00346
00355 void set(UChar32 start, UChar32 end);
00356
00361 static UBool resemblesPattern(const UnicodeString& pattern,
00362 int32_t pos);
00363
00373 virtual void applyPattern(const UnicodeString& pattern,
00374 UErrorCode& status);
00375
00388 virtual UnicodeString& toPattern(UnicodeString& result,
00389 UBool escapeUnprintable = FALSE) const;
00390
00398 virtual int32_t size(void) const;
00399
00406 virtual UBool isEmpty(void) const;
00407
00416 virtual UBool contains(UChar32 start, UChar32 end) const;
00417
00424 virtual UBool contains(UChar32 c) const;
00425
00429 UMatchDegree matches(const Replaceable& text,
00430 int32_t& offset,
00431 int32_t limit,
00432 UBool incremental);
00433
00441 int32_t indexOf(UChar32 c) const;
00442
00451 UChar32 charAt(int32_t index) const;
00452
00466 virtual void add(UChar32 start, UChar32 end);
00467
00474 void add(UChar32 c);
00475
00488 virtual void retain(UChar32 start, UChar32 end);
00489
00490
00495 void retain(UChar32 c);
00496
00509 virtual void remove(UChar32 start, UChar32 end);
00510
00517 void remove(UChar32 c);
00518
00525 virtual void complement(void);
00526
00540 virtual void complement(UChar32 start, UChar32 end);
00541
00542
00549 void complement(UChar32 c);
00550
00560 virtual UBool containsAll(const UnicodeSet& c) const;
00561
00562 private:
00563 friend class NormalizationTransliterator;
00564
00568 UBool containsAll(const UnicodeString& s) const;
00569
00570 public:
00571
00583 virtual void addAll(const UnicodeSet& c);
00584
00595 virtual void retainAll(const UnicodeSet& c);
00596
00607 virtual void removeAll(const UnicodeSet& c);
00608
00617 virtual void complementAll(const UnicodeSet& c);
00618
00624 virtual void clear(void);
00625
00632 virtual int32_t getRangeCount(void) const;
00633
00640 virtual UChar32 getRangeStart(int32_t index) const;
00641
00648 virtual UChar32 getRangeEnd(int32_t index) const;
00649
00654 virtual void compact();
00655
00667 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00668
00676 virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); };
00677
00678 private:
00679
00680 static const char fgClassID;
00681
00682 private:
00683
00684
00685
00686
00687
00688 friend class Transliterator;
00689 friend class TransliteratorParser;
00690 friend class TransliteratorIDParser;
00691 friend class TransliterationRule;
00692
00711 UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
00712 const SymbolTable& symbols,
00713 UErrorCode& status);
00714
00720 UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
00721 UErrorCode& status);
00722
00728 virtual UBool matchesIndexValue(uint8_t v) const;
00729
00730 private:
00731
00732
00733
00734
00735
00760 void applyPattern(const UnicodeString& pattern,
00761 ParsePosition& pos,
00762 const SymbolTable* symbols,
00763 UErrorCode& status);
00764
00765
00766
00767
00768
00769 void ensureCapacity(int32_t newLen);
00770
00771 void ensureBufferCapacity(int32_t newLen);
00772
00773 void swapBuffers(void);
00774
00775 void _applyPattern(const UnicodeString& pattern,
00776 ParsePosition& pos,
00777 const SymbolTable* symbols,
00778 UnicodeString& rebuiltPat,
00779 UErrorCode& status);
00780
00781 UnicodeString& _toPattern(UnicodeString& result,
00782 UBool escapeUnprintable) const;
00783
00784 UnicodeString& _generatePattern(UnicodeString& result,
00785 UBool escapeUnprintable) const;
00786
00787 static void _appendToPat(UnicodeString& buf, UChar32 c, UBool escapeUnprintable);
00788
00789
00790
00791
00792
00793 void exclusiveOr(const UChar32* other, int32_t otherLen, int8_t polarity);
00794
00795 void add(const UChar32* other, int32_t otherLen, int8_t polarity);
00796
00797 void retain(const UChar32* other, int32_t otherLen, int8_t polarity);
00798 };
00799
00800 inline UBool UnicodeSet::operator!=(const UnicodeSet& o) const {
00801 return !operator==(o);
00802 }
00803
00804 U_NAMESPACE_END
00805
00806 #endif