scuffed-code/icu4c/source/common/schriter.cpp

114 lines
3.5 KiB
C++
Raw Normal View History

1999-08-16 21:50:52 +00:00
/*
*******************************************************************************
* Copyright (C) 1998-1999, International Business Machines Corporation and *
* 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.
*******************************************************************************
*/
#include "unicode/chariter.h"
#include "unicode/schriter.h"
1999-08-16 21:50:52 +00:00
UClassID StringCharacterIterator::fgClassID = 0;
1999-08-16 21:50:52 +00:00
StringCharacterIterator::StringCharacterIterator()
: UCharCharacterIterator(),
text()
1999-08-16 21:50:52 +00:00
{
// NEVER DEFAULT CONSTRUCT!
}
StringCharacterIterator::StringCharacterIterator(const UnicodeString& text)
: UCharCharacterIterator(text.fArray, text.length()),
text(text)
1999-08-16 21:50:52 +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
}
StringCharacterIterator::StringCharacterIterator(const UnicodeString& text,
UTextOffset pos)
: UCharCharacterIterator(text.fArray, text.length(), pos),
text(text)
1999-08-16 21:50:52 +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
}
StringCharacterIterator::StringCharacterIterator(const UnicodeString& text,
UTextOffset begin,
UTextOffset end,
UTextOffset pos)
: UCharCharacterIterator(text.fArray, text.length(), begin, end, pos),
text(text)
1999-08-16 21:50:52 +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
}
StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that)
: UCharCharacterIterator(that),
text(that.text)
1999-08-16 21:50:52 +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
}
StringCharacterIterator::~StringCharacterIterator() {
1999-08-16 21:50:52 +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
}
bool_t
StringCharacterIterator::operator==(const CharacterIterator& that) const {
if (this == &that) {
return TRUE;
}
1999-08-16 21:50:52 +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
if (getDynamicClassID() != that.getDynamicClassID()) {
return FALSE;
}
1999-08-16 21:50:52 +00:00
StringCharacterIterator& realThat = (StringCharacterIterator&)that;
1999-08-16 21:50:52 +00:00
return text == realThat.text
&& pos == realThat.pos
&& begin == realThat.begin
&& end == realThat.end;
1999-08-16 21:50:52 +00:00
}
CharacterIterator*
StringCharacterIterator::clone() const {
return new StringCharacterIterator(*this);
1999-08-16 21:50:52 +00:00
}
void
StringCharacterIterator::setText(const UnicodeString& newText) {
text = newText;
UCharCharacterIterator::setText(text.fArray, text.length());
}
1999-08-16 21:50:52 +00:00
void
StringCharacterIterator::getText(UnicodeString& result) {
result = text;
1999-08-16 21:50:52 +00:00
}