2 * Copyright (C) 1999-2004, International Business Machines Corporation and others. All Rights Reserved.
3 **********************************************************************
4 * Date Name Description
5 * 11/17/99 aliu Creation.
6 **********************************************************************
11 #include "unicode/utypes.h"
12 #include "unicode/uclean.h"
14 #if !UCONFIG_NO_TRANSLITERATION
16 #include "unicode/uobject.h"
24 class UnicodeReplacer
;
28 * The rule data for a RuleBasedTransliterators. RBT objects hold
29 * a const pointer to a TRD object that they do not own. TRD objects
30 * are essentially the parsed rules in compact, usable form. The
31 * TRD objects themselves are held for the life of the process in
32 * a static cache owned by Transliterator.
34 * This class' API is a little asymmetric. There is a method to
35 * define a variable, but no way to define a set. This is because the
36 * sets are defined by the parser in a UVector, and the vector is
37 * copied into a fixed-size array here. Once this is done, no new
38 * sets may be defined. In practice, there is no need to do so, since
39 * generating the data and using it are discrete phases. When there
40 * is a need to access the set data during the parse phase, another
41 * data structure handles this. See the parsing code for more
44 class U_I18N_API TransliterationRuleData
: public UMemory
{
48 // PUBLIC DATA MEMBERS
51 * Rule table. May be empty.
53 TransliterationRuleSet ruleSet
;
56 * Map variable name (String) to variable (UnicodeString). A variable name
57 * corresponds to zero or more characters, stored in a UnicodeString in
58 * this hash. One or more of these chars may also correspond to a
59 * UnicodeMatcher, in which case the character in the UnicodeString in this hash is
60 * a stand-in: it is an index for a secondary lookup in
61 * data.variables. The stand-in also represents the UnicodeMatcher in
64 Hashtable
* variableNames
;
67 * Map category variable (UChar) to set (UnicodeFunctor).
68 * Variables that correspond to a set of characters are mapped
69 * from variable name to a stand-in character in data.variableNames.
70 * The stand-in then serves as a key in this hash to lookup the
71 * actual UnicodeFunctor object. In addition, the stand-in is
72 * stored in the rule text to represent the set of characters.
73 * variables[i] represents character (variablesBase + i).
75 UnicodeFunctor
** variables
;
78 * The character that represents variables[0]. Characters
79 * variablesBase through variablesBase +
80 * variablesLength - 1 represent UnicodeFunctor objects.
85 * The length of variables.
87 int32_t variablesLength
;
93 * @param status Output param set to success/failure code on exit.
95 TransliterationRuleData(UErrorCode
& status
);
100 TransliterationRuleData(const TransliterationRuleData
&);
105 ~TransliterationRuleData();
108 * Given a stand-in character, return the UnicodeFunctor that it
109 * represents, or NULL if it doesn't represent anything.
110 * @param standIn the given stand-in character.
111 * @return the UnicodeFunctor that 'standIn' represents
113 UnicodeFunctor
* lookup(UChar32 standIn
) const;
116 * Given a stand-in character, return the UnicodeMatcher that it
117 * represents, or NULL if it doesn't represent anything or if it
118 * represents something that is not a matcher.
119 * @param standIn the given stand-in character.
120 * @return return the UnicodeMatcher that 'standIn' represents
122 UnicodeMatcher
* lookupMatcher(UChar32 standIn
) const;
125 * Given a stand-in character, return the UnicodeReplacer that it
126 * represents, or NULL if it doesn't represent anything or if it
127 * represents something that is not a replacer.
128 * @param standIn the given stand-in character.
129 * @return return the UnicodeReplacer that 'standIn' represents
131 UnicodeReplacer
* lookupReplacer(UChar32 standIn
) const;
135 TransliterationRuleData
&operator=(const TransliterationRuleData
&other
); // forbid copying of this class
140 #endif /* #if !UCONFIG_NO_TRANSLITERATION */