X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/9d88c94317aeac5dd26c1dbe8c2112dbe855d2b5..73c04bcfe1096173b00431f0cdc742894b15eef0:/icuSources/common/usetiter.cpp?ds=sidebyside diff --git a/icuSources/common/usetiter.cpp b/icuSources/common/usetiter.cpp index 75a75de4..44858ed4 100644 --- a/icuSources/common/usetiter.cpp +++ b/icuSources/common/usetiter.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (c) 2002-2003, International Business Machines +* Copyright (c) 2002-2006, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** */ @@ -18,6 +18,7 @@ UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UnicodeSetIterator) * @param set set to iterate over */ UnicodeSetIterator::UnicodeSetIterator(const UnicodeSet& uSet) { + cpString = NULL; reset(uSet); } @@ -26,11 +27,12 @@ UnicodeSetIterator::UnicodeSetIterator(const UnicodeSet& uSet) { */ UnicodeSetIterator::UnicodeSetIterator() { this->set = NULL; + cpString = NULL; reset(); } UnicodeSetIterator::~UnicodeSetIterator() { - // Nothing to do + delete cpString; } /** @@ -45,11 +47,13 @@ UnicodeSetIterator::~UnicodeSetIterator() { UBool UnicodeSetIterator::next() { if (nextElement <= endElement) { codepoint = codepointEnd = nextElement++; + string = NULL; return TRUE; } if (range < endRange) { loadRange(++range); codepoint = codepointEnd = nextElement++; + string = NULL; return TRUE; } @@ -71,6 +75,7 @@ UBool UnicodeSetIterator::next() { *
Note also that the codepointEnd is undefined after calling this method. */ UBool UnicodeSetIterator::nextRange() { + string = NULL; if (nextElement <= endElement) { codepointEnd = endElement; codepoint = nextElement; @@ -118,6 +123,7 @@ void UnicodeSetIterator::reset() { loadRange(range); } nextString = 0; + string = NULL; } void UnicodeSetIterator::loadRange(int32_t iRange) { @@ -125,6 +131,20 @@ void UnicodeSetIterator::loadRange(int32_t iRange) { endElement = set->getRangeEnd(iRange); } + +const UnicodeString& UnicodeSetIterator::getString() { + if (string==NULL && codepoint!=(UChar32)IS_STRING) { + if (cpString == NULL) { + cpString = new UnicodeString(); + } + if (cpString != NULL) { + cpString->setTo((UChar32)codepoint); + } + string = cpString; + } + return *string; +} + U_NAMESPACE_END //eof