|
1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Implementation of nodes container |
|
15 // |
|
16 |
|
17 |
|
18 |
|
19 /** |
|
20 @file |
|
21 @internalComponent |
|
22 @released |
|
23 */ |
|
24 #ifndef XMLENGOWNED_NODES_CONTAINER_H |
|
25 #define XMLENGOWNED_NODES_CONTAINER_H |
|
26 |
|
27 #include <e32base.h> |
|
28 #include <libxml2_tree.h> |
|
29 |
|
30 |
|
31 |
|
32 /** |
|
33 * Container for nodes owned by document |
|
34 * |
|
35 */ |
|
36 class CXmlEngOwnedNodesContainer: public CBase |
|
37 { |
|
38 public: |
|
39 /** |
|
40 * Creates an instance of CXmlEngOwnedNodesContainer. |
|
41 * |
|
42 */ |
|
43 static CXmlEngOwnedNodesContainer* NewL(); |
|
44 |
|
45 /** |
|
46 * Destructor. |
|
47 * |
|
48 */ |
|
49 ~CXmlEngOwnedNodesContainer(); |
|
50 |
|
51 /** |
|
52 * Adds an owned node. |
|
53 * |
|
54 * @param aNodePtr A pointer to some node to be added into the container |
|
55 * |
|
56 * @note This method does not check whether the pointer is already in the container |
|
57 * @note In OOM situation the node is destroyed before leave occurs |
|
58 */ |
|
59 void Add(xmlNodePtr aNodePtr); |
|
60 |
|
61 /** |
|
62 * Excludes node pointer from the list of owned nodes. |
|
63 * Does nothing if provided node pointer is not on the list. |
|
64 * |
|
65 * @param aNodePtr A pointer to node that should be removed. |
|
66 */ |
|
67 void Remove(xmlNodePtr aNodePtr); |
|
68 |
|
69 /** |
|
70 * Performs clean up of the list |
|
71 * |
|
72 */ |
|
73 void RemoveAll(); |
|
74 |
|
75 /** |
|
76 * Performs clean up of all owned nodes: |
|
77 * xmlFreeNode is called on every contained pointer |
|
78 * |
|
79 */ |
|
80 void FreeAll(); |
|
81 |
|
82 private: |
|
83 /** |
|
84 * Default constructor. |
|
85 * |
|
86 */ |
|
87 CXmlEngOwnedNodesContainer() {} |
|
88 |
|
89 /** |
|
90 * Searches for a node in the list |
|
91 * |
|
92 * @param aPtr Pointer to a libxml2 node |
|
93 * @return Index in the list of nodes [0; iLastIndex-1] or iLastIndex if not found |
|
94 */ |
|
95 TUint Lookup(xmlNodePtr aPtr); |
|
96 |
|
97 public: |
|
98 /** Node pointer */ |
|
99 xmlNodePtr iNodes; |
|
100 /** Last node pointer */ |
|
101 xmlNodePtr iLast; |
|
102 /** Element count */ |
|
103 TUint iCount; |
|
104 }; |
|
105 |
|
106 |
|
107 |
|
108 #endif /* XMLENGOWNED_NODES_CONTAINER_H */ |