Line data Source code
1 : // © 2016 and later: Unicode, Inc. and others.
2 : // License & terms of use: http://www.unicode.org/copyright.html
3 : /*
4 : ******************************************************************************
5 : * Copyright (C) 1998-2012, International Business Machines Corporation and
6 : * others. All Rights Reserved.
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 :
18 : #include "utypeinfo.h" // for 'typeid' to work
19 :
20 : #include "unicode/chariter.h"
21 : #include "unicode/schriter.h"
22 :
23 : U_NAMESPACE_BEGIN
24 :
25 0 : UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator)
26 :
27 0 : StringCharacterIterator::StringCharacterIterator()
28 : : UCharCharacterIterator(),
29 0 : text()
30 : {
31 : // NEVER DEFAULT CONSTRUCT!
32 0 : }
33 :
34 0 : StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr)
35 : : UCharCharacterIterator(textStr.getBuffer(), textStr.length()),
36 0 : text(textStr)
37 : {
38 : // we had set the input parameter's array, now we need to set our copy's array
39 0 : UCharCharacterIterator::text = this->text.getBuffer();
40 0 : }
41 :
42 0 : StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr,
43 0 : int32_t textPos)
44 : : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textPos),
45 0 : text(textStr)
46 : {
47 : // we had set the input parameter's array, now we need to set our copy's array
48 0 : UCharCharacterIterator::text = this->text.getBuffer();
49 0 : }
50 :
51 0 : StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr,
52 : int32_t textBegin,
53 : int32_t textEnd,
54 0 : int32_t textPos)
55 : : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textBegin, textEnd, textPos),
56 0 : text(textStr)
57 : {
58 : // we had set the input parameter's array, now we need to set our copy's array
59 0 : UCharCharacterIterator::text = this->text.getBuffer();
60 0 : }
61 :
62 0 : StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that)
63 : : UCharCharacterIterator(that),
64 0 : text(that.text)
65 : {
66 : // we had set the input parameter's array, now we need to set our copy's array
67 0 : UCharCharacterIterator::text = this->text.getBuffer();
68 0 : }
69 :
70 0 : StringCharacterIterator::~StringCharacterIterator() {
71 0 : }
72 :
73 : StringCharacterIterator&
74 0 : StringCharacterIterator::operator=(const StringCharacterIterator& that) {
75 0 : UCharCharacterIterator::operator=(that);
76 0 : text = that.text;
77 : // we had set the input parameter's array, now we need to set our copy's array
78 0 : UCharCharacterIterator::text = this->text.getBuffer();
79 0 : return *this;
80 : }
81 :
82 : UBool
83 0 : StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const {
84 0 : if (this == &that) {
85 0 : 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 :
92 0 : if (typeid(*this) != typeid(that)) {
93 0 : return FALSE;
94 : }
95 :
96 0 : StringCharacterIterator& realThat = (StringCharacterIterator&)that;
97 :
98 0 : return text == realThat.text
99 0 : && pos == realThat.pos
100 0 : && begin == realThat.begin
101 0 : && end == realThat.end;
102 : }
103 :
104 : CharacterIterator*
105 0 : StringCharacterIterator::clone() const {
106 0 : return new StringCharacterIterator(*this);
107 : }
108 :
109 : void
110 0 : StringCharacterIterator::setText(const UnicodeString& newText) {
111 0 : text = newText;
112 0 : UCharCharacterIterator::setText(text.getBuffer(), text.length());
113 0 : }
114 :
115 : void
116 0 : StringCharacterIterator::getText(UnicodeString& result) {
117 0 : result = text;
118 0 : }
119 : U_NAMESPACE_END
|