]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
b75a7d8f A |
3 | /* |
4 | ****************************************************************************** | |
51004dcb | 5 | * Copyright (C) 1998-2012, International Business Machines Corporation and |
729e4ab9 | 6 | * others. All Rights Reserved. |
b75a7d8f A |
7 | ****************************************************************************** |
8 | * | |
9 | * File schriter.cpp | |
10 | * | |
11 | * Modification History: | |
12 | * | |
13 | * Date Name Description | |
14 | * 05/05/99 stephen Cleaned up. | |
15 | ****************************************************************************** | |
16 | */ | |
17 | ||
51004dcb | 18 | #include "utypeinfo.h" // for 'typeid' to work |
729e4ab9 | 19 | |
b75a7d8f A |
20 | #include "unicode/chariter.h" |
21 | #include "unicode/schriter.h" | |
22 | ||
23 | U_NAMESPACE_BEGIN | |
24 | ||
374ca955 | 25 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator) |
b75a7d8f A |
26 | |
27 | StringCharacterIterator::StringCharacterIterator() | |
28 | : UCharCharacterIterator(), | |
29 | text() | |
30 | { | |
31 | // NEVER DEFAULT CONSTRUCT! | |
32 | } | |
33 | ||
34 | StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr) | |
46f4442e | 35 | : UCharCharacterIterator(textStr.getBuffer(), textStr.length()), |
b75a7d8f A |
36 | text(textStr) |
37 | { | |
38 | // we had set the input parameter's array, now we need to set our copy's array | |
46f4442e | 39 | UCharCharacterIterator::text = this->text.getBuffer(); |
b75a7d8f A |
40 | } |
41 | ||
42 | StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, | |
43 | int32_t textPos) | |
46f4442e | 44 | : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textPos), |
b75a7d8f A |
45 | text(textStr) |
46 | { | |
47 | // we had set the input parameter's array, now we need to set our copy's array | |
46f4442e | 48 | UCharCharacterIterator::text = this->text.getBuffer(); |
b75a7d8f A |
49 | } |
50 | ||
51 | StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, | |
52 | int32_t textBegin, | |
53 | int32_t textEnd, | |
54 | int32_t textPos) | |
46f4442e | 55 | : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textBegin, textEnd, textPos), |
b75a7d8f A |
56 | text(textStr) |
57 | { | |
58 | // we had set the input parameter's array, now we need to set our copy's array | |
46f4442e | 59 | UCharCharacterIterator::text = this->text.getBuffer(); |
b75a7d8f A |
60 | } |
61 | ||
62 | StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that) | |
63 | : UCharCharacterIterator(that), | |
64 | text(that.text) | |
65 | { | |
66 | // we had set the input parameter's array, now we need to set our copy's array | |
46f4442e | 67 | UCharCharacterIterator::text = this->text.getBuffer(); |
b75a7d8f A |
68 | } |
69 | ||
70 | StringCharacterIterator::~StringCharacterIterator() { | |
71 | } | |
72 | ||
73 | StringCharacterIterator& | |
74 | StringCharacterIterator::operator=(const StringCharacterIterator& that) { | |
75 | UCharCharacterIterator::operator=(that); | |
76 | text = that.text; | |
77 | // we had set the input parameter's array, now we need to set our copy's array | |
46f4442e | 78 | UCharCharacterIterator::text = this->text.getBuffer(); |
b75a7d8f A |
79 | return *this; |
80 | } | |
81 | ||
82 | UBool | |
83 | StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const { | |
84 | if (this == &that) { | |
85 | return TRUE; | |
86 | } | |
87 | ||
88 | // do not call UCharCharacterIterator::operator==() | |
89 | // because that checks for array pointer equality | |
90 | // while we compare UnicodeString objects | |
91 | ||
729e4ab9 | 92 | if (typeid(*this) != typeid(that)) { |
b75a7d8f A |
93 | return FALSE; |
94 | } | |
95 | ||
96 | StringCharacterIterator& realThat = (StringCharacterIterator&)that; | |
97 | ||
98 | return text == realThat.text | |
99 | && pos == realThat.pos | |
100 | && begin == realThat.begin | |
101 | && end == realThat.end; | |
102 | } | |
103 | ||
340931cb | 104 | StringCharacterIterator* |
b75a7d8f A |
105 | StringCharacterIterator::clone() const { |
106 | return new StringCharacterIterator(*this); | |
107 | } | |
108 | ||
109 | void | |
110 | StringCharacterIterator::setText(const UnicodeString& newText) { | |
111 | text = newText; | |
46f4442e | 112 | UCharCharacterIterator::setText(text.getBuffer(), text.length()); |
b75a7d8f A |
113 | } |
114 | ||
115 | void | |
116 | StringCharacterIterator::getText(UnicodeString& result) { | |
117 | result = text; | |
118 | } | |
119 | U_NAMESPACE_END |