1999-08-16 21:50:52 +00:00
|
|
|
/*
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
2010-05-19 17:29:33 +00:00
|
|
|
* Copyright (C) 1998-2010, International Business Machines Corporation and
|
|
|
|
* others. All Rights Reserved.
|
2001-03-21 20:44:20 +00:00
|
|
|
******************************************************************************
|
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
|
|
|
*/
|
|
|
|
|
2010-05-19 17:29:33 +00:00
|
|
|
#include <typeinfo> // for 'typeid' to work
|
|
|
|
|
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)
|
2007-09-28 04:50:25 +00:00
|
|
|
: UCharCharacterIterator(textStr.getBuffer(), textStr.length()),
|
2000-11-29 01:32:34 +00:00
|
|
|
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
|
2007-09-28 04:50:25 +00:00
|
|
|
UCharCharacterIterator::text = this->text.getBuffer();
|
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)
|
2007-09-28 04:50:25 +00:00
|
|
|
: UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textPos),
|
2000-11-29 01:32:34 +00:00
|
|
|
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
|
2007-09-28 04:50:25 +00:00
|
|
|
UCharCharacterIterator::text = this->text.getBuffer();
|
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)
|
2007-09-28 04:50:25 +00:00
|
|
|
: UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textBegin, textEnd, textPos),
|
2000-11-29 01:32:34 +00:00
|
|
|
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
|
2007-09-28 04:50:25 +00:00
|
|
|
UCharCharacterIterator::text = this->text.getBuffer();
|
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
|
2007-09-28 04:50:25 +00:00
|
|
|
UCharCharacterIterator::text = this->text.getBuffer();
|
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
|
2007-09-28 04:50:25 +00:00
|
|
|
UCharCharacterIterator::text = this->text.getBuffer();
|
2000-04-12 19:36:30 +00:00
|
|
|
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
|
|
|
|
2010-05-19 17:29:33 +00:00
|
|
|
if (typeid(*this) != typeid(that)) {
|
2000-04-12 19:36:30 +00:00
|
|
|
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;
|
2007-09-28 04:50:25 +00:00
|
|
|
UCharCharacterIterator::setText(text.getBuffer(), text.length());
|
2000-01-08 02:05:05 +00:00
|
|
|
}
|
|
|
|
|
1999-08-16 21:50:52 +00:00
|
|
|
void
|
2004-03-30 22:39:45 +00:00
|
|
|
StringCharacterIterator::getText(UnicodeString& result) {
|
2000-04-12 19:36:30 +00:00
|
|
|
result = text;
|
1999-08-16 21:50:52 +00:00
|
|
|
}
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|