1 /* |
|
2 * Copyright (c) 2005 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: XDM Engine document node |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "XdmEngine.h" |
|
23 #include "XdmDocument.h" |
|
24 #include "XdmNodeFactory.h" |
|
25 #include "XdmDocumentNode.h" |
|
26 #include "XdmNodeAttribute.h" |
|
27 |
|
28 //XML Escape codes |
|
29 _LIT8( KXmlBracketOpenEsc, "<"); |
|
30 _LIT8( KXmlBracketCloseEsc, ">"); |
|
31 _LIT8( KXmlAmpersandEsc, "&"); |
|
32 |
|
33 // ---------------------------------------------------------- |
|
34 // CXdmDocumentNode::CXdmDocumentNode |
|
35 // |
|
36 // ---------------------------------------------------------- |
|
37 // |
|
38 EXPORT_C CXdmDocumentNode::CXdmDocumentNode( CXdmEngine& aXdmEngine, |
|
39 MXdmNodeFactory& aNodeFactory ) : |
|
40 iPosition( KErrNotFound ), |
|
41 iEmptyNode( EFalse ), |
|
42 iXdmEngine( aXdmEngine ), |
|
43 iNodeFactory( aNodeFactory ) |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // ---------------------------------------------------------- |
|
49 // CXdmDocumentNode::CXdmDocumentNode |
|
50 // |
|
51 // ---------------------------------------------------------- |
|
52 // |
|
53 EXPORT_C CXdmDocumentNode::CXdmDocumentNode( CXdmEngine& aXdmEngine, |
|
54 MXdmNodeFactory& aNodeFactory, |
|
55 CXdmDocumentNode* aParentNode ) : |
|
56 iEmptyNode( EFalse ), |
|
57 iXdmEngine( aXdmEngine ), |
|
58 iNodeFactory( aNodeFactory ), |
|
59 iParentNode( aParentNode ) |
|
60 |
|
61 { |
|
62 } |
|
63 |
|
64 // ---------------------------------------------------------- |
|
65 // CXdmDocumentNode::CXdmDocumentNode |
|
66 // |
|
67 // ---------------------------------------------------------- |
|
68 // |
|
69 EXPORT_C CXdmDocumentNode::CXdmDocumentNode( const TBool aLeafNode, |
|
70 CXdmEngine& aXdmEngine, |
|
71 MXdmNodeFactory& aNodeFactory, |
|
72 CXdmDocumentNode* aParentNode ) : |
|
73 iLeafNode( aLeafNode ), |
|
74 iEmptyNode( EFalse ), |
|
75 iXdmEngine( aXdmEngine ), |
|
76 iNodeFactory( aNodeFactory ), |
|
77 iParentNode( aParentNode ) |
|
78 |
|
79 { |
|
80 |
|
81 } |
|
82 |
|
83 // ---------------------------------------------------------- |
|
84 // CXdmDocumentNode::ConstructL |
|
85 // |
|
86 // ---------------------------------------------------------- |
|
87 // |
|
88 EXPORT_C void CXdmDocumentNode::BaseConstructL( const TDesC& aNodeName ) |
|
89 { |
|
90 delete iNodeName; |
|
91 iNodeName = NULL; |
|
92 iNodeName = HBufC::NewL( aNodeName.Length() ); |
|
93 iNodeName->Des().Copy( aNodeName ); |
|
94 } |
|
95 |
|
96 // ---------------------------------------------------------- |
|
97 // CXdmDocumentNode::CopyConstructL |
|
98 // |
|
99 // ---------------------------------------------------------- |
|
100 // |
|
101 EXPORT_C void CXdmDocumentNode::CopyConstructL( const CXdmDocumentNode& aAnotherNode, |
|
102 const CXdmDocumentNode& aParentNode ) |
|
103 { |
|
104 #ifdef _DEBUG |
|
105 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CopyConstructL()" ) ); |
|
106 #endif |
|
107 if( aAnotherNode.ElementType() != EXdmElementAttribute ) |
|
108 { |
|
109 ConstructChildrenL( aAnotherNode ); |
|
110 ConstructAttributesL( aAnotherNode ); |
|
111 } |
|
112 iLeafNode = aAnotherNode.IsLeafNode(); |
|
113 iEmptyNode = aAnotherNode.IsEmptyNode(); |
|
114 if( iLeafNode ) |
|
115 { |
|
116 iLeafContent = HBufC8::New( aAnotherNode.LeafNodeContent().Length() ); |
|
117 iLeafContent->Des().Copy( aAnotherNode.LeafNodeContent() ); |
|
118 } |
|
119 iParentNode = CONST_CAST( CXdmDocumentNode*, &aParentNode ); |
|
120 } |
|
121 |
|
122 // ---------------------------------------------------------- |
|
123 // CXdmDocumentNode::ConstructAttributesL |
|
124 // |
|
125 // ---------------------------------------------------------- |
|
126 // |
|
127 void CXdmDocumentNode::ConstructAttributesL( const CXdmDocumentNode& aAnotherNode ) |
|
128 { |
|
129 #ifdef _DEBUG |
|
130 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CopyConstructL()" ) ); |
|
131 #endif |
|
132 TInt attrCount = aAnotherNode.AttributeCount(); |
|
133 for( TInt i = 0;i < attrCount;i++ ) |
|
134 { |
|
135 TPtrC name = aAnotherNode.Attribute( i )->NodeName(); |
|
136 TPtrC value = aAnotherNode.Attribute( i )->AttributeValue(); |
|
137 CXdmNodeAttribute* attribute = iNodeFactory.AttributeL( name ); |
|
138 CleanupStack::PushL( attribute ); |
|
139 attribute->SetAttributeValueL( value ); |
|
140 User::LeaveIfError( iAttributes.Append( attribute ) ); |
|
141 CleanupStack::Pop(); //attribute |
|
142 } |
|
143 } |
|
144 |
|
145 // ---------------------------------------------------------- |
|
146 // CXdmDocumentNode::ConstructChildrenL |
|
147 // |
|
148 // ---------------------------------------------------------- |
|
149 // |
|
150 void CXdmDocumentNode::ConstructChildrenL( const CXdmDocumentNode& aAnotherNode ) |
|
151 { |
|
152 #ifdef _DEBUG |
|
153 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ConstructChildrenL()" ) ); |
|
154 #endif |
|
155 TInt childCount = aAnotherNode.NodeCount(); |
|
156 for( TInt i = 0;i < childCount;i++ ) |
|
157 { |
|
158 CXdmDocumentNode* node = aAnotherNode.ChileNode( i ); |
|
159 CXdmDocumentNode* copy = iNodeFactory.ChileNodeL( node ); |
|
160 CleanupStack::PushL( copy ); |
|
161 User::LeaveIfError( iChildren.Append( copy ) ); |
|
162 CleanupStack::Pop(); //copy |
|
163 } |
|
164 } |
|
165 |
|
166 // ---------------------------------------------------- |
|
167 // CXdmDocumentNode::~CXdmDocumentNode |
|
168 // |
|
169 // ---------------------------------------------------- |
|
170 // |
|
171 EXPORT_C CXdmDocumentNode::~CXdmDocumentNode() |
|
172 { |
|
173 #ifdef _DEBUG |
|
174 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::~CXdmDocumentNode()" ) ); |
|
175 #endif |
|
176 delete iNextNode; |
|
177 iNextNode = NULL; |
|
178 delete iLeafContent; |
|
179 delete iNodeName; |
|
180 iChildren.ResetAndDestroy(); |
|
181 iChildren.Close(); |
|
182 iAttributes.ResetAndDestroy(); |
|
183 iAttributes.Close(); |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------- |
|
187 // CXdmDocumentNode::CreateChileNodeL |
|
188 // |
|
189 // ---------------------------------------------------- |
|
190 // |
|
191 EXPORT_C CXdmDocumentNode* CXdmDocumentNode::CreateChileNodeL() |
|
192 { |
|
193 /*#ifdef _DEBUG |
|
194 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateChileNodeL()" ) ); |
|
195 #endif*/ |
|
196 __ASSERT_ALWAYS( !iEmptyNode, User::Panic( _L( "CXdmDocumentNode" ), ENodeNotEmpty ) ); |
|
197 CXdmDocumentNode* node = iNodeFactory.ChileNodeL(); |
|
198 CleanupStack::PushL( node ); |
|
199 User::LeaveIfError( iChildren.Append( node ) ); |
|
200 CleanupStack::Pop(); //node |
|
201 return node; |
|
202 } |
|
203 |
|
204 // ---------------------------------------------------- |
|
205 // CXdmDocumentNode::CreateChileNodeL |
|
206 // |
|
207 // ---------------------------------------------------- |
|
208 // |
|
209 EXPORT_C CXdmDocumentNode* CXdmDocumentNode::CreateChileNodeL( const TDesC& aChildName ) |
|
210 { |
|
211 /*#ifdef _DEBUG |
|
212 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateChileNodeL() - Name: %S" ), &aChildName ); |
|
213 #endif*/ |
|
214 __ASSERT_ALWAYS( !iEmptyNode, User::Panic( _L( "CXdmDocumentNode" ), ENodeNotEmpty ) ); |
|
215 CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aChildName ); |
|
216 CleanupStack::PushL( node ); |
|
217 User::LeaveIfError( iChildren.Append( node ) ); |
|
218 CleanupStack::Pop(); //node |
|
219 return node; |
|
220 } |
|
221 |
|
222 // ---------------------------------------------------- |
|
223 // CXdmDocumentNode::SetLeafNode |
|
224 // |
|
225 // ---------------------------------------------------- |
|
226 // |
|
227 EXPORT_C void CXdmDocumentNode::SetLeafNode( const TBool aIsLeafNode ) |
|
228 { |
|
229 iLeafNode = aIsLeafNode; |
|
230 } |
|
231 |
|
232 // ---------------------------------------------------- |
|
233 // CXdmDocumentNode::IsLeafNode |
|
234 // |
|
235 // ---------------------------------------------------- |
|
236 // |
|
237 EXPORT_C TBool CXdmDocumentNode::IsLeafNode() const |
|
238 { |
|
239 return iLeafNode; |
|
240 } |
|
241 |
|
242 // ---------------------------------------------------- |
|
243 // CXdmDocumentNode::SetEmptyNode |
|
244 // |
|
245 // ---------------------------------------------------- |
|
246 // |
|
247 EXPORT_C void CXdmDocumentNode::SetEmptyNode( const TBool aIsEmptyNode ) |
|
248 { |
|
249 //Do nothing if the state is not being changed |
|
250 if( aIsEmptyNode != iEmptyNode ) |
|
251 { |
|
252 if( aIsEmptyNode ) |
|
253 { |
|
254 if( !iEmptyNode ) |
|
255 { |
|
256 TInt count = iChildren.Count(); |
|
257 if( count > 0 ) |
|
258 iChildren.ResetAndDestroy(); |
|
259 } |
|
260 } |
|
261 iEmptyNode = aIsEmptyNode; |
|
262 } |
|
263 } |
|
264 |
|
265 // ---------------------------------------------------- |
|
266 // CXdmDocumentNode::IsEmptyNode |
|
267 // |
|
268 // ---------------------------------------------------- |
|
269 // |
|
270 EXPORT_C TBool CXdmDocumentNode::IsEmptyNode() const |
|
271 { |
|
272 return iEmptyNode; |
|
273 } |
|
274 |
|
275 // ---------------------------------------------------- |
|
276 // CXdmDocumentNode::CreateAttributeL |
|
277 // |
|
278 // ---------------------------------------------------- |
|
279 // |
|
280 EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::CreateAttributeL() |
|
281 { |
|
282 /*#ifdef _DEBUG |
|
283 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateAttributeL()" ) ); |
|
284 #endif*/ |
|
285 CXdmDocumentNode* node = iNodeFactory.AttributeL(); |
|
286 CleanupStack::PushL( node ); |
|
287 User::LeaveIfError( iAttributes.Append( ( CXdmNodeAttribute* )node ) ); |
|
288 CleanupStack::Pop(); //node |
|
289 return ( CXdmNodeAttribute* )node; |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------- |
|
293 // CXdmDocumentNode::CreateAttributeL |
|
294 // |
|
295 // ---------------------------------------------------- |
|
296 // |
|
297 EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::CreateAttributeL( const TDesC& aAttributeName ) |
|
298 { |
|
299 /*#ifdef _DEBUG |
|
300 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::CreateAttributeL() - Name: %S" ), &aAttributeName ); |
|
301 #endif*/ |
|
302 CXdmDocumentNode* node = iNodeFactory.AttributeL( aAttributeName ); |
|
303 CleanupStack::PushL( node ); |
|
304 User::LeaveIfError( iAttributes.Append( ( CXdmNodeAttribute* )node ) ); |
|
305 CleanupStack::Pop(); //node |
|
306 return ( CXdmNodeAttribute* )node; |
|
307 } |
|
308 |
|
309 // ---------------------------------------------------- |
|
310 // CXdmDocumentNode::SetLeafNodeContentL |
|
311 // |
|
312 // ---------------------------------------------------- |
|
313 // |
|
314 EXPORT_C void CXdmDocumentNode::SetLeafNodeContentL( const TDesC& aLeafContent ) |
|
315 { |
|
316 /*#ifdef _DEBUG |
|
317 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetLeafNodeContentL( 16 ) - Content: %S" ), |
|
318 &aLeafContent ); |
|
319 #endif*/ |
|
320 if( iLeafNode ) |
|
321 { |
|
322 delete iLeafContent; |
|
323 iLeafContent = NULL; |
|
324 iLeafContent = CXdmEngine::ConvertToUTF8L( aLeafContent ); |
|
325 } |
|
326 else |
|
327 User::Leave( KErrGeneral ); |
|
328 } |
|
329 |
|
330 // ---------------------------------------------------- |
|
331 // CXdmDocumentNode::SetLeafNodeContentL |
|
332 // |
|
333 // ---------------------------------------------------- |
|
334 // |
|
335 EXPORT_C void CXdmDocumentNode::SetLeafNodeContentL( const TDesC8& aLeafContent ) |
|
336 { |
|
337 /*#ifdef _DEBUG |
|
338 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetLeafNodeContentL( 8 ) - Content: %S" ), |
|
339 &aLeafContent ); |
|
340 #endif*/ |
|
341 if( iLeafNode ) |
|
342 { |
|
343 delete iLeafContent; |
|
344 iLeafContent = NULL; |
|
345 iLeafContent = HBufC8::NewL( aLeafContent.Length() ); |
|
346 iLeafContent->Des().Copy( aLeafContent ); |
|
347 } |
|
348 else |
|
349 User::Leave( KErrGeneral ); |
|
350 } |
|
351 |
|
352 // ---------------------------------------------------- |
|
353 // CXdmDocumentNode::ElementData |
|
354 // |
|
355 // ---------------------------------------------------- |
|
356 // |
|
357 EXPORT_C HBufC8* CXdmDocumentNode::ElementDataLC() const |
|
358 { |
|
359 /*#ifdef _DEBUG |
|
360 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ElementDataLC()" ) ); |
|
361 #endif*/ |
|
362 TInt position = 0; |
|
363 CBufFlat* buffer = CBufFlat::NewL( 48 ); |
|
364 CleanupStack::PushL( buffer ); |
|
365 buffer->InsertL( position, EightBitNodeNameLC()->Des() ); |
|
366 CleanupStack::PopAndDestroy(); //EightBitNodeNameLC() |
|
367 position = position + NodeName().Length(); |
|
368 TInt attributeCount = iAttributes.Count(); |
|
369 if( attributeCount > 0 ) |
|
370 { |
|
371 for( TInt i = 0;i < attributeCount;i++ ) |
|
372 { |
|
373 buffer->InsertL( position, KGeneralSpace ); |
|
374 position = position + KGeneralSpace().Length(); |
|
375 CXdmNodeAttribute* attribute = iAttributes[i]; |
|
376 TPtrC8 name( attribute->EightBitNodeNameLC()->Des() ); |
|
377 buffer->InsertL( position, name ); |
|
378 position = position + name.Length(); |
|
379 buffer->InsertL( position, KGeneralEqualsAndQuotes ); |
|
380 position = position + KGeneralEqualsAndQuotes().Length(); |
|
381 TPtrC8 value( attribute->EscapedValueLC()->Des() ); |
|
382 buffer->InsertL( position, value ); |
|
383 position = position + value.Length(); |
|
384 buffer->InsertL( position, KGeneralQuotes ); |
|
385 position = position + KGeneralQuotes().Length(); |
|
386 CleanupStack::PopAndDestroy( 2 ); //EscapedValueLC(), |
|
387 //EightBitNodeNameLC() |
|
388 } |
|
389 } |
|
390 HBufC8* ret = HBufC8::NewL( buffer->Size() ); |
|
391 TPtr8 pointer( ret->Des() ); |
|
392 buffer->Read( 0, pointer, buffer->Size() ); |
|
393 CleanupStack::PopAndDestroy(); //buffer |
|
394 CleanupStack::PushL( ret ); |
|
395 return ret; |
|
396 } |
|
397 |
|
398 // ---------------------------------------------------------- |
|
399 // CXdmNodeAttribute::NodeCount |
|
400 // |
|
401 // ---------------------------------------------------------- |
|
402 // |
|
403 EXPORT_C TInt CXdmDocumentNode::NodeCount() const |
|
404 { |
|
405 return iNextNode ? 1 : iChildren.Count(); |
|
406 } |
|
407 |
|
408 // ---------------------------------------------------------- |
|
409 // CXdmNodeAttribute::NodeCount |
|
410 // |
|
411 // ---------------------------------------------------------- |
|
412 // |
|
413 EXPORT_C TInt CXdmDocumentNode::AttributeCount() const |
|
414 { |
|
415 return iAttributes.Count(); |
|
416 } |
|
417 |
|
418 // ---------------------------------------------------------- |
|
419 // CXdmDocumentNode::Parent |
|
420 // |
|
421 // ---------------------------------------------------------- |
|
422 // |
|
423 EXPORT_C CXdmDocumentNode* CXdmDocumentNode::ChileNode( const TInt aPosition ) const |
|
424 { |
|
425 /*#ifdef _DEBUG |
|
426 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ChileNode() - Position: %d" ), aPosition ); |
|
427 #endif*/ |
|
428 if( iNextNode ) |
|
429 return iNextNode; |
|
430 else |
|
431 { |
|
432 TInt count = NodeCount(); |
|
433 if( count > 0 && aPosition >= 0 && aPosition < count ) |
|
434 return iChildren[aPosition]; |
|
435 else return NULL; |
|
436 } |
|
437 } |
|
438 |
|
439 // ---------------------------------------------------------- |
|
440 // CXdmDocumentNode::Attribute |
|
441 // |
|
442 // ---------------------------------------------------------- |
|
443 // |
|
444 EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::Attribute( const TInt aPosition ) const |
|
445 { |
|
446 /*#ifdef _DEBUG |
|
447 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Attribute() - Position: %d" ), aPosition ); |
|
448 #endif*/ |
|
449 TInt count = iAttributes.Count(); |
|
450 if( count > 0 && aPosition >= 0 && aPosition < count ) |
|
451 return iAttributes[aPosition]; |
|
452 else return NULL; |
|
453 } |
|
454 |
|
455 // ---------------------------------------------------------- |
|
456 // CXdmDocumentNode::Attribute |
|
457 // |
|
458 // ---------------------------------------------------------- |
|
459 // |
|
460 EXPORT_C CXdmNodeAttribute* CXdmDocumentNode::Attribute( const TDesC& aAttributeName ) const |
|
461 { |
|
462 /*#ifdef _DEBUG |
|
463 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Attribute() - Name: %S" ), &aAttributeName ); |
|
464 #endif*/ |
|
465 TInt count = iAttributes.Count(); |
|
466 if( count > 0 ) |
|
467 { |
|
468 TBool found = EFalse; |
|
469 CXdmNodeAttribute* target = NULL; |
|
470 for( TInt i = 0;!found && i < count;i++ ) |
|
471 { |
|
472 if( iAttributes[i]->NodeName().Compare( aAttributeName ) == 0 ) |
|
473 { |
|
474 target = iAttributes[i]; |
|
475 found = ETrue; |
|
476 } |
|
477 } |
|
478 return target; |
|
479 } |
|
480 else return NULL; |
|
481 } |
|
482 |
|
483 // ---------------------------------------------------------- |
|
484 // CXdmDocumentNode::Parent |
|
485 // |
|
486 // ---------------------------------------------------------- |
|
487 // |
|
488 EXPORT_C TPtrC8 CXdmDocumentNode::LeafNodeContent() const |
|
489 { |
|
490 return iLeafNode && iLeafContent != NULL ? iLeafContent->Des() : TPtrC8(); |
|
491 } |
|
492 |
|
493 // ---------------------------------------------------------- |
|
494 // CXdmDocumentNode::Parent |
|
495 // |
|
496 // ---------------------------------------------------------- |
|
497 // |
|
498 EXPORT_C HBufC8* CXdmDocumentNode::EscapeLeafNodeContentLC() const |
|
499 { |
|
500 return iLeafNode && iLeafContent != NULL ? EscapeDescLC( iLeafContent->Des() ) : NULL; |
|
501 } |
|
502 |
|
503 // ---------------------------------------------------------- |
|
504 // CXdmDocumentNode::SetNextNode |
|
505 // |
|
506 // ---------------------------------------------------------- |
|
507 // |
|
508 EXPORT_C TPtrC CXdmDocumentNode::NodeName() const |
|
509 { |
|
510 return iNodeName != NULL ? iNodeName->Des() : TPtrC(); |
|
511 } |
|
512 |
|
513 // ---------------------------------------------------------- |
|
514 // CXdmDocumentNode::SetNextNode |
|
515 // |
|
516 // ---------------------------------------------------------- |
|
517 // |
|
518 EXPORT_C HBufC8* CXdmDocumentNode::EightBitNodeNameLC() const |
|
519 { |
|
520 HBufC8* eightBit = CXdmEngine::ConvertToUTF8L( iNodeName->Des() ); |
|
521 CleanupStack::PushL( eightBit ); |
|
522 return eightBit; |
|
523 } |
|
524 |
|
525 // ---------------------------------------------------------- |
|
526 // CXdmDocumentNode::SetNextNode |
|
527 // |
|
528 // ---------------------------------------------------------- |
|
529 // |
|
530 EXPORT_C void CXdmDocumentNode::SetNameL( const TDesC& aNodeName ) |
|
531 { |
|
532 /*#ifdef _DEBUG |
|
533 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetNameL( 16-Bit ) - Name: %S" ), |
|
534 &aNodeName ); |
|
535 #endif*/ |
|
536 delete iNodeName; |
|
537 iNodeName = NULL; |
|
538 iNodeName = HBufC::NewL( aNodeName.Length() ); |
|
539 iNodeName->Des().Copy( aNodeName ); |
|
540 } |
|
541 |
|
542 // ---------------------------------------------------------- |
|
543 // CXdmDocumentNode::SetNextNode |
|
544 // |
|
545 // ---------------------------------------------------------- |
|
546 // |
|
547 EXPORT_C void CXdmDocumentNode::SetNameL( const TDesC8& aNodeName ) |
|
548 { |
|
549 /*#ifdef _DEBUG |
|
550 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetNameL( 8-Bit ) - Name: %S" ), |
|
551 &aNodeName ); |
|
552 #endif*/ |
|
553 delete iNodeName; |
|
554 iNodeName = NULL; |
|
555 iNodeName = HBufC::NewL( aNodeName.Length() ); |
|
556 iNodeName->Des().Copy( aNodeName ); |
|
557 } |
|
558 |
|
559 // ---------------------------------------------------------- |
|
560 // CXdmNodeAttribute::ElementType |
|
561 // |
|
562 // ---------------------------------------------------------- |
|
563 // |
|
564 EXPORT_C CXdmDocumentNode* CXdmDocumentNode::Parent() const |
|
565 { |
|
566 /*#ifdef _DEBUG |
|
567 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Parent()" ) ); |
|
568 #endif*/ |
|
569 return iParentNode; |
|
570 } |
|
571 |
|
572 // ---------------------------------------------------------- |
|
573 // CXdmNodeAttribute::ElementType |
|
574 // |
|
575 // ---------------------------------------------------------- |
|
576 // |
|
577 EXPORT_C TXdmElementType CXdmDocumentNode::ElementType() const |
|
578 { |
|
579 /*#ifdef _DEBUG |
|
580 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ElementType()" ) ); |
|
581 #endif*/ |
|
582 return EXdmElementNode; |
|
583 } |
|
584 |
|
585 // ---------------------------------------------------------- |
|
586 // CXdmDocumentNode::Match |
|
587 // |
|
588 // ---------------------------------------------------------- |
|
589 // |
|
590 EXPORT_C TBool CXdmDocumentNode::Match( const CXdmDocumentNode& aAnotherNode ) const |
|
591 { |
|
592 #ifdef _DEBUG |
|
593 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Match()" ) ); |
|
594 #endif |
|
595 if( NodeName().Compare( aAnotherNode.NodeName() ) == 0 ) |
|
596 { |
|
597 TBool match = ETrue; |
|
598 TInt attrCount = iAttributes.Count(); |
|
599 if( attrCount == aAnotherNode.AttributeCount() ) |
|
600 { |
|
601 for( TInt i = 0;match && i < attrCount;i++ ) |
|
602 match = HasAttribute( *aAnotherNode.Attribute( i ) ); |
|
603 } |
|
604 else match = EFalse; |
|
605 return match; |
|
606 } |
|
607 else return EFalse; |
|
608 } |
|
609 |
|
610 // ---------------------------------------------------------- |
|
611 // CXdmDocumentNode::Match |
|
612 // |
|
613 // ---------------------------------------------------------- |
|
614 // |
|
615 EXPORT_C TBool CXdmDocumentNode::Match( const TDesC& aNodeName, |
|
616 const RPointerArray<SXdmAttribute8>& |
|
617 aAttributeArray ) const |
|
618 { |
|
619 #ifdef _DEBUG |
|
620 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Match()" ) ); |
|
621 #endif |
|
622 if( NodeName().Compare( aNodeName ) == 0 ) |
|
623 { |
|
624 TBool match = ETrue; |
|
625 TInt attrCount = iAttributes.Count(); |
|
626 if( attrCount == aAttributeArray.Count() ) |
|
627 { |
|
628 for( TInt i = 0;match && i < attrCount;i++ ) |
|
629 match = HasAttributeL( *aAttributeArray[i] ); |
|
630 } |
|
631 else match = EFalse; |
|
632 return match; |
|
633 } |
|
634 else return EFalse; |
|
635 } |
|
636 |
|
637 // --------------------------------------------------------- |
|
638 // CXdmDocumentNode::HasAttribute |
|
639 // |
|
640 // --------------------------------------------------------- |
|
641 // |
|
642 EXPORT_C TBool CXdmDocumentNode::HasAttribute( const TDesC& aAttributeName ) const |
|
643 { |
|
644 #ifdef _DEBUG |
|
645 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::HasAttribute()" ) ); |
|
646 #endif |
|
647 TInt count = iAttributes.Count(); |
|
648 for( TInt i = 0; i < count;i++ ) |
|
649 { |
|
650 if( !iAttributes[i]->NodeName().Compare( aAttributeName ) ) |
|
651 return ETrue; |
|
652 } |
|
653 return EFalse; |
|
654 } |
|
655 |
|
656 // --------------------------------------------------------- |
|
657 // CXdmDocumentNode::Print |
|
658 // !!! For debugging ONLY !!! |
|
659 // --------------------------------------------------------- |
|
660 // |
|
661 EXPORT_C void CXdmDocumentNode::Print() |
|
662 { |
|
663 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::Print()" ) ); |
|
664 HBufC8* nameBuf = HBufC8::NewLC( iNodeName->Des().Length() ); |
|
665 TPtr8 name( nameBuf->Des() ); |
|
666 name.Copy( iNodeName->Des() ); |
|
667 if( ElementType() == EXdmElementAttribute ) |
|
668 { |
|
669 CXdmNodeAttribute* attr = ( CXdmNodeAttribute* )this; |
|
670 TPtrC8 value( attr->EightBitValueLC()->Des() ); |
|
671 iXdmEngine.WriteToLog( _L8( "* Name: %S Value: %S" ), &name, &value ); |
|
672 CleanupStack::PopAndDestroy(); //value |
|
673 } |
|
674 else |
|
675 { |
|
676 iXdmEngine.WriteToLog( _L8( "* Name: %S" ), &name ); |
|
677 TInt count = iAttributes.Count(); |
|
678 if( count > 0 ) |
|
679 { |
|
680 for( TInt i = 0;i < count;i++ ) |
|
681 { |
|
682 CXdmNodeAttribute* attr = iAttributes[i]; |
|
683 TPtrC8 value( attr->EightBitValueLC()->Des() ); |
|
684 TPtrC8 name( attr->EightBitNodeNameLC()->Des() ); |
|
685 iXdmEngine.WriteToLog( _L8( "* Attribute %d - Name: %S Value: %S" ), i, &name, &value ); |
|
686 CleanupStack::PopAndDestroy( 2 ); //name, value |
|
687 } |
|
688 |
|
689 } |
|
690 if( iLeafNode ) |
|
691 { |
|
692 TPtr8 data( iLeafContent->Des() ); |
|
693 iXdmEngine.WriteToLog( _L8( "* Data: %S" ), &data ); |
|
694 } |
|
695 CXdmDocumentNode* node = NULL; |
|
696 TInt nodeCount = NodeCount(); |
|
697 for( TInt i = 0;i < nodeCount;i++ ) |
|
698 { |
|
699 node = ChileNode( i ); |
|
700 node->Print(); |
|
701 } |
|
702 } |
|
703 CleanupStack::PopAndDestroy(); //nameBuf |
|
704 } |
|
705 |
|
706 // --------------------------------------------------------- |
|
707 // CXdmDocumentNode::Find |
|
708 // |
|
709 // --------------------------------------------------------- |
|
710 // |
|
711 EXPORT_C TInt CXdmDocumentNode::Find( const TDesC& aNodeName, |
|
712 RPointerArray<CXdmDocumentNode>& aResultArray ) const |
|
713 { |
|
714 TInt error = KErrNotFound; |
|
715 TInt childCount = NodeCount(); |
|
716 if( childCount > 0 ) |
|
717 { |
|
718 for( TInt i = 0;i < childCount;i++ ) |
|
719 error = ChileNode( i )->DoFind( aNodeName, aResultArray ); |
|
720 } |
|
721 return error; |
|
722 } |
|
723 |
|
724 // --------------------------------------------------------- |
|
725 // CXdmDocumentNode::DoFind |
|
726 // |
|
727 // --------------------------------------------------------- |
|
728 // |
|
729 TInt CXdmDocumentNode::DoFind( const TDesC& aNodeName, |
|
730 RPointerArray<CXdmDocumentNode>& aResultArray ) const |
|
731 { |
|
732 TInt error = KErrNone; |
|
733 if( NodeName().Compare( aNodeName ) == 0 ) |
|
734 error = aResultArray.Append( this ); |
|
735 if( error == KErrNone ) |
|
736 { |
|
737 TInt childCount = NodeCount(); |
|
738 if( childCount > 0 ) |
|
739 { |
|
740 for( TInt i = 0;i < childCount;i++ ) |
|
741 error = ChileNode( i )->DoFind( aNodeName, aResultArray ); |
|
742 } |
|
743 } |
|
744 return error; |
|
745 } |
|
746 |
|
747 // --------------------------------------------------------- |
|
748 // CXdmDocumentNode::Find |
|
749 // |
|
750 // --------------------------------------------------------- |
|
751 // |
|
752 EXPORT_C TInt CXdmDocumentNode::Find( const CXdmDocumentNode& aTargetNode, |
|
753 RPointerArray<CXdmDocumentNode>& aResultArray ) const |
|
754 { |
|
755 TInt error = KErrNotFound; |
|
756 TInt childCount = NodeCount(); |
|
757 if( childCount > 0 ) |
|
758 { |
|
759 for( TInt i = 0;i < childCount;i++ ) |
|
760 error = ChileNode( i )->DoFind( aTargetNode, aResultArray ); |
|
761 } |
|
762 return error; |
|
763 } |
|
764 |
|
765 // --------------------------------------------------------- |
|
766 // CXdmDocumentNode::Find |
|
767 // |
|
768 // --------------------------------------------------------- |
|
769 // |
|
770 TInt CXdmDocumentNode::DoFind( const CXdmDocumentNode& aTargetNode, |
|
771 RPointerArray<CXdmDocumentNode>& aResultArray ) const |
|
772 { |
|
773 TInt error = KErrNone; |
|
774 if( *this == aTargetNode ) |
|
775 error = aResultArray.Append( this ); |
|
776 if( error == KErrNone ) |
|
777 { |
|
778 TInt childCount = NodeCount(); |
|
779 if( childCount > 0 ) |
|
780 { |
|
781 for( TInt i = 0;i < childCount;i++ ) |
|
782 error = ChileNode( i )->DoFind( aTargetNode, aResultArray ); |
|
783 } |
|
784 } |
|
785 return error; |
|
786 } |
|
787 |
|
788 // --------------------------------------------------------- |
|
789 // CXdmDocumentNode::Find |
|
790 // |
|
791 // --------------------------------------------------------- |
|
792 // |
|
793 EXPORT_C TInt CXdmDocumentNode::Find( const TDesC& aNodeName, |
|
794 RPointerArray<CXdmDocumentNode>& aResultArray, |
|
795 const RPointerArray<SXdmAttribute16>& aAttributeArray ) const |
|
796 { |
|
797 TInt error = KErrNone; |
|
798 TInt childCount = NodeCount(); |
|
799 if( childCount > 0 ) |
|
800 { |
|
801 for( TInt j = 0;j < childCount;j++ ) |
|
802 error = ChileNode( j )->DoFind( aNodeName, aResultArray, aAttributeArray ); |
|
803 } |
|
804 return error; |
|
805 } |
|
806 |
|
807 // --------------------------------------------------------- |
|
808 // CXcapHttpOperation::RemoveNamespaceAttributes |
|
809 // |
|
810 // --------------------------------------------------------- |
|
811 // |
|
812 void CXdmDocumentNode::RemoveNamespaceAttributes() |
|
813 { |
|
814 _LIT( KXmlNamespaceAttr, "xmlns" ); |
|
815 for( TInt i( iAttributes.Count() - 1 ); i > KErrNotFound; i-- ) |
|
816 { |
|
817 CXdmNodeAttribute* attr( iAttributes[i] ); |
|
818 if( attr->NodeName().Find( KXmlNamespaceAttr ) == 0 ) |
|
819 { |
|
820 iAttributes.Remove( i ); |
|
821 delete attr; |
|
822 attr = NULL; |
|
823 } |
|
824 } |
|
825 } |
|
826 |
|
827 // --------------------------------------------------------- |
|
828 // CXdmDocumentNode::DoFind |
|
829 // |
|
830 // --------------------------------------------------------- |
|
831 // |
|
832 TInt CXdmDocumentNode::DoFind( const TDesC& aNodeName, |
|
833 RPointerArray<CXdmDocumentNode>& aResultArray, |
|
834 const RPointerArray<SXdmAttribute16>& aAttributeArray ) |
|
835 { |
|
836 TBool match = EFalse; |
|
837 TInt error = KErrNone; |
|
838 if( NodeName().Compare( aNodeName ) == 0 ) |
|
839 { |
|
840 match = ETrue; |
|
841 RemoveNamespaceAttributes(); |
|
842 TInt attrCount = iAttributes.Count(); |
|
843 if( attrCount == aAttributeArray.Count() ) |
|
844 { |
|
845 if( attrCount > 0 ) |
|
846 { |
|
847 for( TInt i = 0;i < attrCount;i++ ) |
|
848 match = HasAttribute( *aAttributeArray[i] ); |
|
849 } |
|
850 } |
|
851 else match = EFalse; |
|
852 error = match ? aResultArray.Append( this ) : KErrNotFound; |
|
853 } |
|
854 TInt childCount = NodeCount(); |
|
855 if( childCount > 0 ) |
|
856 { |
|
857 for( TInt j = 0;j < childCount;j++ ) |
|
858 error = ChileNode( j )->DoFind( aNodeName, aResultArray, aAttributeArray ); |
|
859 } |
|
860 return error; |
|
861 } |
|
862 |
|
863 // --------------------------------------------------------- |
|
864 // CXdmDocumentNode::operator== |
|
865 // |
|
866 // --------------------------------------------------------- |
|
867 // |
|
868 EXPORT_C TBool CXdmDocumentNode::operator==( const CXdmDocumentNode& aNode ) const |
|
869 { |
|
870 TBool match = EFalse; |
|
871 if( NodeName().Compare( aNode.NodeName() ) == 0 ) |
|
872 { |
|
873 match = ETrue; |
|
874 TInt attrCount = iAttributes.Count(); |
|
875 if( attrCount == aNode.AttributeCount() ) |
|
876 { |
|
877 if( attrCount > 0 ) |
|
878 { |
|
879 for( TInt i = 0;i < attrCount;i++ ) |
|
880 match = aNode.HasAttribute( *iAttributes[i] ); |
|
881 } |
|
882 } |
|
883 if( match ) |
|
884 { |
|
885 TInt childCount = NodeCount(); |
|
886 if( childCount == aNode.NodeCount() ) |
|
887 { |
|
888 if( childCount > 0 ) |
|
889 { |
|
890 for( TInt j = 0;j < childCount;j++ ) |
|
891 { |
|
892 match = *ChileNode( j ) == *aNode.ChileNode( j ); |
|
893 if( !match ) |
|
894 break; |
|
895 } |
|
896 } |
|
897 } |
|
898 else match = EFalse; |
|
899 } |
|
900 else match = EFalse; |
|
901 } |
|
902 return match; |
|
903 } |
|
904 |
|
905 // ---------------------------------------------------- |
|
906 // CXdmDocumentNode::AppendChileNodeL |
|
907 // |
|
908 // ---------------------------------------------------- |
|
909 // |
|
910 EXPORT_C void CXdmDocumentNode::AppendChileNodeL( CXdmDocumentNode* aDocumentNode ) |
|
911 { |
|
912 #ifdef _DEBUG |
|
913 iXdmEngine.WriteToLog( _L8( "CLocalDocument::AppendChileNodeL()" ) ); |
|
914 #endif |
|
915 CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aDocumentNode ); |
|
916 CleanupStack::PushL( node ); |
|
917 User::LeaveIfError( iChildren.Append( node ) ); |
|
918 CleanupStack::Pop(); //node |
|
919 } |
|
920 |
|
921 // ---------------------------------------------------- |
|
922 // CXdmDocumentNode::InsertChileNodeL |
|
923 // |
|
924 // ---------------------------------------------------- |
|
925 // |
|
926 EXPORT_C void CXdmDocumentNode::InsertChileNodeL( TInt aIndex, CXdmDocumentNode* aDocumentNode ) |
|
927 { |
|
928 #ifdef _DEBUG |
|
929 iXdmEngine.WriteToLog( _L8( "CLocalDocument::InsertChileNodeL()" ) ); |
|
930 #endif |
|
931 __ASSERT_ALWAYS( aIndex >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) ); |
|
932 CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aDocumentNode ); |
|
933 CleanupStack::PushL( node ); |
|
934 User::LeaveIfError( iChildren.Insert( node, aIndex ) ); |
|
935 CleanupStack::Pop(); //node |
|
936 } |
|
937 |
|
938 // ---------------------------------------------------- |
|
939 // CXdmDocumentNode::ReplaceChileNodeL |
|
940 // |
|
941 // ---------------------------------------------------- |
|
942 // |
|
943 EXPORT_C void CXdmDocumentNode::ReplaceChileNodeL( CXdmDocumentNode* aNewNode, |
|
944 CXdmDocumentNode* aTargetNode ) |
|
945 { |
|
946 CXdmDocumentNode* remove = NULL; |
|
947 TInt index = iChildren.Find( aTargetNode ); |
|
948 #ifdef _DEBUG |
|
949 CXdmDocumentNode* a = NULL; |
|
950 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::ReplaceChileNodeL()" ) ); |
|
951 iXdmEngine.WriteToLog( _L8( " New node: %x" ), aNewNode ); |
|
952 iXdmEngine.WriteToLog( _L8( " Target node: %x" ), aTargetNode ); |
|
953 for( TInt i = 0;i < iChildren.Count();i++ ) |
|
954 { |
|
955 a = iChildren[i]; |
|
956 iXdmEngine.WriteToLog( _L8( " Child %d: %x" ), i, a ); |
|
957 } |
|
958 #endif |
|
959 __ASSERT_DEBUG( index >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) ); |
|
960 remove = iChildren[index]; |
|
961 iChildren.Remove( index ); |
|
962 delete remove; |
|
963 remove = NULL; |
|
964 CXdmDocumentNode* node = iNodeFactory.ChileNodeL( aNewNode ); |
|
965 CleanupStack::PushL( node ); |
|
966 User::LeaveIfError( iChildren.Insert( node, index ) ); |
|
967 CleanupStack::Pop(); //node |
|
968 } |
|
969 |
|
970 // ---------------------------------------------------------- |
|
971 // CXdmDocumentNode::RemoveChileNodeL |
|
972 // |
|
973 // ---------------------------------------------------------- |
|
974 // |
|
975 EXPORT_C void CXdmDocumentNode::RemoveChileNodeL( CXdmDocumentNode* aChileNode ) |
|
976 { |
|
977 #ifdef _DEBUG |
|
978 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::RemoveChileNodeL()" ) ); |
|
979 #endif |
|
980 CXdmDocumentNode* remove = NULL; |
|
981 switch( aChileNode->ElementType() ) |
|
982 { |
|
983 case EXdmElementNode: |
|
984 { |
|
985 #ifdef _DEBUG |
|
986 iXdmEngine.WriteToLog( _L8( " Element is a node" ) ); |
|
987 #endif |
|
988 TInt index( iChildren.Find( aChileNode ) ); |
|
989 __ASSERT_DEBUG( index >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) ); |
|
990 remove = iChildren[index]; |
|
991 iChildren.Remove( index ); |
|
992 delete remove; |
|
993 remove = NULL; |
|
994 } |
|
995 break; |
|
996 case EXdmElementAttribute: |
|
997 { |
|
998 #ifdef _DEBUG |
|
999 iXdmEngine.WriteToLog( _L8( " Element is an attribute" ) ); |
|
1000 #endif |
|
1001 TInt index( iAttributes.Find( ( CXdmNodeAttribute* )aChileNode ) ); |
|
1002 __ASSERT_DEBUG( index >= 0, User::Panic( _L( "CXdmDocumentNode" ), EIndexOutOfBounds ) ); |
|
1003 remove = iAttributes[index]; |
|
1004 iAttributes.Remove( index ); |
|
1005 delete remove; |
|
1006 remove = NULL; |
|
1007 } |
|
1008 break; |
|
1009 default: |
|
1010 #ifdef _DEBUG |
|
1011 iXdmEngine.WriteToLog( _L8( " Element is of undefined type, ignore" ) ); |
|
1012 #endif |
|
1013 break; |
|
1014 } |
|
1015 } |
|
1016 |
|
1017 // ---------------------------------------------------------- |
|
1018 // CXdmDocumentNode::NextNode |
|
1019 // |
|
1020 // ---------------------------------------------------------- |
|
1021 // |
|
1022 EXPORT_C CXdmDocumentNode* CXdmDocumentNode::NextNode() const |
|
1023 { |
|
1024 /*#ifdef _DEBUG |
|
1025 iXdmEngine.WriteToLog( _L8( "CXcapDocumentNode::NextNode()" ) ); |
|
1026 #endif*/ |
|
1027 return iNextNode; |
|
1028 } |
|
1029 |
|
1030 // ---------------------------------------------------------- |
|
1031 // CXcapDocumentNode::SetNextNode |
|
1032 // |
|
1033 // ---------------------------------------------------------- |
|
1034 // |
|
1035 EXPORT_C void CXdmDocumentNode::SetNextNode( CXdmDocumentNode* aNextNode ) |
|
1036 { |
|
1037 /*#ifdef _DEBUG |
|
1038 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::SetNextNode()" ) ); |
|
1039 #endif*/ |
|
1040 __ASSERT_DEBUG( aNextNode != NULL, User::Panic( _L( "CXdmDocumentNode" ), EDocNodeNull ) ); |
|
1041 iNextNode = aNextNode; |
|
1042 } |
|
1043 |
|
1044 // --------------------------------------------------------- |
|
1045 // CXdmDocumentNode::EscapeDescLC |
|
1046 // |
|
1047 // --------------------------------------------------------- |
|
1048 // |
|
1049 HBufC8* CXdmDocumentNode::EscapeDescLC( const TDesC8& aDescriptor ) const |
|
1050 { |
|
1051 /*#ifdef _DEBUG |
|
1052 iXdmEngine.WriteToLog( _L8( "CXdmDocumentNode::EscapeDescLC()" ) ); |
|
1053 #endif*/ |
|
1054 TInt bufPos = 0; |
|
1055 TBuf8<10> format; |
|
1056 HBufC8* ret = NULL; |
|
1057 CBufFlat* buffer = CBufFlat::NewL( 50 ); |
|
1058 CleanupStack::PushL( buffer ); |
|
1059 for( TInt i = 0;i < aDescriptor.Length();i++ ) |
|
1060 { |
|
1061 TUint8 byte = aDescriptor[i]; |
|
1062 switch( byte ) |
|
1063 { |
|
1064 case 0x26: //'&' |
|
1065 format.Append( KXmlAmpersandEsc ); |
|
1066 break; |
|
1067 case 0x3C: //'<' |
|
1068 format.Append( KXmlBracketOpenEsc ); |
|
1069 break; |
|
1070 case 0x3E: //'>' |
|
1071 format.Append( KXmlBracketCloseEsc ); |
|
1072 break; |
|
1073 default: |
|
1074 format.Append( byte ); |
|
1075 break; |
|
1076 } |
|
1077 buffer->InsertL( bufPos, format ); |
|
1078 bufPos = bufPos + format.Length(); |
|
1079 format.Zero(); |
|
1080 } |
|
1081 ret = HBufC8::NewL( buffer->Size() ); |
|
1082 ret->Des().Copy( buffer->BackPtr( buffer->Size() ) ); |
|
1083 CleanupStack::PopAndDestroy(); //buffer |
|
1084 CleanupStack::PushL( ret ); |
|
1085 return ret; |
|
1086 } |
|
1087 |
|
1088 // --------------------------------------------------------- |
|
1089 // CXdmDocumentNode::HasAttribute |
|
1090 // |
|
1091 // --------------------------------------------------------- |
|
1092 // |
|
1093 TBool CXdmDocumentNode::HasAttribute( const CXdmNodeAttribute& aAttribute ) const |
|
1094 { |
|
1095 TBool ret = EFalse; |
|
1096 TInt count = iAttributes.Count(); |
|
1097 for( TInt i = 0;i < count && !ret;i++ ) |
|
1098 { |
|
1099 ret = iAttributes[i]->NodeName().Compare( aAttribute.NodeName() ) == 0 && |
|
1100 iAttributes[i]->AttributeValue().Compare( aAttribute.AttributeValue() ) == 0; |
|
1101 } |
|
1102 return ret; |
|
1103 } |
|
1104 |
|
1105 // --------------------------------------------------------- |
|
1106 // CXdmDocumentNode::HasAttribute |
|
1107 // |
|
1108 // --------------------------------------------------------- |
|
1109 // |
|
1110 TBool CXdmDocumentNode::HasAttributeL( const SXdmAttribute8& aAttribute ) const |
|
1111 { |
|
1112 TBool ret = EFalse; |
|
1113 TInt count = iAttributes.Count(); |
|
1114 for( TInt i = 0;i < count && !ret;i++ ) |
|
1115 { |
|
1116 HBufC8* name = CXdmEngine::ConvertToUTF8L( iAttributes[i]->NodeName() ); |
|
1117 CleanupStack::PushL( name ); |
|
1118 HBufC8* value = CXdmEngine::ConvertToUTF8L( iAttributes[i]->AttributeValue() ); |
|
1119 CleanupStack::PushL( value ); |
|
1120 ret = name->Des().Compare( aAttribute.iName ) == 0 && |
|
1121 value->Des().Compare( aAttribute.iValue ) == 0; |
|
1122 CleanupStack::PopAndDestroy( 2 ); //value, name |
|
1123 } |
|
1124 return ret; |
|
1125 } |
|
1126 |
|
1127 // --------------------------------------------------------- |
|
1128 // CXdmDocumentNode::HasAttribute |
|
1129 // |
|
1130 // --------------------------------------------------------- |
|
1131 // |
|
1132 TBool CXdmDocumentNode::HasAttribute( const SXdmAttribute16& aAttribute ) const |
|
1133 { |
|
1134 TBool ret = EFalse; |
|
1135 TInt count = iAttributes.Count(); |
|
1136 for( TInt i = 0;i < count && !ret;i++ ) |
|
1137 { |
|
1138 ret = iAttributes[i]->NodeName().Compare( aAttribute.iName ) == 0 && |
|
1139 iAttributes[i]->AttributeValue().Compare( aAttribute.iValue ) == 0; |
|
1140 } |
|
1141 return ret; |
|
1142 } |
|
1143 |
|