Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/src/share/native/common/unicode/schriter.h
38827 views
/*1******************************************************************************2*3* Copyright (C) 1998-2005, International Business Machines4* Corporation and others. All Rights Reserved.5*6******************************************************************************7*8* File schriter.h9*10* Modification History:11*12* Date Name Description13* 05/05/99 stephen Cleaned up.14******************************************************************************15*/1617#ifndef SCHRITER_H18#define SCHRITER_H1920#include "unicode/utypes.h"21#include "unicode/chariter.h"22#include "unicode/uchriter.h"2324/**25* \file26* \brief C++ API: String Character Iterator27*/2829U_NAMESPACE_BEGIN30/**31* A concrete subclass of CharacterIterator that iterates over the32* characters (code units or code points) in a UnicodeString.33* It's possible not only to create an34* iterator that iterates over an entire UnicodeString, but also to35* create one that iterates over only a subrange of a UnicodeString36* (iterators over different subranges of the same UnicodeString don't37* compare equal).38* @see CharacterIterator39* @see ForwardCharacterIterator40* @stable ICU 2.041*/42class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator {43public:44/**45* Create an iterator over the UnicodeString referred to by "textStr".46* The UnicodeString object is copied.47* The iteration range is the whole string, and the starting position is 0.48* @param textStr The unicode string used to create an iterator49* @stable ICU 2.050*/51StringCharacterIterator(const UnicodeString& textStr);5253/**54* Create an iterator over the UnicodeString referred to by "textStr".55* The iteration range is the whole string, and the starting56* position is specified by "textPos". If "textPos" is outside the valid57* iteration range, the behavior of this object is undefined.58* @param textStr The unicode string used to create an iterator59* @param textPos The starting position of the iteration60* @stable ICU 2.061*/62StringCharacterIterator(const UnicodeString& textStr,63int32_t textPos);6465/**66* Create an iterator over the UnicodeString referred to by "textStr".67* The UnicodeString object is copied.68* The iteration range begins with the code unit specified by69* "textBegin" and ends with the code unit BEFORE the code unit specfied70* by "textEnd". The starting position is specified by "textPos". If71* "textBegin" and "textEnd" don't form a valid range on "text" (i.e.,72* textBegin >= textEnd or either is negative or greater than text.size()),73* or "textPos" is outside the range defined by "textBegin" and "textEnd",74* the behavior of this iterator is undefined.75* @param textStr The unicode string used to create the StringCharacterIterator76* @param textBegin The begin position of the iteration range77* @param textEnd The end position of the iteration range78* @param textPos The starting position of the iteration79* @stable ICU 2.080*/81StringCharacterIterator(const UnicodeString& textStr,82int32_t textBegin,83int32_t textEnd,84int32_t textPos);8586/**87* Copy constructor. The new iterator iterates over the same range88* of the same string as "that", and its initial position is the89* same as "that"'s current position.90* The UnicodeString object in "that" is copied.91* @param that The StringCharacterIterator to be copied92* @stable ICU 2.093*/94StringCharacterIterator(const StringCharacterIterator& that);9596/**97* Destructor.98* @stable ICU 2.099*/100virtual ~StringCharacterIterator();101102/**103* Assignment operator. *this is altered to iterate over the same104* range of the same string as "that", and refers to the same105* character within that string as "that" does.106* @param that The object to be copied.107* @return the newly created object.108* @stable ICU 2.0109*/110StringCharacterIterator&111operator=(const StringCharacterIterator& that);112113/**114* Returns true if the iterators iterate over the same range of the115* same string and are pointing at the same character.116* @param that The ForwardCharacterIterator to be compared for equality117* @return true if the iterators iterate over the same range of the118* same string and are pointing at the same character.119* @stable ICU 2.0120*/121virtual UBool operator==(const ForwardCharacterIterator& that) const;122123/**124* Returns a new StringCharacterIterator referring to the same125* character in the same range of the same string as this one. The126* caller must delete the new iterator.127* @return the newly cloned object.128* @stable ICU 2.0129*/130virtual CharacterIterator* clone(void) const;131132/**133* Sets the iterator to iterate over the provided string.134* @param newText The string to be iterated over135* @stable ICU 2.0136*/137void setText(const UnicodeString& newText);138139/**140* Copies the UnicodeString under iteration into the UnicodeString141* referred to by "result". Even if this iterator iterates across142* only a part of this string, the whole string is copied.143* @param result Receives a copy of the text under iteration.144* @stable ICU 2.0145*/146virtual void getText(UnicodeString& result);147148/**149* Return a class ID for this object (not really public)150* @return a class ID for this object.151* @stable ICU 2.0152*/153virtual UClassID getDynamicClassID(void) const;154155/**156* Return a class ID for this class (not really public)157* @return a class ID for this class158* @stable ICU 2.0159*/160static UClassID U_EXPORT2 getStaticClassID(void);161162protected:163/**164* Default constructor, iteration over empty string.165* @stable ICU 2.0166*/167StringCharacterIterator();168169/**170* Sets the iterator to iterate over the provided string.171* @param newText The string to be iterated over172* @param newTextLength The length of the String173* @stable ICU 2.0174*/175void setText(const UChar* newText, int32_t newTextLength);176177/**178* Copy of the iterated string object.179* @stable ICU 2.0180*/181UnicodeString text;182183};184185U_NAMESPACE_END186#endif187188189