]> git.saurik.com Git - apple/icu.git/blame - icuSources/i18n/rbt_data.h
ICU-6.2.14.tar.gz
[apple/icu.git] / icuSources / i18n / rbt_data.h
CommitLineData
b75a7d8f 1/*
374ca955 2* Copyright (C) 1999-2004, International Business Machines Corporation and others. All Rights Reserved.
b75a7d8f
A
3**********************************************************************
4* Date Name Description
5* 11/17/99 aliu Creation.
6**********************************************************************
7*/
8#ifndef RBT_DATA_H
9#define RBT_DATA_H
10
11#include "unicode/utypes.h"
374ca955 12#include "unicode/uclean.h"
b75a7d8f
A
13
14#if !UCONFIG_NO_TRANSLITERATION
15
16#include "unicode/uobject.h"
17#include "rbt_set.h"
18
19U_NAMESPACE_BEGIN
20
21class UnicodeFunctor;
22class UnicodeString;
23class UnicodeMatcher;
24class UnicodeReplacer;
25class Hashtable;
26
27/**
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.
33 *
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
42 * details.
43 */
44class U_I18N_API TransliterationRuleData : public UMemory {
45
46public:
47
48 // PUBLIC DATA MEMBERS
49
50 /**
51 * Rule table. May be empty.
52 */
53 TransliterationRuleSet ruleSet;
54
55 /**
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
62 * the stored rules.
63 */
64 Hashtable* variableNames;
65
66 /**
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).
74 */
75 UnicodeFunctor** variables;
76
77 /**
78 * The character that represents variables[0]. Characters
79 * variablesBase through variablesBase +
80 * variablesLength - 1 represent UnicodeFunctor objects.
81 */
82 UChar variablesBase;
83
84 /**
85 * The length of variables.
86 */
87 int32_t variablesLength;
88
89public:
90
91 /**
92 * Constructor
93 * @param status Output param set to success/failure code on exit.
94 */
95 TransliterationRuleData(UErrorCode& status);
96
97 /**
98 * Copy Constructor
99 */
100 TransliterationRuleData(const TransliterationRuleData&);
101
102 /**
103 * destructor
104 */
105 ~TransliterationRuleData();
106
107 /**
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
112 */
113 UnicodeFunctor* lookup(UChar32 standIn) const;
114
115 /**
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
121 */
122 UnicodeMatcher* lookupMatcher(UChar32 standIn) const;
123
124 /**
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
130 */
131 UnicodeReplacer* lookupReplacer(UChar32 standIn) const;
132
374ca955 133
b75a7d8f
A
134private:
135 TransliterationRuleData &operator=(const TransliterationRuleData &other); // forbid copying of this class
136};
137
138U_NAMESPACE_END
139
140#endif /* #if !UCONFIG_NO_TRANSLITERATION */
141
142#endif