michael@0: /* michael@0: ****************************************************************************** michael@0: * Copyright (C) 1998-2012, International Business Machines Corporation and michael@0: * others. All Rights Reserved. michael@0: ****************************************************************************** michael@0: * michael@0: * File schriter.cpp michael@0: * michael@0: * Modification History: michael@0: * michael@0: * Date Name Description michael@0: * 05/05/99 stephen Cleaned up. michael@0: ****************************************************************************** michael@0: */ michael@0: michael@0: #include "utypeinfo.h" // for 'typeid' to work michael@0: michael@0: #include "unicode/chariter.h" michael@0: #include "unicode/schriter.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator) michael@0: michael@0: StringCharacterIterator::StringCharacterIterator() michael@0: : UCharCharacterIterator(), michael@0: text() michael@0: { michael@0: // NEVER DEFAULT CONSTRUCT! michael@0: } michael@0: michael@0: StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr) michael@0: : UCharCharacterIterator(textStr.getBuffer(), textStr.length()), michael@0: text(textStr) michael@0: { michael@0: // we had set the input parameter's array, now we need to set our copy's array michael@0: UCharCharacterIterator::text = this->text.getBuffer(); michael@0: } michael@0: michael@0: StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, michael@0: int32_t textPos) michael@0: : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textPos), michael@0: text(textStr) michael@0: { michael@0: // we had set the input parameter's array, now we need to set our copy's array michael@0: UCharCharacterIterator::text = this->text.getBuffer(); michael@0: } michael@0: michael@0: StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, michael@0: int32_t textBegin, michael@0: int32_t textEnd, michael@0: int32_t textPos) michael@0: : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textBegin, textEnd, textPos), michael@0: text(textStr) michael@0: { michael@0: // we had set the input parameter's array, now we need to set our copy's array michael@0: UCharCharacterIterator::text = this->text.getBuffer(); michael@0: } michael@0: michael@0: StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that) michael@0: : UCharCharacterIterator(that), michael@0: text(that.text) michael@0: { michael@0: // we had set the input parameter's array, now we need to set our copy's array michael@0: UCharCharacterIterator::text = this->text.getBuffer(); michael@0: } michael@0: michael@0: StringCharacterIterator::~StringCharacterIterator() { michael@0: } michael@0: michael@0: StringCharacterIterator& michael@0: StringCharacterIterator::operator=(const StringCharacterIterator& that) { michael@0: UCharCharacterIterator::operator=(that); michael@0: text = that.text; michael@0: // we had set the input parameter's array, now we need to set our copy's array michael@0: UCharCharacterIterator::text = this->text.getBuffer(); michael@0: return *this; michael@0: } michael@0: michael@0: UBool michael@0: StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const { michael@0: if (this == &that) { michael@0: return TRUE; michael@0: } michael@0: michael@0: // do not call UCharCharacterIterator::operator==() michael@0: // because that checks for array pointer equality michael@0: // while we compare UnicodeString objects michael@0: michael@0: if (typeid(*this) != typeid(that)) { michael@0: return FALSE; michael@0: } michael@0: michael@0: StringCharacterIterator& realThat = (StringCharacterIterator&)that; michael@0: michael@0: return text == realThat.text michael@0: && pos == realThat.pos michael@0: && begin == realThat.begin michael@0: && end == realThat.end; michael@0: } michael@0: michael@0: CharacterIterator* michael@0: StringCharacterIterator::clone() const { michael@0: return new StringCharacterIterator(*this); michael@0: } michael@0: michael@0: void michael@0: StringCharacterIterator::setText(const UnicodeString& newText) { michael@0: text = newText; michael@0: UCharCharacterIterator::setText(text.getBuffer(), text.length()); michael@0: } michael@0: michael@0: void michael@0: StringCharacterIterator::getText(UnicodeString& result) { michael@0: result = text; michael@0: } michael@0: U_NAMESPACE_END