1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/intl/icu/source/common/schriter.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,117 @@ 1.4 +/* 1.5 +****************************************************************************** 1.6 +* Copyright (C) 1998-2012, International Business Machines Corporation and 1.7 +* others. All Rights Reserved. 1.8 +****************************************************************************** 1.9 +* 1.10 +* File schriter.cpp 1.11 +* 1.12 +* Modification History: 1.13 +* 1.14 +* Date Name Description 1.15 +* 05/05/99 stephen Cleaned up. 1.16 +****************************************************************************** 1.17 +*/ 1.18 + 1.19 +#include "utypeinfo.h" // for 'typeid' to work 1.20 + 1.21 +#include "unicode/chariter.h" 1.22 +#include "unicode/schriter.h" 1.23 + 1.24 +U_NAMESPACE_BEGIN 1.25 + 1.26 +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(StringCharacterIterator) 1.27 + 1.28 +StringCharacterIterator::StringCharacterIterator() 1.29 + : UCharCharacterIterator(), 1.30 + text() 1.31 +{ 1.32 + // NEVER DEFAULT CONSTRUCT! 1.33 +} 1.34 + 1.35 +StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr) 1.36 + : UCharCharacterIterator(textStr.getBuffer(), textStr.length()), 1.37 + text(textStr) 1.38 +{ 1.39 + // we had set the input parameter's array, now we need to set our copy's array 1.40 + UCharCharacterIterator::text = this->text.getBuffer(); 1.41 +} 1.42 + 1.43 +StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, 1.44 + int32_t textPos) 1.45 + : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textPos), 1.46 + text(textStr) 1.47 +{ 1.48 + // we had set the input parameter's array, now we need to set our copy's array 1.49 + UCharCharacterIterator::text = this->text.getBuffer(); 1.50 +} 1.51 + 1.52 +StringCharacterIterator::StringCharacterIterator(const UnicodeString& textStr, 1.53 + int32_t textBegin, 1.54 + int32_t textEnd, 1.55 + int32_t textPos) 1.56 + : UCharCharacterIterator(textStr.getBuffer(), textStr.length(), textBegin, textEnd, textPos), 1.57 + text(textStr) 1.58 +{ 1.59 + // we had set the input parameter's array, now we need to set our copy's array 1.60 + UCharCharacterIterator::text = this->text.getBuffer(); 1.61 +} 1.62 + 1.63 +StringCharacterIterator::StringCharacterIterator(const StringCharacterIterator& that) 1.64 + : UCharCharacterIterator(that), 1.65 + text(that.text) 1.66 +{ 1.67 + // we had set the input parameter's array, now we need to set our copy's array 1.68 + UCharCharacterIterator::text = this->text.getBuffer(); 1.69 +} 1.70 + 1.71 +StringCharacterIterator::~StringCharacterIterator() { 1.72 +} 1.73 + 1.74 +StringCharacterIterator& 1.75 +StringCharacterIterator::operator=(const StringCharacterIterator& that) { 1.76 + UCharCharacterIterator::operator=(that); 1.77 + text = that.text; 1.78 + // we had set the input parameter's array, now we need to set our copy's array 1.79 + UCharCharacterIterator::text = this->text.getBuffer(); 1.80 + return *this; 1.81 +} 1.82 + 1.83 +UBool 1.84 +StringCharacterIterator::operator==(const ForwardCharacterIterator& that) const { 1.85 + if (this == &that) { 1.86 + return TRUE; 1.87 + } 1.88 + 1.89 + // do not call UCharCharacterIterator::operator==() 1.90 + // because that checks for array pointer equality 1.91 + // while we compare UnicodeString objects 1.92 + 1.93 + if (typeid(*this) != typeid(that)) { 1.94 + return FALSE; 1.95 + } 1.96 + 1.97 + StringCharacterIterator& realThat = (StringCharacterIterator&)that; 1.98 + 1.99 + return text == realThat.text 1.100 + && pos == realThat.pos 1.101 + && begin == realThat.begin 1.102 + && end == realThat.end; 1.103 +} 1.104 + 1.105 +CharacterIterator* 1.106 +StringCharacterIterator::clone() const { 1.107 + return new StringCharacterIterator(*this); 1.108 +} 1.109 + 1.110 +void 1.111 +StringCharacterIterator::setText(const UnicodeString& newText) { 1.112 + text = newText; 1.113 + UCharCharacterIterator::setText(text.getBuffer(), text.length()); 1.114 +} 1.115 + 1.116 +void 1.117 +StringCharacterIterator::getText(UnicodeString& result) { 1.118 + result = text; 1.119 +} 1.120 +U_NAMESPACE_END