]> git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/remtrans.cpp
ICU-511.32.tar.gz
[apple/icu.git] / icuSources / i18n / remtrans.cpp
1 /*
2 **********************************************************************
3 * Copyright (c) 2001-2011, 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(UnicodeString(TRUE, ::CURR_ID, -1),
39 RemoveTransliterator_create, integerToken(0));
40
41 Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"),
42 UNICODE_STRING_SIMPLE("Null"), FALSE);
43 }
44
45 RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE, ::CURR_ID, -1), 0) {}
46
47 RemoveTransliterator::~RemoveTransliterator() {}
48
49 Transliterator* RemoveTransliterator::clone(void) const {
50 Transliterator* result = new RemoveTransliterator();
51 if (result != NULL && getFilter() != 0) {
52 result->adoptFilter((UnicodeFilter*)(getFilter()->clone()));
53 }
54 return result;
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 */