X-Git-Url: https://git.saurik.com/apple/icu.git/blobdiff_plain/b75a7d8f3b4adbae880cab104ce2c6a50eee4db2..a0b4f637ba1a6c3c5651b61a69303b029bacf7d3:/icuSources/i18n/toupptrn.cpp diff --git a/icuSources/i18n/toupptrn.cpp b/icuSources/i18n/toupptrn.cpp index cf283566..4b7c7d06 100644 --- a/icuSources/i18n/toupptrn.cpp +++ b/icuSources/i18n/toupptrn.cpp @@ -1,6 +1,6 @@ /* ********************************************************************** -* Copyright (C) 2001, International Business Machines +* Copyright (C) 2001-2007, International Business Machines * Corporation and others. All Rights Reserved. ********************************************************************** * Date Name Description @@ -20,50 +20,38 @@ U_NAMESPACE_BEGIN -const char UppercaseTransliterator::fgClassID=0; - -const char UppercaseTransliterator::_ID[] = "Any-Upper"; +UOBJECT_DEFINE_RTTI_IMPLEMENTATION(UppercaseTransliterator) /** * Constructs a transliterator. */ -UppercaseTransliterator::UppercaseTransliterator(const Locale& theLoc) : - Transliterator(_ID, 0), - loc(theLoc), - buffer(0) +UppercaseTransliterator::UppercaseTransliterator() : + CaseMapTransliterator(UNICODE_STRING("Any-Upper", 9), ucase_toFullUpper) { - buffer = (UChar *)uprv_malloc(u_getMaxCaseExpansion()*sizeof(buffer[0])); } /** * Destructor. */ UppercaseTransliterator::~UppercaseTransliterator() { - uprv_free(buffer); } /** * Copy constructor. */ UppercaseTransliterator::UppercaseTransliterator(const UppercaseTransliterator& o) : - Transliterator(o), - loc(o.loc), - buffer(0) + CaseMapTransliterator(o) { - buffer = (UChar *)uprv_malloc(u_getMaxCaseExpansion()*sizeof(buffer[0])); - uprv_arrayCopy(o.buffer, 0, this->buffer, 0, u_getMaxCaseExpansion()); } /** * Assignment operator. */ -UppercaseTransliterator& UppercaseTransliterator::operator=( +/*UppercaseTransliterator& UppercaseTransliterator::operator=( const UppercaseTransliterator& o) { - Transliterator::operator=(o); - loc = o.loc; - uprv_arrayCopy(o.buffer, 0, this->buffer, 0, u_getMaxCaseExpansion()); + CaseMapTransliterator::operator=(o); return *this; -} +}*/ /** * Transliterator API. @@ -72,54 +60,6 @@ Transliterator* UppercaseTransliterator::clone(void) const { return new UppercaseTransliterator(*this); } -/** - * Implements {@link Transliterator#handleTransliterate}. - */ -void UppercaseTransliterator::handleTransliterate(Replaceable& text, - UTransPosition& offsets, - UBool isIncremental) const { - int32_t textPos = offsets.start; - if (textPos >= offsets.limit) return; - - // get string for context - - UnicodeString original; - text.extractBetween(offsets.contextStart, offsets.contextLimit, original); - - UCharIterator iter; - uiter_setReplaceable(&iter, &text); - iter.start = offsets.contextStart; - iter.limit = offsets.contextLimit; - - // Walk through original string - // If there is a case change, modify corresponding position in replaceable - - int32_t i = textPos - offsets.contextStart; - int32_t limit = offsets.limit - offsets.contextStart; - UChar32 cp; - int32_t oldLen; - - for (; i < limit; ) { - UTF_GET_CHAR(original.getBuffer(), 0, i, original.length(), cp); - oldLen = UTF_CHAR_LENGTH(cp); - i += oldLen; - iter.index = i; // Point _past_ current char - int32_t newLen = u_internalToUpper(cp, &iter, buffer, u_getMaxCaseExpansion(), loc.getName()); - if (newLen >= 0) { - UnicodeString temp(buffer, newLen); - text.handleReplaceBetween(textPos, textPos + oldLen, temp); - if (newLen != oldLen) { - textPos += newLen; - offsets.limit += newLen - oldLen; - offsets.contextLimit += newLen - oldLen; - continue; - } - } - textPos += oldLen; - } - offsets.start = offsets.limit; -} - U_NAMESPACE_END #endif /* #if !UCONFIG_NO_TRANSLITERATION */