114
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Primary datatype for the entire Document Object Model.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
#ifndef hsps_DOM_NODE_H
|
|
21 |
#define hsps_DOM_NODE_H
|
|
22 |
|
|
23 |
// INCLUDES
|
|
24 |
#include <e32base.h>
|
|
25 |
#include <s32strm.h>
|
|
26 |
#include "mhspsdomlistitem.h"
|
|
27 |
|
|
28 |
// FORWARD DECLARATIONS
|
|
29 |
enum TContentType
|
|
30 |
{
|
|
31 |
EEmpty = 0,
|
|
32 |
EAny,
|
|
33 |
EPCData
|
|
34 |
};
|
|
35 |
|
|
36 |
class ChspsDomList;
|
|
37 |
class ChspsDomStringPool;
|
|
38 |
class ChspsNode;
|
|
39 |
|
|
40 |
// CLASS DECLARATION
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Class represents a single node in the document tree.
|
|
44 |
*
|
|
45 |
* @lib hspsdomdocument.lib
|
|
46 |
* @since S60 5.0
|
|
47 |
* @ingroup group_hspsdom
|
|
48 |
*/
|
|
49 |
class ChspsDomNode : public CBase, public MhspsDomListItem
|
|
50 |
{
|
|
51 |
|
|
52 |
public: // Constructors and destructor
|
|
53 |
|
|
54 |
/**
|
|
55 |
* Two-phased constructor.
|
|
56 |
*
|
|
57 |
* @since S60 5.0
|
|
58 |
* @param aName Name of node.
|
|
59 |
* @param aNS Namespace.
|
|
60 |
* @param aStringPool Attached string pool.
|
|
61 |
*/
|
|
62 |
static ChspsDomNode* NewL(
|
|
63 |
const TDesC8& aName,
|
|
64 |
const TDesC8& aNS,
|
|
65 |
ChspsDomStringPool& aStringPool );
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Two-phased constructor.
|
|
69 |
*
|
|
70 |
* @since S60 5.0
|
|
71 |
* @param aName Name of node (string pool index).
|
|
72 |
* @param aNS Namespace (string pool index).
|
|
73 |
* @param aStringPool Attached string pool.
|
|
74 |
*/
|
|
75 |
static ChspsDomNode* NewL(
|
|
76 |
const TInt aName,
|
|
77 |
const TInt aNS,
|
|
78 |
ChspsDomStringPool& aStringPool );
|
|
79 |
|
|
80 |
/**
|
|
81 |
* Two-phased stream constructor.
|
|
82 |
*
|
|
83 |
* @since S60 5.0
|
|
84 |
* @param aStream Source stream.
|
|
85 |
* @param aStringPool Attached string pool.
|
|
86 |
*/
|
|
87 |
static ChspsDomNode* NewL( RReadStream& aStream, ChspsDomStringPool& aStringPool );
|
|
88 |
|
|
89 |
/**
|
|
90 |
* Destructor.
|
|
91 |
*/
|
|
92 |
virtual ~ChspsDomNode();
|
|
93 |
|
|
94 |
public: // New functions
|
|
95 |
/**
|
|
96 |
* Makes a clone from this node and it's child nodes.
|
|
97 |
*
|
|
98 |
* @since S60 5.0
|
|
99 |
* @param aStringPool A new string pool.
|
|
100 |
* @param aFastClone If ETrue, then fast mode cloning is used.
|
|
101 |
*
|
|
102 |
* @return Pointer to a clone node. Caller has the ownership.
|
|
103 |
*/
|
|
104 |
IMPORT_C ChspsDomNode* CloneL( ChspsDomStringPool& aStringPool,
|
|
105 |
const TBool aFastClone = EFalse );
|
|
106 |
|
|
107 |
/**
|
|
108 |
* Makes a clone only from this node.
|
|
109 |
*
|
|
110 |
* @since S60 5.0
|
|
111 |
* @param aStringPool A new string pool.
|
|
112 |
* @return Pointer to a clone node. Caller has the ownership.
|
|
113 |
*/
|
|
114 |
IMPORT_C ChspsDomNode* CloneWithoutKidsL( ChspsDomStringPool& aStringPool );
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Contructs a ref node from this node and its child's.
|
|
118 |
*
|
|
119 |
* @since S60 5.0
|
|
120 |
* @return Pointer to a ref node. Caller has the ownership.
|
|
121 |
*/
|
|
122 |
IMPORT_C ChspsDomNode* CreateRefNodeL();
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Get the namespace of this node.
|
|
126 |
*
|
|
127 |
* @since S60 5.0
|
|
128 |
* @return Pointer to the namespace buffer.
|
|
129 |
*/
|
|
130 |
IMPORT_C const TDesC8& Namespace();
|
|
131 |
|
|
132 |
/**
|
|
133 |
* Node's attributes exist in a list.
|
|
134 |
*
|
|
135 |
* @since S60 5.0
|
|
136 |
* @return Reference to a attribute list.
|
|
137 |
*/
|
|
138 |
IMPORT_C ChspsDomList& AttributeList()const;
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Node need to know it's parent.
|
|
142 |
*
|
|
143 |
* @since S60 5.0
|
|
144 |
* @param aParent Pointer to this node parent.
|
|
145 |
*/
|
|
146 |
IMPORT_C void SetParent( ChspsDomNode* aParent );
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Node's parent is enquered e.g to traverse the document.
|
|
150 |
*
|
|
151 |
* @since S60 5.0
|
|
152 |
* @return Pointer to a parent node.
|
|
153 |
*/
|
|
154 |
IMPORT_C ChspsDomNode* Parent() const;
|
|
155 |
|
|
156 |
/**
|
|
157 |
* Node id is for a uiengine use.
|
|
158 |
*
|
|
159 |
* @since S60 5.0
|
|
160 |
* @param aNodeId Unique identifier.
|
|
161 |
*/
|
|
162 |
IMPORT_C void SetNodeId( const TInt aNodeId );
|
|
163 |
|
|
164 |
/**
|
|
165 |
* Get the node unique identifier.
|
|
166 |
*
|
|
167 |
* @since S60 5.0
|
|
168 |
* @return Node unique identifier.
|
|
169 |
*/
|
|
170 |
IMPORT_C TInt NodeId() const;
|
|
171 |
|
|
172 |
/**
|
|
173 |
* Get the node unique identifier.
|
|
174 |
*
|
|
175 |
* @since S60 5.0
|
|
176 |
* @return Node unique identifier.
|
|
177 |
*/
|
|
178 |
IMPORT_C TInt ItemIndex( const MhspsDomListItem& aItem )const;
|
|
179 |
|
|
180 |
/**
|
|
181 |
* Access to child nodes.
|
|
182 |
*
|
|
183 |
* @since S60 5.0
|
|
184 |
* @return Pointer to a list of child nodes.
|
|
185 |
*/
|
|
186 |
IMPORT_C ChspsDomList& ChildNodes();
|
|
187 |
|
|
188 |
/**
|
|
189 |
* Child nodes of this node are needed to be able to
|
|
190 |
* traverse the document.
|
|
191 |
*
|
|
192 |
* @since S60 5.0
|
|
193 |
* @param aNode Node owns it's childs.
|
|
194 |
*/
|
|
195 |
IMPORT_C void AddChildL( ChspsDomNode* aNode );
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Child nodes of this node are needed to be able to
|
|
199 |
* traverse the document.
|
|
200 |
*
|
|
201 |
* @since S60 5.0
|
|
202 |
* @param aNode Node owns it's childs.
|
|
203 |
* @param aIndex Index in list where the node is added.
|
|
204 |
*/
|
|
205 |
IMPORT_C void AddChildL( ChspsDomNode* aNode, TInt aIndex );
|
|
206 |
|
|
207 |
/**
|
|
208 |
* Removes node from the child list and frees memory allocated
|
|
209 |
* for a child node and it descendants.
|
|
210 |
*
|
|
211 |
* @since S60 5.0
|
|
212 |
* @param aNode Node to be released.
|
|
213 |
*/
|
|
214 |
IMPORT_C void DeleteChild( ChspsDomNode* aNode );
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Replaces a child node with the other node. Memory allocated for
|
|
218 |
* the node is freed.
|
|
219 |
*
|
|
220 |
* @since S60 5.0
|
|
221 |
* @param aNode Node to be replaced.
|
|
222 |
* @param aNewNode New node.
|
|
223 |
*/
|
|
224 |
IMPORT_C void ReplaceChildL( ChspsDomNode* aNode, ChspsDomNode* aNewNode );
|
|
225 |
|
|
226 |
/**
|
|
227 |
* Get the character data.
|
|
228 |
*
|
|
229 |
* @since S60 5.0
|
|
230 |
* @return Reference to a buffer.
|
|
231 |
*/
|
|
232 |
IMPORT_C const TDesC8& PCData();
|
|
233 |
|
|
234 |
/**
|
|
235 |
* Append PCData into node. Thus it is possible to have
|
|
236 |
* "<root>a <first/> c <second/> e </root>" PCData.
|
|
237 |
*
|
|
238 |
* @since S60 5.0
|
|
239 |
* @param aPCData UTF-8 encoded parsed character data.
|
|
240 |
*/
|
|
241 |
IMPORT_C void AppendPCDataL( const TDesC8& aPCData );
|
|
242 |
|
|
243 |
/**
|
|
244 |
* Set parsed character data.
|
|
245 |
*
|
|
246 |
* @since S60 5.0
|
|
247 |
* @param aPCData UTF-8 encoded parsed character data.
|
|
248 |
*/
|
|
249 |
IMPORT_C void SetPCDataL( const TDesC8& aPCData );
|
|
250 |
|
|
251 |
/**
|
|
252 |
* Set content type.
|
|
253 |
*
|
|
254 |
* @since S60 5.0
|
|
255 |
* @return content type.
|
|
256 |
*/
|
|
257 |
IMPORT_C const TContentType& ContentType();
|
|
258 |
|
|
259 |
/**
|
|
260 |
* Get content type.
|
|
261 |
*
|
|
262 |
* @since S60 5.0
|
|
263 |
* @param aContentType content type.
|
|
264 |
*/
|
|
265 |
IMPORT_C void SetContentType( const TContentType& aContentType );
|
|
266 |
|
|
267 |
/**
|
|
268 |
* Recursive function to count all child nodes belonging
|
|
269 |
* to this node.
|
|
270 |
*
|
|
271 |
* @since S60 5.0
|
|
272 |
* @return This node and it's all childs count.
|
|
273 |
*/
|
|
274 |
IMPORT_C TInt DescendantCount() const;
|
|
275 |
|
|
276 |
/**
|
|
277 |
* Get reference to the dom's string pool.
|
|
278 |
*
|
|
279 |
* @since S60 5.0
|
|
280 |
* @return Reference to string pool.
|
|
281 |
*/
|
|
282 |
IMPORT_C ChspsDomStringPool& StringPool() const;
|
|
283 |
|
|
284 |
/**
|
|
285 |
* Mark this node as a reference node.
|
|
286 |
*
|
|
287 |
* @since S60 5.0
|
|
288 |
* @param aRefNode ETrue if node is a reference node.
|
|
289 |
*/
|
|
290 |
IMPORT_C void SetRefNode( TBool aRefNode=ETrue );
|
|
291 |
|
|
292 |
/**
|
|
293 |
* Check if this node is referring to some global node.
|
|
294 |
*
|
|
295 |
* @since S60 5.0
|
|
296 |
* @return ETrue if this is a reference node.
|
|
297 |
*/
|
|
298 |
IMPORT_C TBool IsRefNode() const;
|
|
299 |
|
|
300 |
/**
|
|
301 |
* Deletes attributes when they are not needed anymore.
|
|
302 |
* I.e. UIEngine has copied them into property list.
|
|
303 |
*
|
|
304 |
* @since S60 5.0
|
|
305 |
*/
|
|
306 |
IMPORT_C void DeleteAttributeList();
|
|
307 |
|
|
308 |
/**
|
|
309 |
* Returns value of given attribute.
|
|
310 |
*
|
|
311 |
* @param aAttribute Name of the attribute.
|
|
312 |
* @since S60 5.0
|
|
313 |
* @return Value of an attribute.
|
|
314 |
*/
|
|
315 |
IMPORT_C const TDesC8& AttributeValue(const TDesC8& aAttribute) const;
|
|
316 |
|
|
317 |
public: //From MhspsDomListItem
|
|
318 |
|
|
319 |
/**
|
|
320 |
* Documented in ChspsDomListItem::Size
|
|
321 |
*/
|
|
322 |
TInt Size() const;
|
|
323 |
|
|
324 |
/**
|
|
325 |
* Documented in ChspsDomListItem::ExternalizeL
|
|
326 |
*/
|
|
327 |
void ExternalizeL( RWriteStream& aStream ) const;
|
|
328 |
|
|
329 |
/**
|
|
330 |
* Documented in ChspsDomListItem::InternalizeL
|
|
331 |
*/
|
|
332 |
void InternalizeL( RReadStream& aStream );
|
|
333 |
|
|
334 |
|
|
335 |
/**
|
|
336 |
* Documented in ChspsDomListItem::Name
|
|
337 |
*/
|
|
338 |
IMPORT_C const TDesC8& Name();
|
|
339 |
|
|
340 |
public:
|
|
341 |
|
|
342 |
/**
|
|
343 |
* Sets pointer to associated layout node.
|
|
344 |
*
|
|
345 |
* @since S60 5.0
|
|
346 |
* @param aNode Pointer to associated layout node.
|
|
347 |
*/
|
|
348 |
IMPORT_C void SetLayoutNode(ChspsNode* aNode);
|
|
349 |
|
|
350 |
/**
|
|
351 |
* Returns pointer to associated layout node.
|
|
352 |
*
|
|
353 |
* @since S60 5.0
|
|
354 |
* @return Pointer to associated layout node.
|
|
355 |
*/
|
|
356 |
IMPORT_C ChspsNode* LayoutNode();
|
|
357 |
private:
|
|
358 |
/**
|
|
359 |
* C++ default constructor.
|
|
360 |
*/
|
|
361 |
ChspsDomNode( ChspsDomStringPool& aStringPool );
|
|
362 |
|
|
363 |
/**
|
|
364 |
* By default Symbian 2nd phase constructor is private.
|
|
365 |
*/
|
|
366 |
void ConstructL( const TDesC8& aName, const TDesC8& aNS );
|
|
367 |
|
|
368 |
/**
|
|
369 |
* By default Symbian 2nd phase constructor is private.
|
|
370 |
*/
|
|
371 |
void ConstructL( const TInt aName, const TInt aNS );
|
|
372 |
|
|
373 |
/**
|
|
374 |
* Construct members
|
|
375 |
*/
|
|
376 |
void Construct2L();
|
|
377 |
|
|
378 |
private: // Data
|
|
379 |
|
|
380 |
//iNameRef refers to a name string in a string pool
|
|
381 |
TInt iNameRef;
|
|
382 |
|
|
383 |
//iNSRef refers to a namespace string in a string pool
|
|
384 |
TInt iNSRef;
|
|
385 |
|
|
386 |
//iStringPool is used to resolve strings based on references
|
|
387 |
ChspsDomStringPool& iStringPool;
|
|
388 |
|
|
389 |
//Type of the elements content
|
|
390 |
TContentType iContentType;
|
|
391 |
|
|
392 |
//Parsed character data
|
|
393 |
HBufC8* iPCData;
|
|
394 |
|
|
395 |
//Node's parent pointer
|
|
396 |
ChspsDomNode* iParentNode;
|
|
397 |
|
|
398 |
//Node unique identifier
|
|
399 |
TInt iNodeId;
|
|
400 |
|
|
401 |
//Node's childs are collected into a list. Childs are owned by node
|
|
402 |
ChspsDomList* iChildList;
|
|
403 |
|
|
404 |
//Node is the owner of the attributes
|
|
405 |
ChspsDomList* iAttributeList;
|
|
406 |
|
|
407 |
//Flag is set if this node is reference node
|
|
408 |
TBool iRefNode;
|
|
409 |
|
|
410 |
// Not owned
|
|
411 |
ChspsNode* iLayoutNode;
|
|
412 |
};
|
|
413 |
|
|
414 |
#endif // hsps_DOM_NODE_H
|
|
415 |
|
|
416 |
// End of File
|