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