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

chariter.h

00001 /*
00002 ********************************************************************
00003 *
00004 *   Copyright (C) 1997-2003, 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"
00016 
00017 U_NAMESPACE_BEGIN
00085 class U_COMMON_API ForwardCharacterIterator : public UObject {
00086 public:
00092     enum { DONE = 0xffff };
00093     
00098     virtual ~ForwardCharacterIterator();
00099     
00108     virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
00109     
00120     inline UBool operator!=(const ForwardCharacterIterator& that) const;
00121     
00127     virtual int32_t hashCode(void) const = 0;
00128     
00136     virtual UClassID getDynamicClassID(void) const = 0;
00137     
00146     virtual UChar         nextPostInc(void) = 0;
00147     
00156     virtual UChar32       next32PostInc(void) = 0;
00157     
00167     virtual UBool        hasNext() = 0;
00168     
00169 protected:
00171     ForwardCharacterIterator() : UObject() {}
00172     
00174     ForwardCharacterIterator(const ForwardCharacterIterator &other) : UObject(other) {}
00175     
00180     ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
00181 };
00182 
00352 class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
00353 public:
00358     enum EOrigin { kStart, kCurrent, kEnd };
00359 
00368     virtual CharacterIterator* clone(void) const = 0;
00369 
00377     virtual UChar         first(void) = 0;
00378 
00387     virtual UChar         firstPostInc(void);
00388 
00398     virtual UChar32       first32(void) = 0;
00399 
00408     virtual UChar32       first32PostInc(void);
00409 
00417     inline int32_t    setToStart();
00418 
00426     virtual UChar         last(void) = 0;
00427         
00435     virtual UChar32       last32(void) = 0;
00436 
00444     inline int32_t    setToEnd();
00445 
00454     virtual UChar         setIndex(int32_t position) = 0;
00455 
00467     virtual UChar32       setIndex32(int32_t position) = 0;
00468 
00474     virtual UChar         current(void) const = 0;
00475         
00481     virtual UChar32       current32(void) const = 0;
00482         
00490     virtual UChar         next(void) = 0;
00491         
00502     virtual UChar32       next32(void) = 0;
00503         
00511     virtual UChar         previous(void) = 0;
00512 
00520     virtual UChar32       previous32(void) = 0;
00521 
00531     virtual UBool        hasPrevious() = 0;
00532 
00543     inline int32_t       startIndex(void) const;
00544         
00554     inline int32_t       endIndex(void) const;
00555         
00564     inline int32_t       getIndex(void) const;
00565 
00572     inline int32_t           getLength() const;
00573 
00585     virtual int32_t      move(int32_t delta, EOrigin origin) = 0;
00586 
00598     virtual int32_t      move32(int32_t delta, EOrigin origin) = 0;
00599 
00606     virtual void            getText(UnicodeString&  result) = 0;
00607 
00608 protected:
00613     CharacterIterator();
00614 
00619     CharacterIterator(int32_t length);
00620 
00625     CharacterIterator(int32_t length, int32_t position);
00626 
00631     CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
00632   
00639     CharacterIterator(const CharacterIterator &that);
00640 
00648     CharacterIterator &operator=(const CharacterIterator &that);
00649 
00655     int32_t textLength;
00656 
00661     int32_t  pos;
00662 
00667     int32_t  begin;
00668 
00673     int32_t  end;
00674 };
00675 
00676 inline UBool
00677 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
00678     return !operator==(that);
00679 }
00680 
00681 inline int32_t
00682 CharacterIterator::setToStart() {
00683     return move(0, kStart);
00684 }
00685 
00686 inline int32_t
00687 CharacterIterator::setToEnd() {
00688     return move(0, kEnd);
00689 }
00690 
00691 inline int32_t
00692 CharacterIterator::startIndex(void) const {
00693     return begin;
00694 }
00695 
00696 inline int32_t
00697 CharacterIterator::endIndex(void) const {
00698     return end;
00699 }
00700 
00701 inline int32_t
00702 CharacterIterator::getIndex(void) const {
00703     return pos;
00704 }
00705 
00706 inline int32_t
00707 CharacterIterator::getLength(void) const {
00708     return textLength;
00709 }
00710 
00711 U_NAMESPACE_END
00712 #endif

Generated on Wed May 18 17:29:14 2005 for ICU 2.8 by  doxygen 1.4.2