00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #ifndef CHARITER_H
00013 #define CHARITER_H
00014
00015 #include "unicode/utypes.h"
00016 #include "unicode/uobject.h"
00017 #include "unicode/unistr.h"
00023 U_NAMESPACE_BEGIN
00091 class U_COMMON_API ForwardCharacterIterator : public UObject {
00092 public:
00098 enum { DONE = 0xffff };
00099
00104 virtual ~ForwardCharacterIterator();
00105
00114 virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
00115
00126 inline UBool operator!=(const ForwardCharacterIterator& that) const;
00127
00133 virtual int32_t hashCode(void) const = 0;
00134
00142 virtual UClassID getDynamicClassID(void) const = 0;
00143
00152 virtual char16_t nextPostInc(void) = 0;
00153
00162 virtual UChar32 next32PostInc(void) = 0;
00163
00173 virtual UBool hasNext() = 0;
00174
00175 protected:
00177 ForwardCharacterIterator();
00178
00180 ForwardCharacterIterator(const ForwardCharacterIterator &other);
00181
00186 ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
00187 };
00188
00358 class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
00359 public:
00364 enum EOrigin { kStart, kCurrent, kEnd };
00365
00370 virtual ~CharacterIterator();
00371
00380 virtual CharacterIterator* clone(void) const = 0;
00381
00389 virtual char16_t first(void) = 0;
00390
00399 virtual char16_t firstPostInc(void);
00400
00410 virtual UChar32 first32(void) = 0;
00411
00420 virtual UChar32 first32PostInc(void);
00421
00429 inline int32_t setToStart();
00430
00438 virtual char16_t last(void) = 0;
00439
00447 virtual UChar32 last32(void) = 0;
00448
00456 inline int32_t setToEnd();
00457
00466 virtual char16_t setIndex(int32_t position) = 0;
00467
00479 virtual UChar32 setIndex32(int32_t position) = 0;
00480
00486 virtual char16_t current(void) const = 0;
00487
00493 virtual UChar32 current32(void) const = 0;
00494
00502 virtual char16_t next(void) = 0;
00503
00514 virtual UChar32 next32(void) = 0;
00515
00523 virtual char16_t previous(void) = 0;
00524
00532 virtual UChar32 previous32(void) = 0;
00533
00543 virtual UBool hasPrevious() = 0;
00544
00555 inline int32_t startIndex(void) const;
00556
00566 inline int32_t endIndex(void) const;
00567
00576 inline int32_t getIndex(void) const;
00577
00584 inline int32_t getLength() const;
00585
00597 virtual int32_t move(int32_t delta, EOrigin origin) = 0;
00598
00610 #ifdef move32
00611
00612 #undef move32
00613 #endif
00614 virtual int32_t move32(int32_t delta, EOrigin origin) = 0;
00615
00622 virtual void getText(UnicodeString& result) = 0;
00623
00624 protected:
00629 CharacterIterator();
00630
00635 CharacterIterator(int32_t length);
00636
00641 CharacterIterator(int32_t length, int32_t position);
00642
00647 CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
00648
00655 CharacterIterator(const CharacterIterator &that);
00656
00664 CharacterIterator &operator=(const CharacterIterator &that);
00665
00671 int32_t textLength;
00672
00677 int32_t pos;
00678
00683 int32_t begin;
00684
00689 int32_t end;
00690 };
00691
00692 inline UBool
00693 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
00694 return !operator==(that);
00695 }
00696
00697 inline int32_t
00698 CharacterIterator::setToStart() {
00699 return move(0, kStart);
00700 }
00701
00702 inline int32_t
00703 CharacterIterator::setToEnd() {
00704 return move(0, kEnd);
00705 }
00706
00707 inline int32_t
00708 CharacterIterator::startIndex(void) const {
00709 return begin;
00710 }
00711
00712 inline int32_t
00713 CharacterIterator::endIndex(void) const {
00714 return end;
00715 }
00716
00717 inline int32_t
00718 CharacterIterator::getIndex(void) const {
00719 return pos;
00720 }
00721
00722 inline int32_t
00723 CharacterIterator::getLength(void) const {
00724 return textLength;
00725 }
00726
00727 U_NAMESPACE_END
00728 #endif