2017-01-20 00:20:31 +00:00
|
|
|
// © 2016 and later: Unicode, Inc. and others.
|
2016-06-15 18:58:17 +00:00
|
|
|
// License & terms of use: http://www.unicode.org/copyright.html
|
2001-04-04 06:46:17 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2016-05-31 21:45:07 +00:00
|
|
|
* Copyright (c) 2001-2011, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
2001-04-04 06:46:17 +00:00
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 04/02/2001 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
2002-09-20 01:54:48 +00:00
|
|
|
|
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
|
|
|
#if !UCONFIG_NO_TRANSLITERATION
|
|
|
|
|
2001-11-16 23:51:15 +00:00
|
|
|
#include "remtrans.h"
|
2005-06-29 19:22:01 +00:00
|
|
|
#include "unicode/unifilt.h"
|
2001-04-04 06:46:17 +00:00
|
|
|
|
2005-01-18 17:31:05 +00:00
|
|
|
static const UChar CURR_ID[] = {65, 110, 121, 45, 0x52, 0x65, 0x6D, 0x6F, 0x76, 0x65, 0x00}; /* "Any-Remove" */
|
2001-11-29 18:03:51 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2003-08-31 20:53:46 +00:00
|
|
|
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(RemoveTransliterator)
|
2002-06-29 00:04:16 +00:00
|
|
|
|
2005-01-09 05:18:02 +00:00
|
|
|
/**
|
|
|
|
* Factory method
|
|
|
|
*/
|
|
|
|
static Transliterator* RemoveTransliterator_create(const UnicodeString& /*ID*/,
|
|
|
|
Transliterator::Token /*context*/) {
|
|
|
|
/* We don't need the ID or context. We just remove data */
|
|
|
|
return new RemoveTransliterator();
|
|
|
|
}
|
|
|
|
|
2001-11-29 18:03:51 +00:00
|
|
|
/**
|
|
|
|
* System registration hook.
|
|
|
|
*/
|
|
|
|
void RemoveTransliterator::registerIDs() {
|
|
|
|
|
2011-07-07 18:46:19 +00:00
|
|
|
Transliterator::_registerFactory(UnicodeString(TRUE, ::CURR_ID, -1),
|
|
|
|
RemoveTransliterator_create, integerToken(0));
|
2001-11-29 18:03:51 +00:00
|
|
|
|
2002-01-22 00:27:49 +00:00
|
|
|
Transliterator::_registerSpecialInverse(UNICODE_STRING_SIMPLE("Remove"),
|
|
|
|
UNICODE_STRING_SIMPLE("Null"), FALSE);
|
2001-11-29 18:03:51 +00:00
|
|
|
}
|
|
|
|
|
2011-07-07 18:46:19 +00:00
|
|
|
RemoveTransliterator::RemoveTransliterator() : Transliterator(UnicodeString(TRUE, ::CURR_ID, -1), 0) {}
|
2001-11-29 18:03:51 +00:00
|
|
|
|
|
|
|
RemoveTransliterator::~RemoveTransliterator() {}
|
2001-04-04 06:46:17 +00:00
|
|
|
|
|
|
|
Transliterator* RemoveTransliterator::clone(void) const {
|
2005-06-29 19:22:01 +00:00
|
|
|
Transliterator* result = new RemoveTransliterator();
|
2008-01-14 23:25:13 +00:00
|
|
|
if (result != NULL && getFilter() != 0) {
|
2005-06-29 19:22:01 +00:00
|
|
|
result->adoptFilter((UnicodeFilter*)(getFilter()->clone()));
|
|
|
|
}
|
|
|
|
return result;
|
2001-04-04 06:46:17 +00:00
|
|
|
}
|
|
|
|
|
2001-07-17 23:36:41 +00:00
|
|
|
void RemoveTransliterator::handleTransliterate(Replaceable& text, UTransPosition& index,
|
2001-04-04 06:46:17 +00:00
|
|
|
UBool /*isIncremental*/) const {
|
2001-07-17 23:36:41 +00:00
|
|
|
// Our caller (filteredTransliterate) has already narrowed us
|
|
|
|
// to an unfiltered run. Delete it.
|
2001-04-04 06:46:17 +00:00
|
|
|
UnicodeString empty;
|
2001-07-17 23:36:41 +00:00
|
|
|
text.handleReplaceBetween(index.start, index.limit, empty);
|
|
|
|
int32_t len = index.limit - index.start;
|
|
|
|
index.contextLimit -= len;
|
|
|
|
index.limit -= len;
|
2001-04-04 06:46:17 +00:00
|
|
|
}
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
|