34
|
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 pointer 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 |
* Swap used string pool.
|
|
179 |
*
|
|
180 |
* @param aStringPool New string pool to be used.
|
|
181 |
* Ownership not transferred!
|
|
182 |
*/
|
|
183 |
IMPORT_C void SwapStringPoolL( CXnDomStringPool* aStringPool );
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Count items in a list.
|
|
187 |
*/
|
|
188 |
TInt Count() const;
|
|
189 |
public: // Serializing
|
|
190 |
|
|
191 |
/**
|
|
192 |
* Get list's data size in bytes.
|
|
193 |
* @since Series 60 3.1
|
|
194 |
* @return Data size in bytes
|
|
195 |
*/
|
|
196 |
TInt Size() const;
|
|
197 |
|
|
198 |
/**
|
|
199 |
* Externalize list's data.
|
|
200 |
* @since Series 60 3.1
|
|
201 |
* @param aStream Output stream
|
|
202 |
*/
|
|
203 |
void ExternalizeL( RWriteStream& aStream ) const;
|
|
204 |
|
|
205 |
/**
|
|
206 |
* Internalize list's data.
|
|
207 |
* @since Series 60 3.1
|
|
208 |
* @param aStream Input stream
|
|
209 |
*/
|
|
210 |
void InternalizeL( RReadStream& aStream );
|
|
211 |
|
|
212 |
public: //Utility
|
|
213 |
|
|
214 |
/**
|
|
215 |
* Get list item type.
|
|
216 |
* @since Series 60 3.1
|
|
217 |
* @return List item type
|
|
218 |
*/
|
|
219 |
TListType Type() const
|
|
220 |
{
|
|
221 |
return iListType;
|
|
222 |
}
|
|
223 |
|
|
224 |
|
|
225 |
private:
|
|
226 |
|
|
227 |
/**
|
|
228 |
* C++ default constructor.
|
|
229 |
*/
|
|
230 |
CXnDomList( TListType aListType,
|
|
231 |
CXnDomStringPool* aStringPool,
|
|
232 |
TInt aGranularity=4 );
|
|
233 |
|
|
234 |
/**
|
|
235 |
* By default Symbian 2nd phase constructor is private.
|
|
236 |
*/
|
|
237 |
void ConstructL();
|
|
238 |
|
|
239 |
protected:
|
|
240 |
//List type
|
|
241 |
TListType iListType;
|
|
242 |
|
|
243 |
//Items are stored into a segmented array
|
|
244 |
RPointerArray<MXnDomListItem> iList;
|
|
245 |
|
|
246 |
private: // Data
|
|
247 |
// StringPool, not owned
|
|
248 |
CXnDomStringPool* iStringPool;
|
|
249 |
|
|
250 |
|
|
251 |
};
|
|
252 |
|
|
253 |
#endif // XN_DOM_LIST_H
|
|
254 |
|
|
255 |
// End of File
|