|
1 /* |
|
2 * Copyright (c) 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: SIMPLE element |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #ifndef simpleelement_H |
|
22 #define simpleelement_H |
|
23 |
|
24 #include <e32std.h> |
|
25 #include <SenBaseElement.h> |
|
26 #include "msimpleelement.h" |
|
27 #include "msimpleattribute.h" |
|
28 |
|
29 // FORWARD DECLARATION |
|
30 class MSimpleNamespace; |
|
31 class CSenElement; |
|
32 class CSimpleAttribute; |
|
33 class CSimpleElement; |
|
34 |
|
35 /** |
|
36 * CSimpleElement |
|
37 * |
|
38 * SIMPLE element. |
|
39 * |
|
40 * @lib simplexmlutils |
|
41 * @since S60 v3.1 |
|
42 */ |
|
43 |
|
44 class CSimpleElement : public CBase, public MSimpleElement |
|
45 { |
|
46 |
|
47 public: |
|
48 |
|
49 /** |
|
50 * Two-phased constructor. |
|
51 * @since S60 v3.1 |
|
52 */ |
|
53 static CSimpleElement* NewL( const TDesC8& aNsUri, |
|
54 const TDesC8& aLocalName ); |
|
55 |
|
56 /** |
|
57 * Two-phased constructor. |
|
58 * @since S60 v3.1 |
|
59 * @param aElement base element |
|
60 * @param aOwn whethre ownership is transferred |
|
61 */ |
|
62 static CSimpleElement* NewL( |
|
63 CSenElement* aElement, |
|
64 TBool aOwn ); |
|
65 |
|
66 /** |
|
67 * Destructor. |
|
68 */ |
|
69 virtual ~CSimpleElement(); |
|
70 |
|
71 /** |
|
72 * @return Base class implementation |
|
73 */ |
|
74 CSenElement* BaseElement(); |
|
75 |
|
76 /** |
|
77 * From MSimpleElement |
|
78 * Adds an attribute. If attribute is already existing, |
|
79 * the value of the attribute will be replaced. |
|
80 * |
|
81 * @since Series60 3.1 |
|
82 * @param aName Name of the attribute to be added. |
|
83 * @param aValue Value of the attribute to be added. |
|
84 */ |
|
85 void AddAttr8L(const TDesC8& aName, const TDesC8& aValue); |
|
86 |
|
87 // from base class MSimpleElement |
|
88 |
|
89 |
|
90 /** |
|
91 * From MSimpleElement |
|
92 * Destroy this element entity and all its descendant elements |
|
93 * |
|
94 * @since S60 v3.1 |
|
95 */ |
|
96 void Close(); |
|
97 |
|
98 /** |
|
99 * From MSimpleElement |
|
100 * Getter for Element's local name. |
|
101 * LocalName and Namespace are given in factory method. |
|
102 * @return KNullDesC if not set |
|
103 */ |
|
104 const TDesC8& LocalName(); |
|
105 |
|
106 /** |
|
107 * From MSimpleElement |
|
108 * Getter for Element's default namespace. |
|
109 * |
|
110 * @since S60 v3.1 |
|
111 * @return const pointer to the CSenNamespace object of this Element. |
|
112 * NULL if not set. Ownership is transferred. |
|
113 */ |
|
114 MSimpleNamespace* DefNamespaceL(); |
|
115 |
|
116 /** |
|
117 * From MSimpleElement |
|
118 * Method for checking if the element has any content within. |
|
119 * |
|
120 * @since S60 v3.1 |
|
121 * @return ETrue if has content, EFalse if not. |
|
122 */ |
|
123 TBool HasContent(); |
|
124 |
|
125 /** |
|
126 * From MSimpleElement |
|
127 * Getter for the content of the element, unicode version. |
|
128 * |
|
129 * @since S60 v3.1 |
|
130 * @return content as unicode. Ownership IS TRANSFERRED to the caller. |
|
131 */ |
|
132 HBufC* ContentUnicodeL(); |
|
133 |
|
134 /** |
|
135 * From MSimpleElement |
|
136 * Sets the content to the element. Old content is overwritten. |
|
137 * |
|
138 * @since S60 v3.1 |
|
139 * @param aContent: The content to be set. Can be KNullDesC |
|
140 */ |
|
141 void SetContentUnicodeL(const TDesC& aContent); |
|
142 |
|
143 /** |
|
144 * From MSimpleElement |
|
145 * Getting the child elements of this element. |
|
146 * |
|
147 * @since Series60 3.1 |
|
148 * @param aElementArray: Array to be filled with the matching elements, |
|
149 * or empty array if no matching found. |
|
150 * Any modifications made on the returned items |
|
151 * modify the real childs too. |
|
152 * @return KErrNone ok |
|
153 * KErrNotFound No child elements exist. |
|
154 */ |
|
155 TInt SimpleElementsL( RPointerArray<MSimpleElement>& aElementArray ); |
|
156 |
|
157 /** |
|
158 * From MSimpleElement |
|
159 * Gets the value of the given attribute. |
|
160 * |
|
161 * @since Series60 3.1 |
|
162 * @param aName: Name of the attribute in question. |
|
163 * @return the value of the attribute, or NULL if not found. Ownership is |
|
164 * TRANSFERRED. |
|
165 */ |
|
166 HBufC* AttrValueLC( const TDesC8& aName ); |
|
167 |
|
168 /** |
|
169 * Gets the value of the given attribute. |
|
170 * @param aName: Name of the attribute in question. |
|
171 * @return the value of the attribute, or NULL if not found. Ownership is |
|
172 * NOT TRANSFERRED. |
|
173 */ |
|
174 const TDesC8* AttrValue(const TDesC8& aName); |
|
175 |
|
176 /** |
|
177 * From MSimpleElement |
|
178 * Adds an attribute. If attribute is already existing, |
|
179 * the value of the attribute will be replaced. |
|
180 * |
|
181 * @since Series60 3.1 |
|
182 * @param aName Name of the attribute to be added. |
|
183 * @param aValue Value of the attribute to be added. |
|
184 */ |
|
185 void AddAttrL(const TDesC8& aName, const TDesC& aValue); |
|
186 |
|
187 /** |
|
188 * From MSimpleElement |
|
189 * Gets all the attributes of this element in an array. |
|
190 * |
|
191 * @since Series60 3.1 |
|
192 * @param aArray: Array to be filled with the attributes, |
|
193 * or empty array if no matching found. |
|
194 * @return KErrNone ok |
|
195 * KErrNotFound No child elements exist. |
|
196 */ |
|
197 TInt SimpleAttributesL( RPointerArray<MSimpleAttribute>& aArray ); |
|
198 |
|
199 /** |
|
200 * From MSimpleElement |
|
201 * Gets the parent element of this element. |
|
202 * |
|
203 * @since Series60 3.1 |
|
204 * @return the parent element or NULL if no parent set. |
|
205 * Ownership is IS TRANSFERRED to the caller. |
|
206 */ |
|
207 CSimpleElement* SimpleParentL(); |
|
208 |
|
209 /** |
|
210 * From MSimpleElement |
|
211 * Detach the element from its parent. |
|
212 * If the element, or one of its children, is dependent |
|
213 * on a namespace declared in the scope of the parent |
|
214 * copy those namespace declarations to this element. |
|
215 * Leaves with KErrNotFound if parent was not set and |
|
216 * nothing to detach. |
|
217 * |
|
218 * @since Series60 3.1 |
|
219 */ |
|
220 void DetachSimpleL(); |
|
221 |
|
222 /** |
|
223 * From MSimpleElement |
|
224 * Constructs and adds a new element to the children elements. |
|
225 * Sets this element to be the new parent of the given element. |
|
226 * |
|
227 * @since Series60 3.1 |
|
228 * @param aNsUri: namespace URI of the new element |
|
229 * @param aLocalName: local name of the new element |
|
230 * @return the added Element |
|
231 * Leave codes: |
|
232 * KErrSenInvalidCharacters if aLocalName contains illegal characters. |
|
233 * KErrSenZeroLengthDescriptor if aLocalName is zero length. |
|
234 */ |
|
235 MSimpleElement* AddSimpleElementL( |
|
236 const TDesC8& aNsUri, |
|
237 const TDesC8& aLocalName); |
|
238 |
|
239 /** |
|
240 * From MSimpleElement |
|
241 * Constructs and adds a new element to the children elements. |
|
242 * Sets this element to be the new parent of the given element. |
|
243 * Note: Element is created with no specific namespace, default namespace |
|
244 * of some of the upper level elements are in effect if there is such a |
|
245 * namespace. |
|
246 * |
|
247 * @since Series60 3.1 |
|
248 * @param aLocalName: local name of the new element |
|
249 * @return the added Element. OWNERSHIP IS TRANSFERRED. |
|
250 * Leave codes: |
|
251 * KErrSenInvalidCharacters if aLocalName contains illegal characters. |
|
252 * KErrSenZeroLengthDescriptor if aLocalName is zero length. |
|
253 */ |
|
254 MSimpleElement* AddSimpleElementL( |
|
255 const TDesC8& aLocalName ); |
|
256 |
|
257 |
|
258 /** |
|
259 * From MSimpleElement |
|
260 * Remove an element from the childs. |
|
261 * |
|
262 * @since Series60 3.1 |
|
263 * @param aNsUri: the namespace URI of the element to be removed. |
|
264 * @param aLocalName: the local name of the element to be removed. |
|
265 */ |
|
266 void RemoveSimpleElement( const TDesC8& aNsUri, |
|
267 const TDesC8& aLocalName); |
|
268 |
|
269 protected: |
|
270 |
|
271 /** |
|
272 * Two-phase constructor |
|
273 * @param aNsUri Namespace URI |
|
274 * @param aLocalName local name |
|
275 */ |
|
276 void ConstructL( const TDesC8& aNsUri, |
|
277 const TDesC8& aLocalName ); |
|
278 |
|
279 void CSimpleElement::ConstructL( |
|
280 CSenElement* aElem, |
|
281 TBool aOwn ); |
|
282 |
|
283 /** |
|
284 * constructor |
|
285 */ |
|
286 CSimpleElement(); |
|
287 |
|
288 private: // data |
|
289 |
|
290 /** |
|
291 * Base element when created from scratch |
|
292 * Own. |
|
293 */ |
|
294 CSenElement* iBase; |
|
295 |
|
296 /** |
|
297 * Base element when only reference to base element |
|
298 * Not own. |
|
299 */ |
|
300 CSenElement* iRef; |
|
301 |
|
302 /** |
|
303 * Attributes. |
|
304 */ |
|
305 RPointerArray<CSimpleAttribute> iAttributes; |
|
306 |
|
307 /** |
|
308 * Attributes. |
|
309 */ |
|
310 RPointerArray<CSimpleElement> iElements; |
|
311 |
|
312 }; |
|
313 |
|
314 |
|
315 |
|
316 |
|
317 #endif // ?INCLUDE_H |
|
318 |
|
319 // End of File |