chariter.h

Go to the documentation of this file.
00001 /*
00002 ********************************************************************
00003 *
00004 *   Copyright (C) 1997-2005, 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 
00372     virtual CharacterIterator* clone(void) const = 0;
00373 
00381     virtual UChar         first(void) = 0;
00382 
00391     virtual UChar         firstPostInc(void);
00392 
00402     virtual UChar32       first32(void) = 0;
00403 
00412     virtual UChar32       first32PostInc(void);
00413 
00421     inline int32_t    setToStart();
00422 
00430     virtual UChar         last(void) = 0;
00431         
00439     virtual UChar32       last32(void) = 0;
00440 
00448     inline int32_t    setToEnd();
00449 
00458     virtual UChar         setIndex(int32_t position) = 0;
00459 
00471     virtual UChar32       setIndex32(int32_t position) = 0;
00472 
00478     virtual UChar         current(void) const = 0;
00479         
00485     virtual UChar32       current32(void) const = 0;
00486         
00494     virtual UChar         next(void) = 0;
00495         
00506     virtual UChar32       next32(void) = 0;
00507         
00515     virtual UChar         previous(void) = 0;
00516 
00524     virtual UChar32       previous32(void) = 0;
00525 
00535     virtual UBool        hasPrevious() = 0;
00536 
00547     inline int32_t       startIndex(void) const;
00548         
00558     inline int32_t       endIndex(void) const;
00559         
00568     inline int32_t       getIndex(void) const;
00569 
00576     inline int32_t           getLength() const;
00577 
00589     virtual int32_t      move(int32_t delta, EOrigin origin) = 0;
00590 
00602     virtual int32_t      move32(int32_t delta, EOrigin origin) = 0;
00603 
00610     virtual void            getText(UnicodeString&  result) = 0;
00611 
00612 protected:
00617     CharacterIterator();
00618 
00623     CharacterIterator(int32_t length);
00624 
00629     CharacterIterator(int32_t length, int32_t position);
00630 
00635     CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
00636   
00643     CharacterIterator(const CharacterIterator &that);
00644 
00652     CharacterIterator &operator=(const CharacterIterator &that);
00653 
00659     int32_t textLength;
00660 
00665     int32_t  pos;
00666 
00671     int32_t  begin;
00672 
00677     int32_t  end;
00678 };
00679 
00680 inline UBool
00681 ForwardCharacterIterator::operator!=(const ForwardCharacterIterator& that) const {
00682     return !operator==(that);
00683 }
00684 
00685 inline int32_t
00686 CharacterIterator::setToStart() {
00687     return move(0, kStart);
00688 }
00689 
00690 inline int32_t
00691 CharacterIterator::setToEnd() {
00692     return move(0, kEnd);
00693 }
00694 
00695 inline int32_t
00696 CharacterIterator::startIndex(void) const {
00697     return begin;
00698 }
00699 
00700 inline int32_t
00701 CharacterIterator::endIndex(void) const {
00702     return end;
00703 }
00704 
00705 inline int32_t
00706 CharacterIterator::getIndex(void) const {
00707     return pos;
00708 }
00709 
00710 inline int32_t
00711 CharacterIterator::getLength(void) const {
00712     return textLength;
00713 }
00714 
00715 U_NAMESPACE_END
00716 #endif

Generated on Mon Aug 13 07:17:23 2007 for ICU 3.6 by  doxygen 1.5.2