1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 ***********************************************************************
5 * Copyright (c) 2002-2007, International Business Machines Corporation
6 * and others. All Rights Reserved.
7 ***********************************************************************
8 * Date Name Description
9 * 06/06/2002 aliu Creation.
10 ***********************************************************************
15 #include "unicode/utypes.h"
17 #if !UCONFIG_NO_TRANSLITERATION
19 #include "unicode/translit.h"
20 #include "unicode/uscript.h"
26 * A transliterator named Any-T or Any-T/V, where T is the target
27 * script and V is the optional variant, that uses multiple
28 * transliterators, all going to T or T/V, all with script sources.
29 * The target must be a script. It partitions text into runs of the
30 * same script, and then based on the script of each run,
31 * transliterates from that script to the given target or
32 * target/variant. Adjacent COMMON or INHERITED script characters are
33 * included in each run.
37 class AnyTransliterator
: public Transliterator
{
40 * Cache mapping UScriptCode values to Transliterator*.
45 * The target or target/variant string.
50 * The target script code. Never USCRIPT_INVALID_CODE.
52 UScriptCode targetScript
;
59 virtual ~AnyTransliterator();
64 AnyTransliterator(const AnyTransliterator
&);
69 virtual Transliterator
* clone() const;
72 * Implements {@link Transliterator#handleTransliterate}.
74 virtual void handleTransliterate(Replaceable
& text
, UTransPosition
& index
,
75 UBool incremental
) const;
78 * ICU "poor man's RTTI", returns a UClassID for the actual class.
80 virtual UClassID
getDynamicClassID() const;
83 * ICU "poor man's RTTI", returns a UClassID for this class.
85 U_I18N_API
static UClassID U_EXPORT2
getStaticClassID();
91 * @param id the ID of the form S-T or S-T/V, where T is theTarget
92 * and V is theVariant. Must not be empty.
93 * @param theTarget the target name. Must not be empty, and must
94 * name a script corresponding to theTargetScript.
95 * @param theVariant the variant name, or the empty string if
97 * @param theTargetScript the script code corresponding to
99 * @param ec error code, fails if the internal hashtable cannot be
102 AnyTransliterator(const UnicodeString
& id
,
103 const UnicodeString
& theTarget
,
104 const UnicodeString
& theVariant
,
105 UScriptCode theTargetScript
,
109 * Returns a transliterator from the given source to our target or
110 * target/variant. Returns NULL if the source is the same as our
111 * target script, or if the source is USCRIPT_INVALID_CODE.
112 * Caches the result and returns the same transliterator the next
113 * time. The caller does NOT own the result and must not delete
116 Transliterator
* getTransliterator(UScriptCode source
) const;
119 * Registers standard transliterators with the system. Called by
120 * Transliterator during initialization.
122 static void registerIDs();
124 friend class Transliterator
; // for registerIDs()
129 #endif /* #if !UCONFIG_NO_TRANSLITERATION */