Wed, 31 Dec 2014 07:22:50 +0100
Correct previous dual key logic pending first delivery installment.
michael@0 | 1 | /* |
michael@0 | 2 | ****************************************************************************** |
michael@0 | 3 | * Copyright (C) 1998-2012, International Business Machines Corporation and |
michael@0 | 4 | * others. All Rights Reserved. |
michael@0 | 5 | ****************************************************************************** |
michael@0 | 6 | * |
michael@0 | 7 | * File schriter.cpp |
michael@0 | 8 | * |
michael@0 | 9 | * Modification History: |
michael@0 | 10 | * |
michael@0 | 11 | * Date Name Description |
michael@0 | 12 | * 05/05/99 stephen Cleaned up. |
michael@0 | 13 | ****************************************************************************** |
michael@0 | 14 | */ |
michael@0 | 15 | |
michael@0 | 16 | #include "utypeinfo.h" // for 'typeid' to work |
michael@0 | 17 | |
michael@0 | 18 | #include "unicode/chariter.h" |
michael@0 | 19 | #include "unicode/schriter.h" |
michael@0 | 20 | |
michael@0 | 21 | U_NAMESPACE_BEGIN |
michael@0 | 22 | |
michael@0 | 23 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator) |
michael@0 | 24 | |
michael@0 | 25 | StringCharacterIterator::StringCharacterIterator() |
michael@0 | 26 | : UCharCharacterIterator(), |
michael@0 | 27 | text() |
michael@0 | 28 | { |
michael@0 | 29 | // NEVER DEFAULT CONSTRUCT! |
michael@0 | 30 | } |
michael@0 | 31 | |
michael@0 | 32 | StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr) |
michael@0 | 33 | : UCharCharacterIterator(textStr.getBuffer(), textStr.length()), |
michael@0 | 34 | text(textStr) |
michael@0 | 35 | { |
michael@0 | 36 | // we had set the input parameter's array, now we need to set our copy's array |
michael@0 | 37 | UCharCharacterIterator::text = this->text.getBuffer(); |
michael@0 | 38 | } |
michael@0 | 39 | |
michael@0 | 40 | StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, |
michael@0 | 41 | int32_t textPos) |
michael@0 | 42 | : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textPos), |
michael@0 | 43 | text(textStr) |
michael@0 | 44 | { |
michael@0 | 45 | // we had set the input parameter's array, now we need to set our copy's array |
michael@0 | 46 | UCharCharacterIterator::text = this->text.getBuffer(); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, |
michael@0 | 50 | int32_t textBegin, |
michael@0 | 51 | int32_t textEnd, |
michael@0 | 52 | int32_t textPos) |
michael@0 | 53 | : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textBegin, textEnd, textPos), |
michael@0 | 54 | text(textStr) |
michael@0 | 55 | { |
michael@0 | 56 | // we had set the input parameter's array, now we need to set our copy's array |
michael@0 | 57 | UCharCharacterIterator::text = this->text.getBuffer(); |
michael@0 | 58 | } |
michael@0 | 59 | |
michael@0 | 60 | StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that) |
michael@0 | 61 | : UCharCharacterIterator(that), |
michael@0 | 62 | text(that.text) |
michael@0 | 63 | { |
michael@0 | 64 | // we had set the input parameter's array, now we need to set our copy's array |
michael@0 | 65 | UCharCharacterIterator::text = this->text.getBuffer(); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | StringCharacterIterator::~StringCharacterIterator() { |
michael@0 | 69 | } |
michael@0 | 70 | |
michael@0 | 71 | StringCharacterIterator& |
michael@0 | 72 | StringCharacterIterator::operator=(const StringCharacterIterator& that) { |
michael@0 | 73 | UCharCharacterIterator::operator=(that); |
michael@0 | 74 | text = that.text; |
michael@0 | 75 | // we had set the input parameter's array, now we need to set our copy's array |
michael@0 | 76 | UCharCharacterIterator::text = this->text.getBuffer(); |
michael@0 | 77 | return *this; |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | UBool |
michael@0 | 81 | StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const { |
michael@0 | 82 | if (this == &that) { |
michael@0 | 83 | return TRUE; |
michael@0 | 84 | } |
michael@0 | 85 | |
michael@0 | 86 | // do not call UCharCharacterIterator::operator==() |
michael@0 | 87 | // because that checks for array pointer equality |
michael@0 | 88 | // while we compare UnicodeString objects |
michael@0 | 89 | |
michael@0 | 90 | if (typeid(*this) != typeid(that)) { |
michael@0 | 91 | return FALSE; |
michael@0 | 92 | } |
michael@0 | 93 | |
michael@0 | 94 | StringCharacterIterator& realThat = (StringCharacterIterator&)that; |
michael@0 | 95 | |
michael@0 | 96 | return text == realThat.text |
michael@0 | 97 | && pos == realThat.pos |
michael@0 | 98 | && begin == realThat.begin |
michael@0 | 99 | && end == realThat.end; |
michael@0 | 100 | } |
michael@0 | 101 | |
michael@0 | 102 | CharacterIterator* |
michael@0 | 103 | StringCharacterIterator::clone() const { |
michael@0 | 104 | return new StringCharacterIterator(*this); |
michael@0 | 105 | } |
michael@0 | 106 | |
michael@0 | 107 | void |
michael@0 | 108 | StringCharacterIterator::setText(const UnicodeString& newText) { |
michael@0 | 109 | text = newText; |
michael@0 | 110 | UCharCharacterIterator::setText(text.getBuffer(), text.length()); |
michael@0 | 111 | } |
michael@0 | 112 | |
michael@0 | 113 | void |
michael@0 | 114 | StringCharacterIterator::getText(UnicodeString& result) { |
michael@0 | 115 | result = text; |
michael@0 | 116 | } |
michael@0 | 117 | U_NAMESPACE_END |