|
ICU 73.2
73.2
|
00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ******************************************************************** 00005 * 00006 * Copyright (C) 1997-2011, International Business Machines 00007 * Corporation and others. All Rights Reserved. 00008 * 00009 ******************************************************************** 00010 */ 00011 00012 #ifndef CHARITER_H 00013 #define CHARITER_H 00014 00015 #include "unicode/utypes.h" 00016 00017 #if U_SHOW_CPLUSPLUS_API 00018 00019 #include "unicode/uobject.h" 00020 #include "unicode/unistr.h" 00026 U_NAMESPACE_BEGIN 00094 class U_COMMON_API ForwardCharacterIterator : public UObject { 00095 public: 00101 enum { DONE = 0xffff }; 00102 00107 virtual ~ForwardCharacterIterator(); 00108 00117 virtual bool operator==(const ForwardCharacterIterator& that) const = 0; 00118 00129 inline bool operator!=(const ForwardCharacterIterator& that) const; 00130 00136 virtual int32_t hashCode(void) const = 0; 00137 00145 virtual UClassID getDynamicClassID(void) const override = 0; 00146 00155 virtual char16_t nextPostInc(void) = 0; 00156 00165 virtual UChar32 next32PostInc(void) = 0; 00166 00176 virtual UBool hasNext() = 0; 00177 00178 protected: 00180 ForwardCharacterIterator(); 00181 00183 ForwardCharacterIterator(const ForwardCharacterIterator &other); 00184 00189 ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; } 00190 }; 00191 00361 class U_COMMON_API CharacterIterator : public ForwardCharacterIterator { 00362 public: 00367 enum EOrigin { kStart, kCurrent, kEnd }; 00368 00373 virtual ~CharacterIterator(); 00374 00383 virtual CharacterIterator* clone() const = 0; 00384 00392 virtual char16_t first(void) = 0; 00393 00402 virtual char16_t firstPostInc(void); 00403 00413 virtual UChar32 first32(void) = 0; 00414 00423 virtual UChar32 first32PostInc(void); 00424 00432 inline int32_t setToStart(); 00433 00441 virtual char16_t last(void) = 0; 00442 00450 virtual UChar32 last32(void) = 0; 00451 00459 inline int32_t setToEnd(); 00460 00469 virtual char16_t setIndex(int32_t position) = 0; 00470 00482 virtual UChar32 setIndex32(int32_t position) = 0; 00483 00489 virtual char16_t current(void) const = 0; 00490 00496 virtual UChar32 current32(void) const = 0; 00497 00505 virtual char16_t next(void) = 0; 00506 00517 virtual UChar32 next32(void) = 0; 00518 00526 virtual char16_t previous(void) = 0; 00527 00535 virtual UChar32 previous32(void) = 0; 00536 00546 virtual UBool hasPrevious() = 0; 00547 00558 inline int32_t startIndex(void) const; 00559 00569 inline int32_t endIndex(void) const; 00570 00579 inline int32_t getIndex(void) const; 00580 00587 inline int32_t getLength() const; 00588 00600 virtual int32_t move(int32_t delta, EOrigin origin) = 0; 00601 00613 #ifdef move32 00614 // One of the system headers right now is sometimes defining a conflicting macro we don't use 00615 #undef move32 00616 #endif 00617 virtual int32_t move32(int32_t delta, EOrigin origin) = 0; 00618 00625 virtual void getText(UnicodeString& result) = 0; 00626 00627 protected: 00632 CharacterIterator(); 00633 00638 CharacterIterator(int32_t length); 00639 00644 CharacterIterator(int32_t length, int32_t position); 00645 00650 CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position); 00651 00658 CharacterIterator(const CharacterIterator &that); 00659 00667 CharacterIterator &operator=(const CharacterIterator &that); 00668 00674 int32_t textLength; 00675 00680 int32_t pos; 00681 00686 int32_t begin; 00687 00692 int32_t end; 00693 }; 00694 00695 inline bool 00696 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const { 00697 return !operator==(that); 00698 } 00699 00700 inline int32_t 00701 CharacterIterator::setToStart() { 00702 return move(0, kStart); 00703 } 00704 00705 inline int32_t 00706 CharacterIterator::setToEnd() { 00707 return move(0, kEnd); 00708 } 00709 00710 inline int32_t 00711 CharacterIterator::startIndex(void) const { 00712 return begin; 00713 } 00714 00715 inline int32_t 00716 CharacterIterator::endIndex(void) const { 00717 return end; 00718 } 00719 00720 inline int32_t 00721 CharacterIterator::getIndex(void) const { 00722 return pos; 00723 } 00724 00725 inline int32_t 00726 CharacterIterator::getLength(void) const { 00727 return textLength; 00728 } 00729 00730 U_NAMESPACE_END 00731 00732 #endif /* U_SHOW_CPLUSPLUS_API */ 00733 00734 #endif
1.7.6.1