]>
Commit | Line | Data |
---|---|---|
374ca955 A |
1 | /* |
2 | ********************************************************************** | |
729e4ab9 | 3 | * Copyright (C) 1998-2008, International Business Machines |
374ca955 A |
4 | * Corporation and others. All Rights Reserved. |
5 | ********************************************************************** | |
6 | */ | |
7 | ||
8 | #ifndef __LEINSERTIONLIST_H | |
9 | #define __LEINSERTIONLIST_H | |
10 | ||
11 | #include "LETypes.h" | |
12 | ||
13 | U_NAMESPACE_BEGIN | |
14 | ||
15 | struct InsertionRecord; | |
16 | ||
17 | /** | |
18 | * This class encapsulates the callback used by <code>LEInsertionList</code> | |
19 | * to apply an insertion from the insertion list. | |
20 | * | |
21 | * @internal | |
22 | */ | |
73c04bcf | 23 | class U_LAYOUT_API LEInsertionCallback |
374ca955 A |
24 | { |
25 | public: | |
26 | /** | |
27 | * This method will be called by <code>LEInsertionList::applyInsertions</code> for each | |
28 | * entry on the insertion list. | |
29 | * | |
30 | * @param atPosition the position of the insertion | |
31 | * @param count the number of glyphs to insert | |
32 | * @param newGlyphs the address of the glyphs to insert | |
33 | * | |
34 | * @return <code>TRUE</code> if <code>LEInsertions::applyInsertions</code> should | |
35 | * stop after applying this insertion. | |
36 | * | |
37 | * @internal | |
38 | */ | |
39 | virtual le_bool applyInsertion(le_int32 atPosition, le_int32 count, LEGlyphID newGlyphs[]) = 0; | |
73c04bcf A |
40 | |
41 | /** | |
42 | * The destructor | |
43 | */ | |
44 | virtual ~LEInsertionCallback(); | |
374ca955 A |
45 | }; |
46 | ||
47 | /** | |
48 | * This class is used to keep track of insertions to an array of | |
49 | * <code>LEGlyphIDs</code>. The insertions are kept on a linked | |
50 | * list of <code>InsertionRecords</code> so that the glyph array | |
51 | * doesn't have to be grown for each insertion. The insertions are | |
52 | * stored on the list from leftmost to rightmost to make it easier | |
53 | * to do the insertions. | |
54 | * | |
55 | * The insertions are applied to the array by calling the | |
56 | * <code>applyInsertions</code> method, which calls a client | |
57 | * supplied <code>LEInsertionCallback</code> object to actually | |
58 | * apply the individual insertions. | |
59 | * | |
60 | * @internal | |
61 | */ | |
62 | class LEInsertionList : public UObject | |
63 | { | |
64 | public: | |
65 | /** | |
66 | * Construct an empty insertion list. | |
67 | * | |
68 | * @param rightToLeft <code>TRUE</code> if the glyphs are stored | |
69 | * in the array in right to left order. | |
70 | * | |
71 | * @internal | |
72 | */ | |
73 | LEInsertionList(le_bool rightToLeft); | |
74 | ||
75 | /** | |
76 | * The destructor. | |
77 | */ | |
78 | ~LEInsertionList(); | |
79 | ||
80 | /** | |
81 | * Add an entry to the insertion list. | |
82 | * | |
83 | * @param position the glyph at this position in the array will be | |
84 | * replaced by the new glyphs. | |
85 | * @param count the number of new glyphs | |
729e4ab9 | 86 | * @param success set to an error code if the auxillary data cannot be retrieved. |
374ca955 A |
87 | * |
88 | * @return the address of an array in which to store the new glyphs. This will | |
89 | * <em>not</em> be in the glyph array. | |
90 | * | |
91 | * @internal | |
92 | */ | |
729e4ab9 | 93 | LEGlyphID *insert(le_int32 position, le_int32 count, LEErrorCode &success); |
374ca955 A |
94 | |
95 | /** | |
96 | * Return the number of new glyphs that have been inserted. | |
97 | * | |
98 | * @return the number of new glyphs which have been inserted | |
99 | * | |
100 | * @internal | |
101 | */ | |
102 | le_int32 getGrowAmount(); | |
103 | ||
104 | /** | |
105 | * Call the <code>LEInsertionCallback</code> once for each | |
106 | * entry on the insertion list. | |
107 | * | |
108 | * @param callback the <code>LEInsertionCallback</code> to call for each insertion. | |
109 | * | |
110 | * @return <code>TRUE</code> if <code>callback</code> returned <code>TRUE</code> to | |
111 | * terminate the insertion list processing. | |
112 | * | |
113 | * @internal | |
114 | */ | |
115 | le_bool applyInsertions(LEInsertionCallback *callback); | |
116 | ||
117 | /** | |
118 | * Empty the insertion list and free all associated | |
119 | * storage. | |
120 | * | |
121 | * @internal | |
122 | */ | |
123 | void reset(); | |
124 | ||
125 | /** | |
126 | * ICU "poor man's RTTI", returns a UClassID for the actual class. | |
127 | * | |
128 | * @stable ICU 2.8 | |
129 | */ | |
130 | virtual UClassID getDynamicClassID() const; | |
131 | ||
132 | /** | |
133 | * ICU "poor man's RTTI", returns a UClassID for this class. | |
134 | * | |
135 | * @stable ICU 2.8 | |
136 | */ | |
137 | static UClassID getStaticClassID(); | |
138 | ||
139 | private: | |
140 | ||
141 | /** | |
142 | * The head of the insertion list. | |
143 | * | |
144 | * @internal | |
145 | */ | |
146 | InsertionRecord *head; | |
147 | ||
148 | /** | |
149 | * The tail of the insertion list. | |
150 | * | |
151 | * @internal | |
152 | */ | |
153 | InsertionRecord *tail; | |
154 | ||
155 | /** | |
156 | * The total number of new glyphs on the insertion list. | |
157 | * | |
158 | * @internal | |
159 | */ | |
160 | le_int32 growAmount; | |
161 | ||
162 | /** | |
163 | * Set to <code>TRUE</code> if the glyphs are in right | |
164 | * to left order. Since we want the rightmost insertion | |
165 | * to be first on the list, we need to append the | |
166 | * insertions in this case. Otherwise they're prepended. | |
167 | * | |
168 | * @internal | |
169 | */ | |
170 | le_bool append; | |
171 | }; | |
172 | ||
173 | U_NAMESPACE_END | |
174 | #endif | |
175 |