Path: blob/jdk8u272-b10-aarch32-20201026/jdk/src/share/native/common/unicode/schriter.h
48773 views
// © 2016 and later: Unicode, Inc. and others.1// License & terms of use: http://www.unicode.org/copyright.html2/*3******************************************************************************4*5* Copyright (C) 1998-2005, International Business Machines6* Corporation and others. All Rights Reserved.7*8******************************************************************************9*10* File schriter.h11*12* Modification History:13*14* Date Name Description15* 05/05/99 stephen Cleaned up.16******************************************************************************17*/1819#ifndef SCHRITER_H20#define SCHRITER_H2122#include "unicode/utypes.h"23#include "unicode/chariter.h"24#include "unicode/uchriter.h"2526/**27* \file28* \brief C++ API: String Character Iterator29*/3031U_NAMESPACE_BEGIN32/**33* A concrete subclass of CharacterIterator that iterates over the34* characters (code units or code points) in a UnicodeString.35* It's possible not only to create an36* iterator that iterates over an entire UnicodeString, but also to37* create one that iterates over only a subrange of a UnicodeString38* (iterators over different subranges of the same UnicodeString don't39* compare equal).40* @see CharacterIterator41* @see ForwardCharacterIterator42* @stable ICU 2.043*/44class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator {45public:46/**47* Create an iterator over the UnicodeString referred to by "textStr".48* The UnicodeString object is copied.49* The iteration range is the whole string, and the starting position is 0.50* @param textStr The unicode string used to create an iterator51* @stable ICU 2.052*/53StringCharacterIterator(const UnicodeString& textStr);5455/**56* Create an iterator over the UnicodeString referred to by "textStr".57* The iteration range is the whole string, and the starting58* position is specified by "textPos". If "textPos" is outside the valid59* iteration range, the behavior of this object is undefined.60* @param textStr The unicode string used to create an iterator61* @param textPos The starting position of the iteration62* @stable ICU 2.063*/64StringCharacterIterator(const UnicodeString& textStr,65int32_t textPos);6667/**68* Create an iterator over the UnicodeString referred to by "textStr".69* The UnicodeString object is copied.70* The iteration range begins with the code unit specified by71* "textBegin" and ends with the code unit BEFORE the code unit specified72* by "textEnd". The starting position is specified by "textPos". If73* "textBegin" and "textEnd" don't form a valid range on "text" (i.e.,74* textBegin >= textEnd or either is negative or greater than text.size()),75* or "textPos" is outside the range defined by "textBegin" and "textEnd",76* the behavior of this iterator is undefined.77* @param textStr The unicode string used to create the StringCharacterIterator78* @param textBegin The begin position of the iteration range79* @param textEnd The end position of the iteration range80* @param textPos The starting position of the iteration81* @stable ICU 2.082*/83StringCharacterIterator(const UnicodeString& textStr,84int32_t textBegin,85int32_t textEnd,86int32_t textPos);8788/**89* Copy constructor. The new iterator iterates over the same range90* of the same string as "that", and its initial position is the91* same as "that"'s current position.92* The UnicodeString object in "that" is copied.93* @param that The StringCharacterIterator to be copied94* @stable ICU 2.095*/96StringCharacterIterator(const StringCharacterIterator& that);9798/**99* Destructor.100* @stable ICU 2.0101*/102virtual ~StringCharacterIterator();103104/**105* Assignment operator. *this is altered to iterate over the same106* range of the same string as "that", and refers to the same107* character within that string as "that" does.108* @param that The object to be copied.109* @return the newly created object.110* @stable ICU 2.0111*/112StringCharacterIterator&113operator=(const StringCharacterIterator& that);114115/**116* Returns true if the iterators iterate over the same range of the117* same string and are pointing at the same character.118* @param that The ForwardCharacterIterator to be compared for equality119* @return true if the iterators iterate over the same range of the120* same string and are pointing at the same character.121* @stable ICU 2.0122*/123virtual UBool operator==(const ForwardCharacterIterator& that) const;124125/**126* Returns a new StringCharacterIterator referring to the same127* character in the same range of the same string as this one. The128* caller must delete the new iterator.129* @return the newly cloned object.130* @stable ICU 2.0131*/132virtual CharacterIterator* clone(void) const;133134/**135* Sets the iterator to iterate over the provided string.136* @param newText The string to be iterated over137* @stable ICU 2.0138*/139void setText(const UnicodeString& newText);140141/**142* Copies the UnicodeString under iteration into the UnicodeString143* referred to by "result". Even if this iterator iterates across144* only a part of this string, the whole string is copied.145* @param result Receives a copy of the text under iteration.146* @stable ICU 2.0147*/148virtual void getText(UnicodeString& result);149150/**151* Return a class ID for this object (not really public)152* @return a class ID for this object.153* @stable ICU 2.0154*/155virtual UClassID getDynamicClassID(void) const;156157/**158* Return a class ID for this class (not really public)159* @return a class ID for this class160* @stable ICU 2.0161*/162static UClassID U_EXPORT2 getStaticClassID(void);163164protected:165/**166* Default constructor, iteration over empty string.167* @stable ICU 2.0168*/169StringCharacterIterator();170171/**172* Sets the iterator to iterate over the provided string.173* @param newText The string to be iterated over174* @param newTextLength The length of the String175* @stable ICU 2.0176*/177void setText(const char16_t* newText, int32_t newTextLength);178179/**180* Copy of the iterated string object.181* @stable ICU 2.0182*/183UnicodeString text;184185};186187U_NAMESPACE_END188#endif189190191