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