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

116 lines
3.5 KiB
C++
Raw Normal View History

1999-08-16 21:50:52 +00:00
/*
******************************************************************************
* Copyright (C) 1998-2003, 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.
******************************************************************************
1999-08-16 21:50:52 +00:00
*/
#include "unicode/chariter.h"
#include "unicode/schriter.h"
1999-08-16 21:50:52 +00:00
U_NAMESPACE_BEGIN
1999-08-16 21:50:52 +00:00
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator)
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& textStr)
: UCharCharacterIterator(textStr.fArray, textStr.length()),
text(textStr)
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& textStr,
int32_t textPos)
: UCharCharacterIterator(textStr.fArray, textStr.length(), textPos),
text(textStr)
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& textStr,
int32_t textBegin,
int32_t textEnd,
int32_t textPos)
: UCharCharacterIterator(textStr.fArray, textStr.length(), textBegin, textEnd, textPos),
text(textStr)
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
}
UBool
StringCharacterIterator::operator==(const ForwardCharacterIterator& 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
}
U_NAMESPACE_END