Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

chariter.h

Go to the documentation of this file.
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/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   
00179   ForwardCharacterIterator &operator=(const ForwardCharacterIterator&) { return *this; }
00180 };
00181 
00351 class U_COMMON_API CharacterIterator : public ForwardCharacterIterator {
00352 public:
00357   enum EOrigin { kStart, kCurrent, kEnd };
00358 
00367   virtual CharacterIterator* clone(void) const = 0;
00368 
00376   virtual UChar         first(void) = 0;
00377 
00386   virtual UChar         firstPostInc(void);
00387 
00397   virtual UChar32       first32(void) = 0;
00398 
00407   virtual UChar32       first32PostInc(void);
00408 
00416   inline int32_t    setToStart();
00417 
00425   virtual UChar         last(void) = 0;
00426         
00434   virtual UChar32       last32(void) = 0;
00435 
00443   inline int32_t    setToEnd();
00444 
00453   virtual UChar         setIndex(int32_t position) = 0;
00454 
00466   virtual UChar32       setIndex32(int32_t position) = 0;
00467 
00473   virtual UChar         current(void) const = 0;
00474         
00480   virtual UChar32       current32(void) const = 0;
00481         
00489   virtual UChar         next(void) = 0;
00490         
00501   virtual UChar32       next32(void) = 0;
00502         
00510   virtual UChar         previous(void) = 0;
00511 
00519   virtual UChar32       previous32(void) = 0;
00520 
00530   virtual UBool        hasPrevious() = 0;
00531 
00542   inline int32_t       startIndex(void) const;
00543         
00553   inline int32_t       endIndex(void) const;
00554         
00563   inline int32_t       getIndex(void) const;
00564 
00571   inline int32_t           getLength() const;
00572 
00584   virtual int32_t      move(int32_t delta, EOrigin origin) = 0;
00585 
00597   virtual int32_t      move32(int32_t delta, EOrigin origin) = 0;
00598 
00605   virtual void            getText(UnicodeString&  result) = 0;
00606 
00607 protected:
00608   CharacterIterator() {}
00609   CharacterIterator(int32_t length);
00610   CharacterIterator(int32_t length, int32_t position);
00611   CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
00612   
00613   /*copy constructor
00614    * @param that The CharacterIterator to be copied
00615    * @return the newly created CharacterIterator. */
00616   CharacterIterator(const CharacterIterator &that);
00617 
00624   CharacterIterator &operator=(const CharacterIterator &that);
00625 
00626   int32_t      textLength; // need this for correct getText() and hashCode()
00627   int32_t  pos;
00628   int32_t  begin;
00629   int32_t  end;
00630 };
00631 
00632 inline UBool
00633 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
00634   return !operator==(that);
00635 }
00636 
00637 inline int32_t
00638 CharacterIterator::setToStart() {
00639   return move(0, kStart);
00640 }
00641 
00642 inline int32_t
00643 CharacterIterator::setToEnd() {
00644   return move(0, kEnd);
00645 }
00646 
00647 inline int32_t
00648 CharacterIterator::startIndex(void) const {
00649   return begin;
00650 }
00651 
00652 inline int32_t
00653 CharacterIterator::endIndex(void) const {
00654   return end;
00655 }
00656 
00657 inline int32_t
00658 CharacterIterator::getIndex(void) const {
00659   return pos;
00660 }
00661 
00662 inline int32_t
00663 CharacterIterator::getLength(void) const {
00664   return textLength;
00665 }
00666 
00667 U_NAMESPACE_END
00668 #endif

Generated on Thu Aug 15 14:13:23 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001