11cb0ef41Sopenharmony_ci// © 2016 and later: Unicode, Inc. and others. 21cb0ef41Sopenharmony_ci// License & terms of use: http://www.unicode.org/copyright.html 31cb0ef41Sopenharmony_ci/* 41cb0ef41Sopenharmony_ci********************************************************************** 51cb0ef41Sopenharmony_ci* Copyright (c) 2001-2011, International Business Machines 61cb0ef41Sopenharmony_ci* Corporation and others. All Rights Reserved. 71cb0ef41Sopenharmony_ci********************************************************************** 81cb0ef41Sopenharmony_ci* Date Name Description 91cb0ef41Sopenharmony_ci* 04/02/2001 aliu Creation. 101cb0ef41Sopenharmony_ci********************************************************************** 111cb0ef41Sopenharmony_ci*/ 121cb0ef41Sopenharmony_ci 131cb0ef41Sopenharmony_ci#include "unicode/utypes.h" 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ci#if !UCONFIG_NO_TRANSLITERATION 161cb0ef41Sopenharmony_ci 171cb0ef41Sopenharmony_ci#include "remtrans.h" 181cb0ef41Sopenharmony_ci#include "unicode/unifilt.h" 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_cistatic const char16_t CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */ 211cb0ef41Sopenharmony_ci 221cb0ef41Sopenharmony_ciU_NAMESPACE_BEGIN 231cb0ef41Sopenharmony_ci 241cb0ef41Sopenharmony_ciUOBJECT_DEFINE_RTTI_IMPLEMENTATION(RemoveTransliterator) 251cb0ef41Sopenharmony_ci 261cb0ef41Sopenharmony_ci/** 271cb0ef41Sopenharmony_ci * Factory method 281cb0ef41Sopenharmony_ci */ 291cb0ef41Sopenharmony_cistatic Transliterator* RemoveTransliterator_create(const UnicodeString& /*ID*/, 301cb0ef41Sopenharmony_ci Transliterator::Token /*context*/) { 311cb0ef41Sopenharmony_ci /* We don't need the ID or context. We just remove data */ 321cb0ef41Sopenharmony_ci return new RemoveTransliterator(); 331cb0ef41Sopenharmony_ci} 341cb0ef41Sopenharmony_ci 351cb0ef41Sopenharmony_ci/** 361cb0ef41Sopenharmony_ci * System registration hook. 371cb0ef41Sopenharmony_ci */ 381cb0ef41Sopenharmony_civoid RemoveTransliterator::registerIDs() { 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci Transliterator::_registerFactory(UnicodeString(true, ::CURR_ID, -1), 411cb0ef41Sopenharmony_ci RemoveTransliterator_create, integerToken(0)); 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"), 441cb0ef41Sopenharmony_ci UNICODE_STRING_SIMPLE("Null"), false); 451cb0ef41Sopenharmony_ci} 461cb0ef41Sopenharmony_ci 471cb0ef41Sopenharmony_ciRemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(true, ::CURR_ID, -1), 0) {} 481cb0ef41Sopenharmony_ci 491cb0ef41Sopenharmony_ciRemoveTransliterator::~RemoveTransliterator() {} 501cb0ef41Sopenharmony_ci 511cb0ef41Sopenharmony_ciRemoveTransliterator* RemoveTransliterator::clone() const { 521cb0ef41Sopenharmony_ci RemoveTransliterator* result = new RemoveTransliterator(); 531cb0ef41Sopenharmony_ci if (result != nullptr && getFilter() != 0) { 541cb0ef41Sopenharmony_ci result->adoptFilter(getFilter()->clone()); 551cb0ef41Sopenharmony_ci } 561cb0ef41Sopenharmony_ci return result; 571cb0ef41Sopenharmony_ci} 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_civoid RemoveTransliterator::handleTransliterate(Replaceable& text, UTransPosition& index, 601cb0ef41Sopenharmony_ci UBool /*isIncremental*/) const { 611cb0ef41Sopenharmony_ci // Our caller (filteredTransliterate) has already narrowed us 621cb0ef41Sopenharmony_ci // to an unfiltered run. Delete it. 631cb0ef41Sopenharmony_ci UnicodeString empty; 641cb0ef41Sopenharmony_ci text.handleReplaceBetween(index.start, index.limit, empty); 651cb0ef41Sopenharmony_ci int32_t len = index.limit - index.start; 661cb0ef41Sopenharmony_ci index.contextLimit -= len; 671cb0ef41Sopenharmony_ci index.limit -= len; 681cb0ef41Sopenharmony_ci} 691cb0ef41Sopenharmony_ciU_NAMESPACE_END 701cb0ef41Sopenharmony_ci 711cb0ef41Sopenharmony_ci#endif /* #if !UCONFIG_NO_TRANSLITERATION */ 72