1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/unicode/schriter.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,187 @@ 1.4 +/* 1.5 +****************************************************************************** 1.6 +* 1.7 +* Copyright (C) 1998-2005, International Business Machines 1.8 +* Corporation and others. All Rights Reserved. 1.9 +* 1.10 +****************************************************************************** 1.11 +* 1.12 +* File schriter.h 1.13 +* 1.14 +* Modification History: 1.15 +* 1.16 +* Date Name Description 1.17 +* 05/05/99 stephen Cleaned up. 1.18 +****************************************************************************** 1.19 +*/ 1.20 + 1.21 +#ifndef SCHRITER_H 1.22 +#define SCHRITER_H 1.23 + 1.24 +#include "unicode/utypes.h" 1.25 +#include "unicode/chariter.h" 1.26 +#include "unicode/uchriter.h" 1.27 + 1.28 +/** 1.29 + * \file 1.30 + * \brief C++ API: String Character Iterator 1.31 + */ 1.32 + 1.33 +U_NAMESPACE_BEGIN 1.34 +/** 1.35 + * A concrete subclass of CharacterIterator that iterates over the 1.36 + * characters (code units or code points) in a UnicodeString. 1.37 + * It's possible not only to create an 1.38 + * iterator that iterates over an entire UnicodeString, but also to 1.39 + * create one that iterates over only a subrange of a UnicodeString 1.40 + * (iterators over different subranges of the same UnicodeString don't 1.41 + * compare equal). 1.42 + * @see CharacterIterator 1.43 + * @see ForwardCharacterIterator 1.44 + * @stable ICU 2.0 1.45 + */ 1.46 +class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator { 1.47 +public: 1.48 + /** 1.49 + * Create an iterator over the UnicodeString referred to by "textStr". 1.50 + * The UnicodeString object is copied. 1.51 + * The iteration range is the whole string, and the starting position is 0. 1.52 + * @param textStr The unicode string used to create an iterator 1.53 + * @stable ICU 2.0 1.54 + */ 1.55 + StringCharacterIterator(const UnicodeString& textStr); 1.56 + 1.57 + /** 1.58 + * Create an iterator over the UnicodeString referred to by "textStr". 1.59 + * The iteration range is the whole string, and the starting 1.60 + * position is specified by "textPos". If "textPos" is outside the valid 1.61 + * iteration range, the behavior of this object is undefined. 1.62 + * @param textStr The unicode string used to create an iterator 1.63 + * @param textPos The starting position of the iteration 1.64 + * @stable ICU 2.0 1.65 + */ 1.66 + StringCharacterIterator(const UnicodeString& textStr, 1.67 + int32_t textPos); 1.68 + 1.69 + /** 1.70 + * Create an iterator over the UnicodeString referred to by "textStr". 1.71 + * The UnicodeString object is copied. 1.72 + * The iteration range begins with the code unit specified by 1.73 + * "textBegin" and ends with the code unit BEFORE the code unit specfied 1.74 + * by "textEnd". The starting position is specified by "textPos". If 1.75 + * "textBegin" and "textEnd" don't form a valid range on "text" (i.e., 1.76 + * textBegin >= textEnd or either is negative or greater than text.size()), 1.77 + * or "textPos" is outside the range defined by "textBegin" and "textEnd", 1.78 + * the behavior of this iterator is undefined. 1.79 + * @param textStr The unicode string used to create the StringCharacterIterator 1.80 + * @param textBegin The begin position of the iteration range 1.81 + * @param textEnd The end position of the iteration range 1.82 + * @param textPos The starting position of the iteration 1.83 + * @stable ICU 2.0 1.84 + */ 1.85 + StringCharacterIterator(const UnicodeString& textStr, 1.86 + int32_t textBegin, 1.87 + int32_t textEnd, 1.88 + int32_t textPos); 1.89 + 1.90 + /** 1.91 + * Copy constructor. The new iterator iterates over the same range 1.92 + * of the same string as "that", and its initial position is the 1.93 + * same as "that"'s current position. 1.94 + * The UnicodeString object in "that" is copied. 1.95 + * @param that The StringCharacterIterator to be copied 1.96 + * @stable ICU 2.0 1.97 + */ 1.98 + StringCharacterIterator(const StringCharacterIterator& that); 1.99 + 1.100 + /** 1.101 + * Destructor. 1.102 + * @stable ICU 2.0 1.103 + */ 1.104 + virtual ~StringCharacterIterator(); 1.105 + 1.106 + /** 1.107 + * Assignment operator. *this is altered to iterate over the same 1.108 + * range of the same string as "that", and refers to the same 1.109 + * character within that string as "that" does. 1.110 + * @param that The object to be copied. 1.111 + * @return the newly created object. 1.112 + * @stable ICU 2.0 1.113 + */ 1.114 + StringCharacterIterator& 1.115 + operator=(const StringCharacterIterator& that); 1.116 + 1.117 + /** 1.118 + * Returns true if the iterators iterate over the same range of the 1.119 + * same string and are pointing at the same character. 1.120 + * @param that The ForwardCharacterIterator to be compared for equality 1.121 + * @return true if the iterators iterate over the same range of the 1.122 + * same string and are pointing at the same character. 1.123 + * @stable ICU 2.0 1.124 + */ 1.125 + virtual UBool operator==(const ForwardCharacterIterator& that) const; 1.126 + 1.127 + /** 1.128 + * Returns a new StringCharacterIterator referring to the same 1.129 + * character in the same range of the same string as this one. The 1.130 + * caller must delete the new iterator. 1.131 + * @return the newly cloned object. 1.132 + * @stable ICU 2.0 1.133 + */ 1.134 + virtual CharacterIterator* clone(void) const; 1.135 + 1.136 + /** 1.137 + * Sets the iterator to iterate over the provided string. 1.138 + * @param newText The string to be iterated over 1.139 + * @stable ICU 2.0 1.140 + */ 1.141 + void setText(const UnicodeString& newText); 1.142 + 1.143 + /** 1.144 + * Copies the UnicodeString under iteration into the UnicodeString 1.145 + * referred to by "result". Even if this iterator iterates across 1.146 + * only a part of this string, the whole string is copied. 1.147 + * @param result Receives a copy of the text under iteration. 1.148 + * @stable ICU 2.0 1.149 + */ 1.150 + virtual void getText(UnicodeString& result); 1.151 + 1.152 + /** 1.153 + * Return a class ID for this object (not really public) 1.154 + * @return a class ID for this object. 1.155 + * @stable ICU 2.0 1.156 + */ 1.157 + virtual UClassID getDynamicClassID(void) const; 1.158 + 1.159 + /** 1.160 + * Return a class ID for this class (not really public) 1.161 + * @return a class ID for this class 1.162 + * @stable ICU 2.0 1.163 + */ 1.164 + static UClassID U_EXPORT2 getStaticClassID(void); 1.165 + 1.166 +protected: 1.167 + /** 1.168 + * Default constructor, iteration over empty string. 1.169 + * @stable ICU 2.0 1.170 + */ 1.171 + StringCharacterIterator(); 1.172 + 1.173 + /** 1.174 + * Sets the iterator to iterate over the provided string. 1.175 + * @param newText The string to be iterated over 1.176 + * @param newTextLength The length of the String 1.177 + * @stable ICU 2.0 1.178 + */ 1.179 + void setText(const UChar* newText, int32_t newTextLength); 1.180 + 1.181 + /** 1.182 + * Copy of the iterated string object. 1.183 + * @stable ICU 2.0 1.184 + */ 1.185 + UnicodeString text; 1.186 + 1.187 +}; 1.188 + 1.189 +U_NAMESPACE_END 1.190 +#endif