michael@0: /* michael@0: ********************************************************************** michael@0: * Copyright (c) 2001-2011, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ********************************************************************** michael@0: * Date Name Description michael@0: * 04/02/2001 aliu Creation. michael@0: ********************************************************************** michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: #if !UCONFIG_NO_TRANSLITERATION michael@0: michael@0: #include "remtrans.h" michael@0: #include "unicode/unifilt.h" michael@0: michael@0: static const UChar CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */ michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RemoveTransliterator) michael@0: michael@0: /** michael@0: * Factory method michael@0: */ michael@0: static Transliterator* RemoveTransliterator_create(const UnicodeString& /*ID*/, michael@0: Transliterator::Token /*context*/) { michael@0: /* We don't need the ID or context. We just remove data */ michael@0: return new RemoveTransliterator(); michael@0: } michael@0: michael@0: /** michael@0: * System registration hook. michael@0: */ michael@0: void RemoveTransliterator::registerIDs() { michael@0: michael@0: Transliterator::_registerFactory(UnicodeString(TRUE, ::CURR_ID, -1), michael@0: RemoveTransliterator_create, integerToken(0)); michael@0: michael@0: Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"), michael@0: UNICODE_STRING_SIMPLE("Null"), FALSE); michael@0: } michael@0: michael@0: RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE, ::CURR_ID, -1), 0) {} michael@0: michael@0: RemoveTransliterator::~RemoveTransliterator() {} michael@0: michael@0: Transliterator* RemoveTransliterator::clone(void) const { michael@0: Transliterator* result = new RemoveTransliterator(); michael@0: if (result != NULL && getFilter() != 0) { michael@0: result->adoptFilter((UnicodeFilter*)(getFilter()->clone())); michael@0: } michael@0: return result; michael@0: } michael@0: michael@0: void RemoveTransliterator::handleTransliterate(Replaceable& text, UTransPosition& index, michael@0: UBool /*isIncremental*/) const { michael@0: // Our caller (filteredTransliterate) has already narrowed us michael@0: // to an unfiltered run. Delete it. michael@0: UnicodeString empty; michael@0: text.handleReplaceBetween(index.start, index.limit, empty); michael@0: int32_t len = index.limit - index.start; michael@0: index.contextLimit -= len; michael@0: index.limit -= len; michael@0: } michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* #if !UCONFIG_NO_TRANSLITERATION */