00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef CHARITER_H
00011 #define CHARITER_H
00012
00013 #include "unicode/utypes.h"
00014 #include "unicode/unistr.h"
00015
00081 class U_COMMON_API ForwardCharacterIterator {
00082 public:
00086 enum { DONE = 0xffff };
00087
00092 virtual ~ForwardCharacterIterator() {}
00093
00099 virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
00100
00107 inline UBool operator!=(const ForwardCharacterIterator& that) const;
00108
00113 virtual int32_t hashCode(void) const = 0;
00114
00121 virtual UClassID getDynamicClassID(void) const = 0;
00122
00130 virtual UChar nextPostInc(void) = 0;
00131
00139 virtual UChar32 next32PostInc(void) = 0;
00140
00147 virtual UBool hasNext() = 0;
00148
00149 protected:
00150 ForwardCharacterIterator() {}
00151 ForwardCharacterIterator(const ForwardCharacterIterator&) {}
00152 ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
00153 };
00154
00322 class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
00323 public:
00327 enum EOrigin { kStart, kCurrent, kEnd };
00328
00336 virtual CharacterIterator* clone(void) const = 0;
00337
00344 virtual UChar first(void) = 0;
00345
00353 virtual UChar firstPostInc(void);
00354
00363 virtual UChar32 first32(void) = 0;
00364
00372 virtual UChar32 first32PostInc(void);
00373
00381 inline UTextOffset setToStart();
00382
00389 virtual UChar last(void) = 0;
00390
00397 virtual UChar32 last32(void) = 0;
00398
00406 inline UTextOffset setToEnd();
00407
00414 virtual UChar setIndex(UTextOffset position) = 0;
00415
00425 virtual UChar32 setIndex32(UTextOffset position) = 0;
00426
00431 virtual UChar current(void) const = 0;
00432
00437 virtual UChar32 current32(void) const = 0;
00438
00445 virtual UChar next(void) = 0;
00446
00456 virtual UChar32 next32(void) = 0;
00457
00464 virtual UChar previous(void) = 0;
00465
00472 virtual UChar32 previous32(void) = 0;
00473
00480 virtual UBool hasPrevious() = 0;
00481
00490 inline UTextOffset startIndex(void) const;
00491
00498 inline UTextOffset endIndex(void) const;
00499
00506 inline UTextOffset getIndex(void) const;
00507
00512 inline int32_t getLength() const;
00513
00521 virtual UTextOffset move(int32_t delta, EOrigin origin) = 0;
00522
00530 virtual UTextOffset move32(int32_t delta, EOrigin origin) = 0;
00531
00538 virtual void getText(UnicodeString& result) = 0;
00539
00540 protected:
00541 CharacterIterator() {}
00542 CharacterIterator(int32_t length);
00543 CharacterIterator(int32_t length, UTextOffset position);
00544 CharacterIterator(int32_t length, UTextOffset textBegin, UTextOffset textEnd, UTextOffset position);
00545 CharacterIterator(const CharacterIterator &that);
00546
00547 CharacterIterator &operator=(const CharacterIterator &that);
00548
00549 int32_t textLength;
00550 UTextOffset pos;
00551 UTextOffset begin;
00552 UTextOffset end;
00553 };
00554
00555 inline UBool
00556 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
00557 return !operator==(that);
00558 }
00559
00560 inline UTextOffset
00561 CharacterIterator::setToStart() {
00562 return move(0, kStart);
00563 }
00564
00565 inline UTextOffset
00566 CharacterIterator::setToEnd() {
00567 return move(0, kEnd);
00568 }
00569
00570 inline UTextOffset
00571 CharacterIterator::startIndex(void) const {
00572 return begin;
00573 }
00574
00575 inline UTextOffset
00576 CharacterIterator::endIndex(void) const {
00577 return end;
00578 }
00579
00580 inline UTextOffset
00581 CharacterIterator::getIndex(void) const {
00582 return pos;
00583 }
00584
00585 inline int32_t
00586 CharacterIterator::getLength(void) const {
00587 return textLength;
00588 }
00589
00590 #endif