1999-12-28 23:39:02 +00:00
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
2004-05-18 22:01:41 +00:00
|
|
|
* Copyright (C) 1998-2004, International Business Machines
|
1999-12-28 23:39:02 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*
|
|
|
|
* File schriter.h
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 05/05/99 stephen Cleaned up.
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef SCHRITER_H
|
|
|
|
#define SCHRITER_H
|
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
#include "unicode/chariter.h"
|
2000-04-12 19:36:30 +00:00
|
|
|
#include "unicode/uchriter.h"
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* A concrete subclass of CharacterIterator that iterates over the
|
2000-04-12 19:36:30 +00:00
|
|
|
* characters (code units or code points) in a UnicodeString.
|
|
|
|
* It's possible not only to create an
|
1999-12-28 23:39:02 +00:00
|
|
|
* iterator that iterates over an entire UnicodeString, but also to
|
2000-04-12 19:36:30 +00:00
|
|
|
* create one that iterates over only a subrange of a UnicodeString
|
1999-12-28 23:39:02 +00:00
|
|
|
* (iterators over different subranges of the same UnicodeString don't
|
2000-04-12 19:36:30 +00:00
|
|
|
* compare equal).
|
2000-04-20 23:02:20 +00:00
|
|
|
* @see CharacterIterator
|
|
|
|
* @see ForwardCharacterIterator
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-04-12 19:36:30 +00:00
|
|
|
*/
|
|
|
|
class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator {
|
1999-12-28 23:39:02 +00:00
|
|
|
public:
|
|
|
|
/**
|
2000-11-29 01:32:34 +00:00
|
|
|
* Create an iterator over the UnicodeString referred to by "textStr".
|
2000-04-12 19:36:30 +00:00
|
|
|
* The UnicodeString object is copied.
|
1999-12-28 23:39:02 +00:00
|
|
|
* The iteration range is the whole string, and the starting position is 0.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param textStr The unicode string used to create an iterator
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
1999-12-28 23:39:02 +00:00
|
|
|
*/
|
2000-11-29 01:32:34 +00:00
|
|
|
StringCharacterIterator(const UnicodeString& textStr);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-11-29 01:32:34 +00:00
|
|
|
* Create an iterator over the UnicodeString referred to by "textStr".
|
1999-12-28 23:39:02 +00:00
|
|
|
* The iteration range is the whole string, and the starting
|
2000-11-29 01:32:34 +00:00
|
|
|
* position is specified by "textPos". If "textPos" is outside the valid
|
2004-08-24 17:21:14 +00:00
|
|
|
* iteration range, the behavior of this object is undefined.
|
|
|
|
* @param textStr The unicode string used to create an iterator
|
2004-06-08 22:39:23 +00:00
|
|
|
* @param textPos The starting position of the iteration
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2000-11-29 01:32:34 +00:00
|
|
|
StringCharacterIterator(const UnicodeString& textStr,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t textPos);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2000-11-29 01:32:34 +00:00
|
|
|
* Create an iterator over the UnicodeString referred to by "textStr".
|
2000-04-12 19:36:30 +00:00
|
|
|
* The UnicodeString object is copied.
|
|
|
|
* The iteration range begins with the code unit specified by
|
2000-11-29 01:32:34 +00:00
|
|
|
* "textBegin" and ends with the code unit BEFORE the code unit specfied
|
|
|
|
* by "textEnd". The starting position is specified by "textPos". If
|
|
|
|
* "textBegin" and "textEnd" don't form a valid range on "text" (i.e.,
|
|
|
|
* textBegin >= textEnd or either is negative or greater than text.size()),
|
|
|
|
* or "textPos" is outside the range defined by "textBegin" and "textEnd",
|
2004-08-24 17:21:14 +00:00
|
|
|
* the behavior of this iterator is undefined.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param textStr The unicode string used to create the StringCharacterIterator
|
|
|
|
* @param textBegin The begin position of the iteration range
|
|
|
|
* @param textEnd The end position of the iteration range
|
|
|
|
* @param textPos The starting position of the iteration
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2000-11-29 01:32:34 +00:00
|
|
|
StringCharacterIterator(const UnicodeString& textStr,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t textBegin,
|
|
|
|
int32_t textEnd,
|
|
|
|
int32_t textPos);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy constructor. The new iterator iterates over the same range
|
|
|
|
* of the same string as "that", and its initial position is the
|
2004-08-24 17:21:14 +00:00
|
|
|
* same as "that"'s current position.
|
2000-04-12 19:36:30 +00:00
|
|
|
* The UnicodeString object in "that" is copied.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param that The StringCharacterIterator to be copied
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
StringCharacterIterator(const StringCharacterIterator& that);
|
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Destructor.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
virtual ~StringCharacterIterator();
|
|
|
|
|
|
|
|
/**
|
2000-04-12 19:36:30 +00:00
|
|
|
* Assignment operator. *this is altered to iterate over the same
|
1999-12-28 23:39:02 +00:00
|
|
|
* range of the same string as "that", and refers to the same
|
2002-07-03 12:05:56 +00:00
|
|
|
* character within that string as "that" does.
|
|
|
|
* @param that The object to be copied.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @return the newly created object.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
StringCharacterIterator&
|
|
|
|
operator=(const StringCharacterIterator& that);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns true if the iterators iterate over the same range of the
|
2004-08-24 17:21:14 +00:00
|
|
|
* same string and are pointing at the same character.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param that The ForwardCharacterIterator to be compared for equality
|
|
|
|
* @return true if the iterators iterate over the same range of the
|
2004-08-24 17:21:14 +00:00
|
|
|
* same string and are pointing at the same character.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2000-05-18 22:08:39 +00:00
|
|
|
virtual UBool operator==(const ForwardCharacterIterator& that) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a new StringCharacterIterator referring to the same
|
|
|
|
* character in the same range of the same string as this one. The
|
2004-08-24 17:21:14 +00:00
|
|
|
* caller must delete the new iterator.
|
|
|
|
* @return the newly cloned object.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
virtual CharacterIterator* clone(void) const;
|
2004-08-24 17:21:14 +00:00
|
|
|
|
2000-01-08 02:05:05 +00:00
|
|
|
/**
|
|
|
|
* Sets the iterator to iterate over the provided string.
|
2002-07-03 12:05:56 +00:00
|
|
|
* @param newText The string to be iterated over
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-01-08 02:05:05 +00:00
|
|
|
*/
|
2000-04-12 19:36:30 +00:00
|
|
|
void setText(const UnicodeString& newText);
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
/**
|
|
|
|
* Copies the UnicodeString under iteration into the UnicodeString
|
|
|
|
* referred to by "result". Even if this iterator iterates across
|
2000-04-20 23:02:20 +00:00
|
|
|
* only a part of this string, the whole string is copied.
|
2004-08-24 17:21:14 +00:00
|
|
|
* @param result Receives a copy of the text under iteration.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2004-03-30 22:39:45 +00:00
|
|
|
virtual void getText(UnicodeString& result);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Return a class ID for this object (not really public)
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return a class ID for this object.
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2003-02-06 22:57:35 +00:00
|
|
|
virtual UClassID getDynamicClassID(void) const;
|
1999-12-28 23:39:02 +00:00
|
|
|
|
|
|
|
/**
|
2004-08-24 17:21:14 +00:00
|
|
|
* Return a class ID for this class (not really public)
|
2002-07-03 12:05:56 +00:00
|
|
|
* @return a class ID for this class
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2000-03-22 18:31:40 +00:00
|
|
|
*/
|
2004-08-24 17:21:14 +00:00
|
|
|
static UClassID U_EXPORT2 getStaticClassID(void);
|
1999-12-28 23:39:02 +00:00
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
protected:
|
2002-12-11 22:49:18 +00:00
|
|
|
/**
|
|
|
|
* Default constructor, iteration over empty string.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
StringCharacterIterator();
|
2002-12-11 22:49:18 +00:00
|
|
|
|
|
|
|
/**
|
2002-07-03 12:05:56 +00:00
|
|
|
* Sets the iterator to iterate over the provided string.
|
|
|
|
* @param newText The string to be iterated over
|
|
|
|
* @param newTextLength The length of the String
|
2002-12-04 23:39:56 +00:00
|
|
|
* @stable ICU 2.0
|
2002-07-03 12:05:56 +00:00
|
|
|
*/
|
2000-04-12 19:36:30 +00:00
|
|
|
void setText(const UChar* newText, int32_t newTextLength);
|
2002-12-11 22:49:18 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Copy of the iterated string object.
|
|
|
|
* @stable ICU 2.0
|
|
|
|
*/
|
1999-12-28 23:39:02 +00:00
|
|
|
UnicodeString text;
|
2002-12-11 22:49:18 +00:00
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
};
|
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
1999-12-28 23:39:02 +00:00
|
|
|
#endif
|