Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * |
michael@0 | 4 | * Copyright (C) 1998-2005, International Business Machines |
michael@0 | 5 | * Corporation and others. All Rights Reserved. |
michael@0 | 6 | * |
michael@0 | 7 | ****************************************************************************** |
michael@0 | 8 | * |
michael@0 | 9 | * File schriter.h |
michael@0 | 10 | * |
michael@0 | 11 | * Modification History: |
michael@0 | 12 | * |
michael@0 | 13 | * Date Name Description |
michael@0 | 14 | * 05/05/99 stephen Cleaned up. |
michael@0 | 15 | ****************************************************************************** |
michael@0 | 16 | */ |
michael@0 | 17 | |
michael@0 | 18 | #ifndef SCHRITER_H |
michael@0 | 19 | #define SCHRITER_H |
michael@0 | 20 | |
michael@0 | 21 | #include "unicode/utypes.h" |
michael@0 | 22 | #include "unicode/chariter.h" |
michael@0 | 23 | #include "unicode/uchriter.h" |
michael@0 | 24 | |
michael@0 | 25 | /** |
michael@0 | 26 | * \file |
michael@0 | 27 | * \brief C++ API: String Character Iterator |
michael@0 | 28 | */ |
michael@0 | 29 | |
michael@0 | 30 | U_NAMESPACE_BEGIN |
michael@0 | 31 | /** |
michael@0 | 32 | * A concrete subclass of CharacterIterator that iterates over the |
michael@0 | 33 | * characters (code units or code points) in a UnicodeString. |
michael@0 | 34 | * It's possible not only to create an |
michael@0 | 35 | * iterator that iterates over an entire UnicodeString, but also to |
michael@0 | 36 | * create one that iterates over only a subrange of a UnicodeString |
michael@0 | 37 | * (iterators over different subranges of the same UnicodeString don't |
michael@0 | 38 | * compare equal). |
michael@0 | 39 | * @see CharacterIterator |
michael@0 | 40 | * @see ForwardCharacterIterator |
michael@0 | 41 | * @stable ICU 2.0 |
michael@0 | 42 | */ |
michael@0 | 43 | class U_COMMON_API StringCharacterIterator : public UCharCharacterIterator { |
michael@0 | 44 | public: |
michael@0 | 45 | /** |
michael@0 | 46 | * Create an iterator over the UnicodeString referred to by "textStr". |
michael@0 | 47 | * The UnicodeString object is copied. |
michael@0 | 48 | * The iteration range is the whole string, and the starting position is 0. |
michael@0 | 49 | * @param textStr The unicode string used to create an iterator |
michael@0 | 50 | * @stable ICU 2.0 |
michael@0 | 51 | */ |
michael@0 | 52 | StringCharacterIterator(const UnicodeString& textStr); |
michael@0 | 53 | |
michael@0 | 54 | /** |
michael@0 | 55 | * Create an iterator over the UnicodeString referred to by "textStr". |
michael@0 | 56 | * The iteration range is the whole string, and the starting |
michael@0 | 57 | * position is specified by "textPos". If "textPos" is outside the valid |
michael@0 | 58 | * iteration range, the behavior of this object is undefined. |
michael@0 | 59 | * @param textStr The unicode string used to create an iterator |
michael@0 | 60 | * @param textPos The starting position of the iteration |
michael@0 | 61 | * @stable ICU 2.0 |
michael@0 | 62 | */ |
michael@0 | 63 | StringCharacterIterator(const UnicodeString& textStr, |
michael@0 | 64 | int32_t textPos); |
michael@0 | 65 | |
michael@0 | 66 | /** |
michael@0 | 67 | * Create an iterator over the UnicodeString referred to by "textStr". |
michael@0 | 68 | * The UnicodeString object is copied. |
michael@0 | 69 | * The iteration range begins with the code unit specified by |
michael@0 | 70 | * "textBegin" and ends with the code unit BEFORE the code unit specfied |
michael@0 | 71 | * by "textEnd". The starting position is specified by "textPos". If |
michael@0 | 72 | * "textBegin" and "textEnd" don't form a valid range on "text" (i.e., |
michael@0 | 73 | * textBegin >= textEnd or either is negative or greater than text.size()), |
michael@0 | 74 | * or "textPos" is outside the range defined by "textBegin" and "textEnd", |
michael@0 | 75 | * the behavior of this iterator is undefined. |
michael@0 | 76 | * @param textStr The unicode string used to create the StringCharacterIterator |
michael@0 | 77 | * @param textBegin The begin position of the iteration range |
michael@0 | 78 | * @param textEnd The end position of the iteration range |
michael@0 | 79 | * @param textPos The starting position of the iteration |
michael@0 | 80 | * @stable ICU 2.0 |
michael@0 | 81 | */ |
michael@0 | 82 | StringCharacterIterator(const UnicodeString& textStr, |
michael@0 | 83 | int32_t textBegin, |
michael@0 | 84 | int32_t textEnd, |
michael@0 | 85 | int32_t textPos); |
michael@0 | 86 | |
michael@0 | 87 | /** |
michael@0 | 88 | * Copy constructor. The new iterator iterates over the same range |
michael@0 | 89 | * of the same string as "that", and its initial position is the |
michael@0 | 90 | * same as "that"'s current position. |
michael@0 | 91 | * The UnicodeString object in "that" is copied. |
michael@0 | 92 | * @param that The StringCharacterIterator to be copied |
michael@0 | 93 | * @stable ICU 2.0 |
michael@0 | 94 | */ |
michael@0 | 95 | StringCharacterIterator(const StringCharacterIterator& that); |
michael@0 | 96 | |
michael@0 | 97 | /** |
michael@0 | 98 | * Destructor. |
michael@0 | 99 | * @stable ICU 2.0 |
michael@0 | 100 | */ |
michael@0 | 101 | virtual ~StringCharacterIterator(); |
michael@0 | 102 | |
michael@0 | 103 | /** |
michael@0 | 104 | * Assignment operator. *this is altered to iterate over the same |
michael@0 | 105 | * range of the same string as "that", and refers to the same |
michael@0 | 106 | * character within that string as "that" does. |
michael@0 | 107 | * @param that The object to be copied. |
michael@0 | 108 | * @return the newly created object. |
michael@0 | 109 | * @stable ICU 2.0 |
michael@0 | 110 | */ |
michael@0 | 111 | StringCharacterIterator& |
michael@0 | 112 | operator=(const StringCharacterIterator& that); |
michael@0 | 113 | |
michael@0 | 114 | /** |
michael@0 | 115 | * Returns true if the iterators iterate over the same range of the |
michael@0 | 116 | * same string and are pointing at the same character. |
michael@0 | 117 | * @param that The ForwardCharacterIterator to be compared for equality |
michael@0 | 118 | * @return true if the iterators iterate over the same range of the |
michael@0 | 119 | * same string and are pointing at the same character. |
michael@0 | 120 | * @stable ICU 2.0 |
michael@0 | 121 | */ |
michael@0 | 122 | virtual UBool operator==(const ForwardCharacterIterator& that) const; |
michael@0 | 123 | |
michael@0 | 124 | /** |
michael@0 | 125 | * Returns a new StringCharacterIterator referring to the same |
michael@0 | 126 | * character in the same range of the same string as this one. The |
michael@0 | 127 | * caller must delete the new iterator. |
michael@0 | 128 | * @return the newly cloned object. |
michael@0 | 129 | * @stable ICU 2.0 |
michael@0 | 130 | */ |
michael@0 | 131 | virtual CharacterIterator* clone(void) const; |
michael@0 | 132 | |
michael@0 | 133 | /** |
michael@0 | 134 | * Sets the iterator to iterate over the provided string. |
michael@0 | 135 | * @param newText The string to be iterated over |
michael@0 | 136 | * @stable ICU 2.0 |
michael@0 | 137 | */ |
michael@0 | 138 | void setText(const UnicodeString& newText); |
michael@0 | 139 | |
michael@0 | 140 | /** |
michael@0 | 141 | * Copies the UnicodeString under iteration into the UnicodeString |
michael@0 | 142 | * referred to by "result". Even if this iterator iterates across |
michael@0 | 143 | * only a part of this string, the whole string is copied. |
michael@0 | 144 | * @param result Receives a copy of the text under iteration. |
michael@0 | 145 | * @stable ICU 2.0 |
michael@0 | 146 | */ |
michael@0 | 147 | virtual void getText(UnicodeString& result); |
michael@0 | 148 | |
michael@0 | 149 | /** |
michael@0 | 150 | * Return a class ID for this object (not really public) |
michael@0 | 151 | * @return a class ID for this object. |
michael@0 | 152 | * @stable ICU 2.0 |
michael@0 | 153 | */ |
michael@0 | 154 | virtual UClassID getDynamicClassID(void) const; |
michael@0 | 155 | |
michael@0 | 156 | /** |
michael@0 | 157 | * Return a class ID for this class (not really public) |
michael@0 | 158 | * @return a class ID for this class |
michael@0 | 159 | * @stable ICU 2.0 |
michael@0 | 160 | */ |
michael@0 | 161 | static UClassID U_EXPORT2 getStaticClassID(void); |
michael@0 | 162 | |
michael@0 | 163 | protected: |
michael@0 | 164 | /** |
michael@0 | 165 | * Default constructor, iteration over empty string. |
michael@0 | 166 | * @stable ICU 2.0 |
michael@0 | 167 | */ |
michael@0 | 168 | StringCharacterIterator(); |
michael@0 | 169 | |
michael@0 | 170 | /** |
michael@0 | 171 | * Sets the iterator to iterate over the provided string. |
michael@0 | 172 | * @param newText The string to be iterated over |
michael@0 | 173 | * @param newTextLength The length of the String |
michael@0 | 174 | * @stable ICU 2.0 |
michael@0 | 175 | */ |
michael@0 | 176 | void setText(const UChar* newText, int32_t newTextLength); |
michael@0 | 177 | |
michael@0 | 178 | /** |
michael@0 | 179 | * Copy of the iterated string object. |
michael@0 | 180 | * @stable ICU 2.0 |
michael@0 | 181 | */ |
michael@0 | 182 | UnicodeString text; |
michael@0 | 183 | |
michael@0 | 184 | }; |
michael@0 | 185 | |
michael@0 | 186 | U_NAMESPACE_END |
michael@0 | 187 | #endif |