1 // Copyright (c) 1999-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
16 // Derived from CTypedNode. Adds functionality
17 // to make the use of the node simpler
37 _LIT(KXmlElementDataItemAttributeName, "__XML_DI");
48 EXmlElPanicInvalidDataItem = 1
51 // Type of an attribute in a node
52 typedef const TDesC* TXmlAttributeType;
53 // Type of an element (type of node)
54 typedef const TDesC* TXmlElementType;
57 // FUNCTION PROTOTYPES
63 GLREF_C void Panic(TXmlElementPanic aPanic);
66 // FORWARD DECLARATIONS
69 class CAttributeLookupTable;
74 //##ModelId=3B66798702FF
75 class CXmlElement : public CTypedNode<TXmlElementType, TXmlAttributeType>
83 //##ModelId=3B6679870364
84 static inline CXmlElement* NewL(TXmlElementType aType,CNode* aParent);
87 // Return the value of a particular attribute
88 //##ModelId=3B667987035D
89 IMPORT_C const TDesC* Attribute(const TDesC& aAttributeName) const;
90 // Return the value of an aIndexth attribute
91 //##ModelId=3B6679870362
92 inline const TDesC* Attribute(TInt aIndex) const;
94 // Set attribute value
95 //##ModelId=3B6679870359
96 IMPORT_C void SetAttributeL(const TDesC& aAttributeName, const TDesC& aAttributeValue, CAttributeLookupTable& aAttributeLUT);
98 // Store a unicode descriptor as data value.
99 //##ModelId=3B6679870357
100 IMPORT_C void SetTextL(const TDesC& aData);
102 //##ModelId=3B6679870352
103 inline const TDesC* Text() const;
106 //##ModelId=3B6679870350
107 inline void AppendChildL(CXmlElement* aElement);
109 //##ModelId=3B667987034D
110 IMPORT_C void InsertChildL(TInt aIndexToInsertBefore, CXmlElement* aElement);
112 //##ModelId=3B6679870347
113 inline TInt Count() const;
115 //##ModelId=3B6679870345
116 inline CXmlElement* Child(TInt aIndex) const;
118 // Find out the index of this child
120 // aChild - Pointer to the child node
122 // TInt - index to the child, -1 if no child found
123 //##ModelId=3B6679870343
124 IMPORT_C TInt ChildIndex(CXmlElement* aChild) const;
127 //##ModelId=3B667987033C
128 IMPORT_C void SetDataItemL(CBase* aDataItem, CAttributeLookupTable& aAttributeLUT); // takes ownership of aDataItem
129 //##ModelId=3B667987033B
130 IMPORT_C CBase* DataItem() const;
131 //##ModelId=3B6679870339
132 IMPORT_C void DeleteDataItem(CAttributeLookupTable& aAttributeLUT);
135 // Data Item handling
136 class CDataItemAttribute : public CBase
139 ~CDataItemAttribute() { delete iDataItem; };
143 //##ModelId=3B6679870335
144 CXmlElement() : CTypedNode<TXmlElementType, TXmlAttributeType>(NULL, NULL) {};
149 //##ModelId=3B6679870334
150 IMPORT_C void WriteIntoFileL();
151 //##ModelId=3B6679870331
152 void StartWriteL(RFile& aFile, TInt aIndentation);
154 //##ModelId=3B6679870327
155 void WriteNameL(RFile& aFile, TInt aIndentation);
162 inline CXmlElement* CXmlElement::NewL(TXmlElementType aType,CNode* aParent)
164 return (CXmlElement*)CTypedNode<TXmlElementType, TXmlAttributeType>::NewL(aType, aParent);
167 inline const TDesC* CXmlElement::Attribute(TInt aIndex) const
169 return (TDesC*)((CDataDelete*)AttributeByIndex(aIndex))->Data();
172 inline const TDesC* CXmlElement::Text() const
174 return (const TDesC*)CTypedNode<TXmlElementType, TXmlAttributeType>::Data();
177 inline void CXmlElement::AppendChildL(CXmlElement* aElement)
179 CTypedNode<TXmlElementType, TXmlAttributeType>::AppendNodeToThisNodeL(aElement);
182 inline TInt CXmlElement::Count() const
184 return NumberImmediateChildren();
187 inline CXmlElement* CXmlElement::Child(TInt aIndex) const
189 return (CXmlElement*)CTypedNode<TXmlElementType, TXmlAttributeType>::Child(aIndex);
192 #endif //__XMLELEMT_H