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 UnicodeMatcher* 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
00447 virtual void add(UChar32 start, UChar32 end);
00448
00455 void add(UChar32 c);
00456
00469 virtual void retain(UChar32 start, UChar32 end);
00470
00471
00476 void retain(UChar32 c);
00477
00490 virtual void remove(UChar32 start, UChar32 end);
00491
00498 void remove(UChar32 c);
00499
00506 virtual void complement(void);
00507
00521 virtual void complement(UChar32 start, UChar32 end);
00522
00523
00530 void complement(UChar32 c);
00531
00541 virtual UBool containsAll(const UnicodeSet& c) const;
00542
00554 virtual void addAll(const UnicodeSet& c);
00555
00566 virtual void retainAll(const UnicodeSet& c);
00567
00578 virtual void removeAll(const UnicodeSet& c);
00579
00588 virtual void complementAll(const UnicodeSet& c);
00589
00595 virtual void clear(void);
00596
00603 virtual int32_t getRangeCount(void) const;
00604
00611 virtual UChar32 getRangeStart(int32_t index) const;
00612
00619 virtual UChar32 getRangeEnd(int32_t index) const;
00620
00625 virtual void compact();
00626
00638 static UClassID getStaticClassID(void) { return (UClassID)&fgClassID; }
00639
00647 virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); };
00648
00649 private:
00650
00651 static const char fgClassID;
00652
00653 private:
00654
00655
00656
00657
00658
00659 friend class Transliterator;
00660 friend class TransliteratorParser;
00661 friend class TransliterationRule;
00662
00681 UnicodeSet(const UnicodeString& pattern, ParsePosition& pos,
00682 const SymbolTable& symbols,
00683 UErrorCode& status);
00684
00690 virtual UBool matchesIndexValue(uint8_t v) const;
00691
00692 private:
00693
00694
00695
00696
00697
00722 void applyPattern(const UnicodeString& pattern,
00723 ParsePosition& pos,
00724 const SymbolTable* symbols,
00725 UErrorCode& status);
00726
00727
00728
00729
00730
00731 void ensureCapacity(int32_t newLen);
00732
00733 void ensureBufferCapacity(int32_t newLen);
00734
00735 void swapBuffers(void);
00736
00737 void _applyPattern(const UnicodeString& pattern,
00738 ParsePosition& pos,
00739 const SymbolTable* symbols,
00740 UnicodeString& rebuiltPat,
00741 UErrorCode& status);
00742
00743 UnicodeString& _toPattern(UnicodeString& result,
00744 UBool escapeUnprintable) const;
00745
00746 UnicodeString& _generatePattern(UnicodeString& result,
00747 UBool escapeUnprintable) const;
00748
00749 static void _appendToPat(UnicodeString& buf, UChar32 c, UBool escapeUnprintable);
00750
00751
00752
00753
00754
00755 void exclusiveOr(const UChar32* other, int32_t otherLen, int8_t polarity);
00756
00757 void add(const UChar32* other, int32_t otherLen, int8_t polarity);
00758
00759 void retain(const UChar32* other, int32_t otherLen, int8_t polarity);
00760 };
00761
00762 inline UBool UnicodeSet::operator!=(const UnicodeSet& o) const {
00763 return !operator==(o);
00764 }
00765
00766 U_NAMESPACE_END
00767
00768 #endif