Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

chariter.h

00001 /* 00002 ******************************************************************** 00003 * 00004 * Copyright (C) 1997-2001, 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/unistr.h" 00015 00016 U_NAMESPACE_BEGIN 00084 class U_COMMON_API ForwardCharacterIterator { 00085 public: 00091 enum { DONE = 0xffff }; 00092 00097 virtual ~ForwardCharacterIterator() {} 00098 00104 virtual UBool operator==(const ForwardCharacterIterator& that) const = 0; 00105 00112 inline UBool operator!=(const ForwardCharacterIterator& that) const; 00113 00118 virtual int32_t hashCode(void) const = 0; 00119 00126 virtual UClassID getDynamicClassID(void) const = 0; 00127 00135 virtual UChar nextPostInc(void) = 0; 00136 00144 virtual UChar32 next32PostInc(void) = 0; 00145 00153 virtual UBool hasNext() = 0; 00154 00155 protected: 00156 ForwardCharacterIterator() {} 00157 ForwardCharacterIterator(const ForwardCharacterIterator&) {} 00158 ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; } 00159 }; 00160 00330 class U_COMMON_API CharacterIterator : public ForwardCharacterIterator { 00331 public: 00336 enum EOrigin { kStart, kCurrent, kEnd }; 00337 00345 virtual CharacterIterator* clone(void) const = 0; 00346 00353 virtual UChar first(void) = 0; 00354 00362 virtual UChar firstPostInc(void); 00363 00372 virtual UChar32 first32(void) = 0; 00373 00381 virtual UChar32 first32PostInc(void); 00382 00390 inline int32_t setToStart(); 00391 00398 virtual UChar last(void) = 0; 00399 00406 virtual UChar32 last32(void) = 0; 00407 00415 inline int32_t setToEnd(); 00416 00423 virtual UChar setIndex(int32_t position) = 0; 00424 00434 virtual UChar32 setIndex32(int32_t position) = 0; 00435 00440 virtual UChar current(void) const = 0; 00441 00446 virtual UChar32 current32(void) const = 0; 00447 00454 virtual UChar next(void) = 0; 00455 00465 virtual UChar32 next32(void) = 0; 00466 00473 virtual UChar previous(void) = 0; 00474 00481 virtual UChar32 previous32(void) = 0; 00482 00490 virtual UBool hasPrevious() = 0; 00491 00500 inline int32_t startIndex(void) const; 00501 00508 inline int32_t endIndex(void) const; 00509 00516 inline int32_t getIndex(void) const; 00517 00523 inline int32_t getLength() const; 00524 00533 virtual int32_t move(int32_t delta, EOrigin origin) = 0; 00534 00543 virtual int32_t move32(int32_t delta, EOrigin origin) = 0; 00544 00551 virtual void getText(UnicodeString& result) = 0; 00552 00553 protected: 00554 CharacterIterator() {} 00555 CharacterIterator(int32_t length); 00556 CharacterIterator(int32_t length, int32_t position); 00557 CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position); 00558 CharacterIterator(const CharacterIterator &that); 00559 00560 CharacterIterator &operator=(const CharacterIterator &that); 00561 00562 int32_t textLength; // need this for correct getText() and hashCode() 00563 int32_t pos; 00564 int32_t begin; 00565 int32_t end; 00566 }; 00567 00568 inline UBool 00569 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const { 00570 return !operator==(that); 00571 } 00572 00573 inline int32_t 00574 CharacterIterator::setToStart() { 00575 return move(0, kStart); 00576 } 00577 00578 inline int32_t 00579 CharacterIterator::setToEnd() { 00580 return move(0, kEnd); 00581 } 00582 00583 inline int32_t 00584 CharacterIterator::startIndex(void) const { 00585 return begin; 00586 } 00587 00588 inline int32_t 00589 CharacterIterator::endIndex(void) const { 00590 return end; 00591 } 00592 00593 inline int32_t 00594 CharacterIterator::getIndex(void) const { 00595 return pos; 00596 } 00597 00598 inline int32_t 00599 CharacterIterator::getLength(void) const { 00600 return textLength; 00601 } 00602 00603 U_NAMESPACE_END 00604 #endif

Generated on Fri Aug 13 09:53:49 2004 for ICU 2.1 by doxygen 1.3.7