|
1 /* |
|
2 * Copyright (c) 2005,2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: List class to hold MXnDomListItem objects. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifndef XN_DOM_LIST_H |
|
21 #define XN_DOM_LIST_H |
|
22 |
|
23 // INCLUDES |
|
24 #include <e32base.h> |
|
25 #include <s32strm.h> |
|
26 |
|
27 |
|
28 // FORWARD DECLARATIONS |
|
29 class MXnDomListItem; |
|
30 class CXnDomStringPool; |
|
31 |
|
32 // CLASS DECLARATION |
|
33 |
|
34 /** |
|
35 * @ingroup group_domdocument |
|
36 * Represents streamable list object, which holds MXnDomListItem objects. |
|
37 * |
|
38 * @lib xndomdocument.lib |
|
39 * @since Series 60 3.1 |
|
40 */ |
|
41 class CXnDomList : public CBase |
|
42 { |
|
43 public: |
|
44 enum TListType |
|
45 { |
|
46 ENodeList=0, |
|
47 EAttributeList, |
|
48 EPropertyList, |
|
49 EPropertyValueList |
|
50 }; |
|
51 public: // Constructors and destructor |
|
52 |
|
53 /** |
|
54 * Two-phased constructor. |
|
55 */ |
|
56 static CXnDomList* NewL( TListType aListType, |
|
57 CXnDomStringPool& aStringPool, |
|
58 TInt aGranularity=4); |
|
59 |
|
60 /** |
|
61 * Two-phased stream constructor. |
|
62 */ |
|
63 static CXnDomList* NewL( |
|
64 RReadStream& aStream, |
|
65 CXnDomStringPool& aStringPool ); |
|
66 |
|
67 /** |
|
68 * Destructor. |
|
69 */ |
|
70 virtual ~CXnDomList(); |
|
71 |
|
72 public: // Adding and removing |
|
73 |
|
74 /** |
|
75 * Frees memory allocated for all items in a list. |
|
76 * @since Series 60 3.1 |
|
77 */ |
|
78 IMPORT_C void Reset(); |
|
79 |
|
80 /** |
|
81 * List owns items. |
|
82 * @since Series 60 3.1 |
|
83 * @param aListItem to add |
|
84 */ |
|
85 IMPORT_C void AddItemL( MXnDomListItem* aListItem ); |
|
86 |
|
87 /** |
|
88 * List owns items. |
|
89 * @since Series 60 3.1 |
|
90 * @param aListItem to add |
|
91 * @param aIndex Index in list where the item is added |
|
92 */ |
|
93 IMPORT_C void AddItemL( MXnDomListItem* aListItem, TInt aIndex ); |
|
94 |
|
95 /** |
|
96 * Remove item from list. |
|
97 * @since Series 60 3.1 |
|
98 * @param Index to aList item to remove |
|
99 */ |
|
100 IMPORT_C void RemoveItem( TInt aIndex ); |
|
101 |
|
102 /** |
|
103 * Delete item from list. |
|
104 * @since Series 60 3.1 |
|
105 * @param Index to aList item to delete |
|
106 */ |
|
107 IMPORT_C void DeleteItem( TInt aIndex ); |
|
108 |
|
109 /** |
|
110 * Remove item from list. |
|
111 * @since Series 60 3.1 |
|
112 * @param aList item to remove |
|
113 */ |
|
114 IMPORT_C void RemoveItem( MXnDomListItem* aItem ); |
|
115 |
|
116 /** |
|
117 * Delete item from list. |
|
118 * @since Series 60 3.1 |
|
119 * @param aList item to delete |
|
120 */ |
|
121 IMPORT_C void DeleteItem( MXnDomListItem* aItem ); |
|
122 |
|
123 public: // Accessing |
|
124 /** |
|
125 * List items are accessed by index, i.e like arrays |
|
126 * @since Series 60 3.1 |
|
127 * @param aIndex list item index |
|
128 * @return Pointer to a a list item |
|
129 */ |
|
130 IMPORT_C MXnDomListItem* Item( TInt aIndex )const; |
|
131 |
|
132 /** |
|
133 * Number of items in a list. |
|
134 * @since Series 60 3.1 |
|
135 * @return Item count |
|
136 */ |
|
137 IMPORT_C TInt Length() const; |
|
138 |
|
139 /** |
|
140 * Get the first item in a list. |
|
141 * @since Series 60 3.1 |
|
142 * @return Pointer to the first item in a list |
|
143 */ |
|
144 IMPORT_C MXnDomListItem* First(); |
|
145 |
|
146 /** |
|
147 * The last item in a list |
|
148 * @since Series 60 3.1 |
|
149 * @return Pointer to the last item in a list |
|
150 */ |
|
151 IMPORT_C MXnDomListItem* Last(); |
|
152 |
|
153 /** |
|
154 * Find list item by item name. Searches list items |
|
155 * which have name attribute. |
|
156 * @since Series 60 3.1 |
|
157 * @param aName UTF8 encoded item's name to be searched |
|
158 * @return Pointer to the list item, NULL if not exist. |
|
159 */ |
|
160 IMPORT_C MXnDomListItem* FindByName( const TDesC8& aName ); |
|
161 |
|
162 /** |
|
163 * Get item index |
|
164 * @since Series 60 3.1 |
|
165 * @param aItem Item to be searched |
|
166 * @return Item index or KErrNotFound if not found |
|
167 */ |
|
168 IMPORT_C TInt ItemIndex( const MXnDomListItem& aItem )const; |
|
169 |
|
170 /** |
|
171 * Get reference to the dom's string pool. |
|
172 * @since Series 60 3.1 |
|
173 * @return Reference to string pool |
|
174 */ |
|
175 IMPORT_C CXnDomStringPool& StringPool() const; |
|
176 |
|
177 /** |
|
178 * Count items in a list. |
|
179 */ |
|
180 TInt Count() const; |
|
181 public: // Serializing |
|
182 |
|
183 /** |
|
184 * Get list's data size in bytes. |
|
185 * @since Series 60 3.1 |
|
186 * @return Data size in bytes |
|
187 */ |
|
188 TInt Size() const; |
|
189 |
|
190 /** |
|
191 * Externalize list's data. |
|
192 * @since Series 60 3.1 |
|
193 * @param aStream Output stream |
|
194 */ |
|
195 void ExternalizeL( RWriteStream& aStream ) const; |
|
196 |
|
197 /** |
|
198 * Internalize list's data. |
|
199 * @since Series 60 3.1 |
|
200 * @param aStream Input stream |
|
201 */ |
|
202 void InternalizeL( RReadStream& aStream ); |
|
203 |
|
204 public: //Utility |
|
205 |
|
206 /** |
|
207 * Get list item type. |
|
208 * @since Series 60 3.1 |
|
209 * @return List item type |
|
210 */ |
|
211 TListType Type() const |
|
212 { |
|
213 return iListType; |
|
214 } |
|
215 |
|
216 |
|
217 private: |
|
218 |
|
219 /** |
|
220 * C++ default constructor. |
|
221 */ |
|
222 CXnDomList( TListType aListType, |
|
223 CXnDomStringPool& aStringPool, |
|
224 TInt aGranularity=4 ); |
|
225 |
|
226 /** |
|
227 * By default Symbian 2nd phase constructor is private. |
|
228 */ |
|
229 void ConstructL(); |
|
230 |
|
231 protected: |
|
232 //List type |
|
233 TListType iListType; |
|
234 |
|
235 //Items are stored into a segmented array |
|
236 RPointerArray<MXnDomListItem> iList; |
|
237 |
|
238 private: // Data |
|
239 // StringPool, not owned |
|
240 CXnDomStringPool& iStringPool; |
|
241 |
|
242 |
|
243 }; |
|
244 |
|
245 #endif // XN_DOM_LIST_H |
|
246 |
|
247 // End of File |