Home | History | Annotate | Download | only in intltest
      1 /********************************************************************
      2  * COPYRIGHT:
      3  * Copyright (c) 1997-2003, International Business Machines Corporation and
      4  * others. All Rights Reserved.
      5  ********************************************************************/
      6 
      7 #ifndef SFDWCHIT_H
      8 #define SFDWCHIT_H
      9 
     10 #include "unicode/chariter.h"
     11 #include "intltest.h"
     12 
     13 class SimpleFwdCharIterator : public ForwardCharacterIterator {
     14 public:
     15     // not used -- SimpleFwdCharIterator(const UnicodeString& s);
     16     SimpleFwdCharIterator(UChar *s, int32_t len, UBool adopt = FALSE);
     17 
     18     virtual ~SimpleFwdCharIterator();
     19 
     20   /**
     21    * Returns true when both iterators refer to the same
     22    * character in the same character-storage object.
     23    */
     24   // not used -- virtual UBool operator==(const ForwardCharacterIterator& that) const;
     25 
     26   /**
     27    * Generates a hash code for this iterator.
     28    */
     29   virtual int32_t hashCode(void) const;
     30 
     31   /**
     32    * Returns a UClassID for this ForwardCharacterIterator ("poor man's
     33    * RTTI").<P> Despite the fact that this function is public,
     34    * DO NOT CONSIDER IT PART OF CHARACTERITERATOR'S API!
     35    */
     36   virtual UClassID getDynamicClassID(void) const;
     37 
     38   /**
     39    * Gets the current code unit for returning and advances to the next code unit
     40    * in the iteration range
     41    * (toward endIndex()).  If there are
     42    * no more code units to return, returns DONE.
     43    */
     44   virtual UChar         nextPostInc(void);
     45 
     46   /**
     47    * Gets the current code point for returning and advances to the next code point
     48    * in the iteration range
     49    * (toward endIndex()).  If there are
     50    * no more code points to return, returns DONE.
     51    */
     52   virtual UChar32       next32PostInc(void);
     53 
     54   /**
     55    * Returns FALSE if there are no more code units or code points
     56    * at or after the current position in the iteration range.
     57    * This is used with nextPostInc() or next32PostInc() in forward
     58    * iteration.
     59    */
     60   virtual UBool        hasNext();
     61 
     62 protected:
     63     SimpleFwdCharIterator() {}
     64     SimpleFwdCharIterator(const SimpleFwdCharIterator &other)
     65         : ForwardCharacterIterator(other) {}
     66     SimpleFwdCharIterator &operator=(const SimpleFwdCharIterator&) { return *this; }
     67 private:
     68     static const int32_t            kInvalidHashCode;
     69     static const int32_t            kEmptyHashCode;
     70 
     71     UChar *fStart, *fEnd, *fCurrent;
     72     int32_t fLen;
     73     UBool fBogus;
     74     int32_t fHashCode;
     75 };
     76 
     77 #endif
     78