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