intl/icu/source/i18n/remtrans.cpp

Wed, 31 Dec 2014 07:22:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 07:22:50 +0100
branch
TOR_BUG_3246
changeset 4
fc2d59ddac77
permissions
-rw-r--r--

Correct previous dual key logic pending first delivery installment.

michael@0 1 /*
michael@0 2 **********************************************************************
michael@0 3 * Copyright (c) 2001-2011, International Business Machines
michael@0 4 * Corporation and others. All Rights Reserved.
michael@0 5 **********************************************************************
michael@0 6 * Date Name Description
michael@0 7 * 04/02/2001 aliu Creation.
michael@0 8 **********************************************************************
michael@0 9 */
michael@0 10
michael@0 11 #include "unicode/utypes.h"
michael@0 12
michael@0 13 #if !UCONFIG_NO_TRANSLITERATION
michael@0 14
michael@0 15 #include "remtrans.h"
michael@0 16 #include "unicode/unifilt.h"
michael@0 17
michael@0 18 static const UChar CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */
michael@0 19
michael@0 20 U_NAMESPACE_BEGIN
michael@0 21
michael@0 22 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RemoveTransliterator)
michael@0 23
michael@0 24 /**
michael@0 25 * Factory method
michael@0 26 */
michael@0 27 static Transliterator* RemoveTransliterator_create(const UnicodeString& /*ID*/,
michael@0 28 Transliterator::Token /*context*/) {
michael@0 29 /* We don't need the ID or context. We just remove data */
michael@0 30 return new RemoveTransliterator();
michael@0 31 }
michael@0 32
michael@0 33 /**
michael@0 34 * System registration hook.
michael@0 35 */
michael@0 36 void RemoveTransliterator::registerIDs() {
michael@0 37
michael@0 38 Transliterator::_registerFactory(UnicodeString(TRUE, ::CURR_ID, -1),
michael@0 39 RemoveTransliterator_create, integerToken(0));
michael@0 40
michael@0 41 Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"),
michael@0 42 UNICODE_STRING_SIMPLE("Null"), FALSE);
michael@0 43 }
michael@0 44
michael@0 45 RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE, ::CURR_ID, -1), 0) {}
michael@0 46
michael@0 47 RemoveTransliterator::~RemoveTransliterator() {}
michael@0 48
michael@0 49 Transliterator* RemoveTransliterator::clone(void) const {
michael@0 50 Transliterator* result = new RemoveTransliterator();
michael@0 51 if (result != NULL && getFilter() != 0) {
michael@0 52 result->adoptFilter((UnicodeFilter*)(getFilter()->clone()));
michael@0 53 }
michael@0 54 return result;
michael@0 55 }
michael@0 56
michael@0 57 void RemoveTransliterator::handleTransliterate(Replaceable& text, UTransPosition& index,
michael@0 58 UBool /*isIncremental*/) const {
michael@0 59 // Our caller (filteredTransliterate) has already narrowed us
michael@0 60 // to an unfiltered run. Delete it.
michael@0 61 UnicodeString empty;
michael@0 62 text.handleReplaceBetween(index.start, index.limit, empty);
michael@0 63 int32_t len = index.limit - index.start;
michael@0 64 index.contextLimit -= len;
michael@0 65 index.limit -= len;
michael@0 66 }
michael@0 67 U_NAMESPACE_END
michael@0 68
michael@0 69 #endif /* #if !UCONFIG_NO_TRANSLITERATION */

mercurial