ICU 49.1.1
49.1.1
|
00001 /* 00002 ******************************************************************** 00003 * 00004 * Copyright (C) 1997-2011, International Business Machines 00005 * Corporation and others. All Rights Reserved. 00006 * 00007 ******************************************************************** 00008 */ 00009 00010 #ifndef CHARITER_H 00011 #define CHARITER_H 00012 00013 #include "unicode/utypes.h" 00014 #include "unicode/uobject.h" 00015 #include "unicode/unistr.h" 00021 U_NAMESPACE_BEGIN 00089 class U_COMMON_API ForwardCharacterIterator : public UObject { 00090 public: 00096 enum { DONE = 0xffff }; 00097 00102 virtual ~ForwardCharacterIterator(); 00103 00112 virtual UBool operator==(const ForwardCharacterIterator& that) const = 0; 00113 00124 inline UBool operator!=(const ForwardCharacterIterator& that) const; 00125 00131 virtual int32_t hashCode(void) const = 0; 00132 00140 virtual UClassID getDynamicClassID(void) const = 0; 00141 00150 virtual UChar nextPostInc(void) = 0; 00151 00160 virtual UChar32 next32PostInc(void) = 0; 00161 00171 virtual UBool hasNext() = 0; 00172 00173 protected: 00175 ForwardCharacterIterator(); 00176 00178 ForwardCharacterIterator(const ForwardCharacterIterator &other); 00179 00184 ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; } 00185 }; 00186 00356 class U_COMMON_API CharacterIterator : public ForwardCharacterIterator { 00357 public: 00362 enum EOrigin { kStart, kCurrent, kEnd }; 00363 00368 virtual ~CharacterIterator(); 00369 00378 virtual CharacterIterator* clone(void) const = 0; 00379 00387 virtual UChar first(void) = 0; 00388 00397 virtual UChar firstPostInc(void); 00398 00408 virtual UChar32 first32(void) = 0; 00409 00418 virtual UChar32 first32PostInc(void); 00419 00427 inline int32_t setToStart(); 00428 00436 virtual UChar last(void) = 0; 00437 00445 virtual UChar32 last32(void) = 0; 00446 00454 inline int32_t setToEnd(); 00455 00464 virtual UChar setIndex(int32_t position) = 0; 00465 00477 virtual UChar32 setIndex32(int32_t position) = 0; 00478 00484 virtual UChar current(void) const = 0; 00485 00491 virtual UChar32 current32(void) const = 0; 00492 00500 virtual UChar next(void) = 0; 00501 00512 virtual UChar32 next32(void) = 0; 00513 00521 virtual UChar previous(void) = 0; 00522 00530 virtual UChar32 previous32(void) = 0; 00531 00541 virtual UBool hasPrevious() = 0; 00542 00553 inline int32_t startIndex(void) const; 00554 00564 inline int32_t endIndex(void) const; 00565 00574 inline int32_t getIndex(void) const; 00575 00582 inline int32_t getLength() const; 00583 00595 virtual int32_t move(int32_t delta, EOrigin origin) = 0; 00596 00608 virtual int32_t move32(int32_t delta, EOrigin origin) = 0; 00609 00616 virtual void getText(UnicodeString& result) = 0; 00617 00618 protected: 00623 CharacterIterator(); 00624 00629 CharacterIterator(int32_t length); 00630 00635 CharacterIterator(int32_t length, int32_t position); 00636 00641 CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position); 00642 00649 CharacterIterator(const CharacterIterator &that); 00650 00658 CharacterIterator &operator=(const CharacterIterator &that); 00659 00665 int32_t textLength; 00666 00671 int32_t pos; 00672 00677 int32_t begin; 00678 00683 int32_t end; 00684 }; 00685 00686 inline UBool 00687 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const { 00688 return !operator==(that); 00689 } 00690 00691 inline int32_t 00692 CharacterIterator::setToStart() { 00693 return move(0, kStart); 00694 } 00695 00696 inline int32_t 00697 CharacterIterator::setToEnd() { 00698 return move(0, kEnd); 00699 } 00700 00701 inline int32_t 00702 CharacterIterator::startIndex(void) const { 00703 return begin; 00704 } 00705 00706 inline int32_t 00707 CharacterIterator::endIndex(void) const { 00708 return end; 00709 } 00710 00711 inline int32_t 00712 CharacterIterator::getIndex(void) const { 00713 return pos; 00714 } 00715 00716 inline int32_t 00717 CharacterIterator::getLength(void) const { 00718 return textLength; 00719 } 00720 00721 U_NAMESPACE_END 00722 #endif