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