]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/anytrans.h
ICU-6.2.14.tar.gz
[apple/icu.git] / icuSources / i18n / anytrans.h
CommitLineData
b75a7d8f
A
1/*
2*****************************************************************
374ca955 3* Copyright (c) 2002-2004, International Business Machines Corporation
b75a7d8f
A
4* and others. All Rights Reserved.
5*****************************************************************
b75a7d8f
A
6* Date Name Description
7* 06/06/2002 aliu Creation.
8*****************************************************************
9*/
10#ifndef _ANYTRANS_H_
11#define _ANYTRANS_H_
12
13#include "unicode/utypes.h"
14
15#if !UCONFIG_NO_TRANSLITERATION
16
17#include "unicode/translit.h"
18#include "unicode/uscript.h"
19#include "uhash.h"
20
21U_NAMESPACE_BEGIN
22
23/**
24 * A transliterator named Any-T or Any-T/V, where T is the target
25 * script and V is the optional variant, that uses multiple
26 * transliterators, all going to T or T/V, all with script sources.
27 * The target must be a script. It partitions text into runs of the
28 * same script, and then based on the script of each run,
29 * transliterates from that script to the given target or
30 * target/variant. Adjacent COMMON or INHERITED script characters are
31 * included in each run.
32 *
33 * @author Alan Liu
34 */
35class U_I18N_API AnyTransliterator : public Transliterator {
36
37 /**
38 * Cache mapping UScriptCode values to Transliterator*.
39 */
40 UHashtable* cache;
41
42 /**
43 * The target or target/variant string.
44 */
45 UnicodeString target;
46
47 /**
48 * The target script code. Never USCRIPT_INVALID_CODE.
49 */
50 UScriptCode targetScript;
51
b75a7d8f 52public:
374ca955 53
b75a7d8f
A
54 /**
55 * Destructor.
56 */
57 virtual ~AnyTransliterator();
58
59 /**
60 * Copy constructor.
61 */
62 AnyTransliterator(const AnyTransliterator&);
63
64 /**
65 * Transliterator API.
66 */
374ca955 67 virtual Transliterator* clone() const;
b75a7d8f
A
68
69 /**
70 * Implements {@link Transliterator#handleTransliterate}.
71 */
72 virtual void handleTransliterate(Replaceable& text, UTransPosition& index,
73 UBool incremental) const;
374ca955 74
b75a7d8f
A
75 /**
76 * ICU "poor man's RTTI", returns a UClassID for the actual class.
77 *
78 * @draft ICU 2.2
79 */
374ca955 80 virtual UClassID getDynamicClassID() const;
b75a7d8f
A
81
82 /**
83 * ICU "poor man's RTTI", returns a UClassID for this class.
84 *
85 * @draft ICU 2.2
86 */
374ca955 87 static UClassID U_EXPORT2 getStaticClassID();
b75a7d8f
A
88
89private:
90
91 /**
92 * Private constructor
93 * @param id the ID of the form S-T or S-T/V, where T is theTarget
94 * and V is theVariant. Must not be empty.
95 * @param theTarget the target name. Must not be empty, and must
96 * name a script corresponding to theTargetScript.
97 * @param theVariant the variant name, or the empty string if
98 * there is no variant
99 * @param theTargetScript the script code corresponding to
100 * theTarget.
101 * @param ec error code, fails if the internal hashtable cannot be
102 * allocated
103 */
104 AnyTransliterator(const UnicodeString& id,
105 const UnicodeString& theTarget,
106 const UnicodeString& theVariant,
107 UScriptCode theTargetScript,
108 UErrorCode& ec);
109
110 /**
111 * Returns a transliterator from the given source to our target or
112 * target/variant. Returns NULL if the source is the same as our
113 * target script, or if the source is USCRIPT_INVALID_CODE.
114 * Caches the result and returns the same transliterator the next
115 * time. The caller does NOT own the result and must not delete
116 * it.
117 */
118 Transliterator* getTransliterator(UScriptCode source) const;
119
120 /**
121 * Registers standard transliterators with the system. Called by
122 * Transliterator during initialization.
123 */
124 static void registerIDs();
125
126 friend class Transliterator; // for registerIDs()
374ca955 127
b75a7d8f
A
128 /**
129 * Return the script code for a given name, or
130 * USCRIPT_INVALID_CODE if not found.
131 */
132 static UScriptCode scriptNameToCode(const UnicodeString& name);
133};
134
135U_NAMESPACE_END
136
137#endif /* #if !UCONFIG_NO_TRANSLITERATION */
138
139#endif