1999-08-16 21:50:52 +00:00
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
2003-12-18 23:16:48 +00:00
|
|
|
* Copyright (C) 1998-2003, International Business Machines Corporation and *
|
2001-03-21 20:44:20 +00:00
|
|
|
* others. All Rights Reserved. *
|
|
|
|
******************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File schriter.cpp
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 05/05/99 stephen Cleaned up.
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*/
|
|
|
|
|
1999-12-28 23:39:02 +00:00
|
|
|
#include "unicode/chariter.h"
|
|
|
|
#include "unicode/schriter.h"
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2003-08-27 01:01:42 +00:00
|
|
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator)
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
StringCharacterIterator::StringCharacterIterator()
|
2000-04-12 19:36:30 +00:00
|
|
|
: UCharCharacterIterator(),
|
|
|
|
text()
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
|
|
|
// NEVER DEFAULT CONSTRUCT!
|
|
|
|
}
|
|
|
|
|
2000-11-29 01:32:34 +00:00
|
|
|
StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr)
|
|
|
|
: UCharCharacterIterator(textStr.fArray, textStr.length()),
|
|
|
|
text(textStr)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
2000-04-12 19:36:30 +00:00
|
|
|
// we had set the input parameter's array, now we need to set our copy's array
|
|
|
|
UCharCharacterIterator::text = this->text.fArray;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-11-29 01:32:34 +00:00
|
|
|
StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t textPos)
|
2000-11-29 01:32:34 +00:00
|
|
|
: UCharCharacterIterator(textStr.fArray, textStr.length(), textPos),
|
|
|
|
text(textStr)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
2000-04-12 19:36:30 +00:00
|
|
|
// we had set the input parameter's array, now we need to set our copy's array
|
|
|
|
UCharCharacterIterator::text = this->text.fArray;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-11-29 01:32:34 +00:00
|
|
|
StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr,
|
2002-03-12 01:32:42 +00:00
|
|
|
int32_t textBegin,
|
|
|
|
int32_t textEnd,
|
|
|
|
int32_t textPos)
|
2000-11-29 01:32:34 +00:00
|
|
|
: UCharCharacterIterator(textStr.fArray, textStr.length(), textBegin, textEnd, textPos),
|
|
|
|
text(textStr)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
2000-04-12 19:36:30 +00:00
|
|
|
// we had set the input parameter's array, now we need to set our copy's array
|
|
|
|
UCharCharacterIterator::text = this->text.fArray;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that)
|
|
|
|
: UCharCharacterIterator(that),
|
|
|
|
text(that.text)
|
1999-08-16 21:50:52 +00:00
|
|
|
{
|
2000-04-12 19:36:30 +00:00
|
|
|
// we had set the input parameter's array, now we need to set our copy's array
|
|
|
|
UCharCharacterIterator::text = this->text.fArray;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
StringCharacterIterator::~StringCharacterIterator() {
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
StringCharacterIterator&
|
|
|
|
StringCharacterIterator::operator=(const StringCharacterIterator& that) {
|
|
|
|
UCharCharacterIterator::operator=(that);
|
|
|
|
text = that.text;
|
|
|
|
// we had set the input parameter's array, now we need to set our copy's array
|
|
|
|
UCharCharacterIterator::text = this->text.fArray;
|
|
|
|
return *this;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool
|
2000-04-20 23:02:20 +00:00
|
|
|
StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const {
|
2000-04-12 19:36:30 +00:00
|
|
|
if (this == &that) {
|
|
|
|
return TRUE;
|
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
// do not call UCharCharacterIterator::operator==()
|
|
|
|
// because that checks for array pointer equality
|
|
|
|
// while we compare UnicodeString objects
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
if (getDynamicClassID() != that.getDynamicClassID()) {
|
|
|
|
return FALSE;
|
|
|
|
}
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
StringCharacterIterator& realThat = (StringCharacterIterator&)that;
|
1999-08-16 21:50:52 +00:00
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
return text == realThat.text
|
|
|
|
&& pos == realThat.pos
|
|
|
|
&& begin == realThat.begin
|
|
|
|
&& end == realThat.end;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-04-12 19:36:30 +00:00
|
|
|
CharacterIterator*
|
|
|
|
StringCharacterIterator::clone() const {
|
|
|
|
return new StringCharacterIterator(*this);
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
|
|
|
|
2000-01-08 02:05:05 +00:00
|
|
|
void
|
2000-04-12 19:36:30 +00:00
|
|
|
StringCharacterIterator::setText(const UnicodeString& newText) {
|
2000-01-08 02:05:05 +00:00
|
|
|
text = newText;
|
2000-04-12 19:36:30 +00:00
|
|
|
UCharCharacterIterator::setText(text.fArray, text.length());
|
2000-01-08 02:05:05 +00:00
|
|
|
}
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void
|
2000-04-12 19:36:30 +00:00
|
|
|
StringCharacterIterator::getText(UnicodeString& result) {
|
|
|
|
result = text;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|