ICU 4.8.1.1  4.8.1.1
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
chariter.h
Go to the documentation of this file.
1 /*
2 ********************************************************************
3 *
4 * Copyright (C) 1997-2005, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 ********************************************************************
8 */
9 
10 #ifndef CHARITER_H
11 #define CHARITER_H
12 
13 #include "unicode/utypes.h"
14 #include "unicode/uobject.h"
15 #include "unicode/unistr.h"
90 public:
96  enum { DONE = 0xffff };
97 
102  virtual ~ForwardCharacterIterator();
103 
112  virtual UBool operator==(const ForwardCharacterIterator& that) const = 0;
113 
124  inline UBool operator!=(const ForwardCharacterIterator& that) const;
125 
131  virtual int32_t hashCode(void) const = 0;
132 
140  virtual UClassID getDynamicClassID(void) const = 0;
141 
150  virtual UChar nextPostInc(void) = 0;
151 
160  virtual UChar32 next32PostInc(void) = 0;
161 
171  virtual UBool hasNext() = 0;
172 
173 protected:
176 
179 
185 };
186 
357 public:
362  enum EOrigin { kStart, kCurrent, kEnd };
363 
372  virtual CharacterIterator* clone(void) const = 0;
373 
381  virtual UChar first(void) = 0;
382 
391  virtual UChar firstPostInc(void);
392 
402  virtual UChar32 first32(void) = 0;
403 
412  virtual UChar32 first32PostInc(void);
413 
421  inline int32_t setToStart();
422 
430  virtual UChar last(void) = 0;
431 
439  virtual UChar32 last32(void) = 0;
440 
448  inline int32_t setToEnd();
449 
458  virtual UChar setIndex(int32_t position) = 0;
459 
471  virtual UChar32 setIndex32(int32_t position) = 0;
472 
478  virtual UChar current(void) const = 0;
479 
485  virtual UChar32 current32(void) const = 0;
486 
494  virtual UChar next(void) = 0;
495 
506  virtual UChar32 next32(void) = 0;
507 
515  virtual UChar previous(void) = 0;
516 
524  virtual UChar32 previous32(void) = 0;
525 
535  virtual UBool hasPrevious() = 0;
536 
547  inline int32_t startIndex(void) const;
548 
558  inline int32_t endIndex(void) const;
559 
568  inline int32_t getIndex(void) const;
569 
576  inline int32_t getLength() const;
577 
589  virtual int32_t move(int32_t delta, EOrigin origin) = 0;
590 
602  virtual int32_t move32(int32_t delta, EOrigin origin) = 0;
603 
610  virtual void getText(UnicodeString& result) = 0;
611 
612 protected:
618 
623  CharacterIterator(int32_t length);
624 
629  CharacterIterator(int32_t length, int32_t position);
630 
635  CharacterIterator(int32_t length, int32_t textBegin, int32_t textEnd, int32_t position);
636 
644 
653 
659  int32_t textLength;
660 
665  int32_t pos;
666 
671  int32_t begin;
672 
677  int32_t end;
678 };
679 
680 inline UBool
682  return !operator==(that);
683 }
684 
685 inline int32_t
687  return move(0, kStart);
688 }
689 
690 inline int32_t
692  return move(0, kEnd);
693 }
694 
695 inline int32_t
697  return begin;
698 }
699 
700 inline int32_t
702  return end;
703 }
704 
705 inline int32_t
707  return pos;
708 }
709 
710 inline int32_t
712  return textLength;
713 }
714 
716 #endif
int32_t textLength
Base class text length field.
Definition: chariter.h:659
int32_t getIndex(void) const
Returns the numeric index in the underlying text-storage object of the character the iterator current...
Definition: chariter.h:706
C++ API: Unicode String.
virtual UBool operator==(const ForwardCharacterIterator &that) const =0
Returns true when both iterators refer to the same character in the same character-storage object...
ForwardCharacterIterator & operator=(const ForwardCharacterIterator &)
Assignment operator to be overridden in the implementing class.
Definition: chariter.h:184
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
int32_t startIndex(void) const
Returns the numeric index in the underlying text-storage object of the character returned by first()...
Definition: chariter.h:696
int32_t setToStart()
Sets the iterator to refer to the first code unit or code point in its iteration range.
Definition: chariter.h:686
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:356
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
int32_t endIndex(void) const
Returns the numeric index in the underlying text-storage object of the position immediately BEYOND th...
Definition: chariter.h:701
int32_t pos
Base class field for the current position.
Definition: chariter.h:665
int32_t UChar32
Define UChar32 as a type for single Unicode code points.
Definition: umachine.h:345
virtual int32_t move(int32_t delta, EOrigin origin)=0
Moves the current position relative to the start or end of the iteration range, or relative to the cu...
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:188
EOrigin
Origin enumeration for the move() and move32() functions.
Definition: chariter.h:362
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
C++ API: Common ICU base class UObject.
uint16_t UChar
Define UChar to be wchar_t if that is 16 bits wide; always assumed to be unsigned.
Definition: umachine.h:325
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:215
UBool operator!=(const ForwardCharacterIterator &that) const
Returns true when the iterators refer to different text-storage objects, or to different characters i...
Definition: chariter.h:681
int32_t end
Base class field for the end of the iteration range.
Definition: chariter.h:677
void * UClassID
UClassID is used to identify classes without using RTTI, since RTTI is not yet supported by all C++ c...
Definition: utypes.h:385
int32_t begin
Base class field for the start of the iteration range.
Definition: chariter.h:671
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:520
Abstract class that defines an API for forward-only iteration on text objects.
Definition: chariter.h:89
int32_t getLength() const
Returns the length of the entire text in the underlying text-storage object.
Definition: chariter.h:711
int32_t setToEnd()
Sets the iterator to the end of its iteration range, just behind the last code unit or code point...
Definition: chariter.h:691
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:228