]>
Commit | Line | Data |
---|---|---|
b75a7d8f A |
1 | /* |
2 | ********************************************************************** | |
4388f060 | 3 | * Copyright (c) 2001-2011, International Business Machines |
b75a7d8f A |
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" | |
73c04bcf | 16 | #include "unicode/unifilt.h" |
b75a7d8f | 17 | |
73c04bcf | 18 | static const UChar CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */ |
b75a7d8f A |
19 | |
20 | U_NAMESPACE_BEGIN | |
21 | ||
374ca955 | 22 | UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RemoveTransliterator) |
b75a7d8f | 23 | |
73c04bcf A |
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 | ||
b75a7d8f A |
33 | /** |
34 | * System registration hook. | |
35 | */ | |
36 | void RemoveTransliterator::registerIDs() { | |
37 | ||
4388f060 A |
38 | Transliterator::_registerFactory(UnicodeString(TRUE, ::CURR_ID, -1), |
39 | RemoveTransliterator_create, integerToken(0)); | |
b75a7d8f A |
40 | |
41 | Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"), | |
42 | UNICODE_STRING_SIMPLE("Null"), FALSE); | |
43 | } | |
44 | ||
4388f060 | 45 | RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE, ::CURR_ID, -1), 0) {} |
b75a7d8f A |
46 | |
47 | RemoveTransliterator::~RemoveTransliterator() {} | |
48 | ||
49 | Transliterator* RemoveTransliterator::clone(void) const { | |
73c04bcf | 50 | Transliterator* result = new RemoveTransliterator(); |
46f4442e | 51 | if (result != NULL && getFilter() != 0) { |
73c04bcf A |
52 | result->adoptFilter((UnicodeFilter*)(getFilter()->clone())); |
53 | } | |
54 | return result; | |
b75a7d8f A |
55 | } |
56 | ||
57 | void RemoveTransliterator::handleTransliterate(Replaceable& text, UTransPosition& index, | |
58 | UBool /*isIncremental*/) const { | |
59 | // Our caller (filteredTransliterate) has already narrowed us | |
60 | // to an unfiltered run. Delete it. | |
61 | UnicodeString empty; | |
62 | text.handleReplaceBetween(index.start, index.limit, empty); | |
63 | int32_t len = index.limit - index.start; | |
64 | index.contextLimit -= len; | |
65 | index.limit -= len; | |
66 | } | |
67 | U_NAMESPACE_END | |
68 | ||
69 | #endif /* #if !UCONFIG_NO_TRANSLITERATION */ |