]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/schriter.cpp
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ******************************************************************************
5 * Copyright (C) 1998-2012, International Business Machines Corporation and
6 * others. All Rights Reserved.
7 ******************************************************************************
11 * Modification History:
13 * Date Name Description
14 * 05/05/99 stephen Cleaned up.
15 ******************************************************************************
18 #include "utypeinfo.h" // for 'typeid' to work
20 #include "unicode/chariter.h"
21 #include "unicode/schriter.h"
25 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator
)
27 StringCharacterIterator::StringCharacterIterator()
28 : UCharCharacterIterator(),
31 // NEVER DEFAULT CONSTRUCT!
34 StringCharacterIterator::StringCharacterIterator(const UnicodeString
& textStr
)
35 : UCharCharacterIterator(textStr
.getBuffer(), textStr
.length()),
38 // we had set the input parameter's array, now we need to set our copy's array
39 UCharCharacterIterator::text
= this->text
.getBuffer();
42 StringCharacterIterator::StringCharacterIterator(const UnicodeString
& textStr
,
44 : UCharCharacterIterator(textStr
.getBuffer(), textStr
.length(), textPos
),
47 // we had set the input parameter's array, now we need to set our copy's array
48 UCharCharacterIterator::text
= this->text
.getBuffer();
51 StringCharacterIterator::StringCharacterIterator(const UnicodeString
& textStr
,
55 : UCharCharacterIterator(textStr
.getBuffer(), textStr
.length(), textBegin
, textEnd
, textPos
),
58 // we had set the input parameter's array, now we need to set our copy's array
59 UCharCharacterIterator::text
= this->text
.getBuffer();
62 StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator
& that
)
63 : UCharCharacterIterator(that
),
66 // we had set the input parameter's array, now we need to set our copy's array
67 UCharCharacterIterator::text
= this->text
.getBuffer();
70 StringCharacterIterator::~StringCharacterIterator() {
73 StringCharacterIterator
&
74 StringCharacterIterator::operator=(const StringCharacterIterator
& that
) {
75 UCharCharacterIterator::operator=(that
);
77 // we had set the input parameter's array, now we need to set our copy's array
78 UCharCharacterIterator::text
= this->text
.getBuffer();
83 StringCharacterIterator::operator==(const ForwardCharacterIterator
& that
) const {
88 // do not call UCharCharacterIterator::operator==()
89 // because that checks for array pointer equality
90 // while we compare UnicodeString objects
92 if (typeid(*this) != typeid(that
)) {
96 StringCharacterIterator
& realThat
= (StringCharacterIterator
&)that
;
98 return text
== realThat
.text
99 && pos
== realThat
.pos
100 && begin
== realThat
.begin
101 && end
== realThat
.end
;
105 StringCharacterIterator::clone() const {
106 return new StringCharacterIterator(*this);
110 StringCharacterIterator::setText(const UnicodeString
& newText
) {
112 UCharCharacterIterator::setText(text
.getBuffer(), text
.length());
116 StringCharacterIterator::getText(UnicodeString
& result
) {