epoc32/include/mw/xmlelemt.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 3 e1b950c65cb4
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     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".
     7 //
     8 // Initial Contributors:
     9 // Nokia Corporation - initial contribution.
    10 //
    11 // Contributors:
    12 //
    13 // Description:
    14 // XmlElement.h
    15 // XML Element class
    16 // Derived from CTypedNode. Adds functionality
    17 // to make the use of the node simpler
    18 // 
    19 //
    20 
    21 #ifndef __XMLELEMT_H
    22 #define __XMLELEMT_H
    23 
    24 //
    25 //  INCLUDES
    26 //
    27 #include <e32base.h>
    28 #include <cnode.h>
    29 
    30 //
    31 //  CONSTANTS  
    32 //
    33 /**
    34 @publishedAll
    35 @deprecated
    36 */
    37 _LIT(KXmlElementDataItemAttributeName, "__XML_DI");
    38 
    39 //
    40 //  DATA TYPES  
    41 //
    42 enum TXmlElementPanic
    43 /**
    44 @publishedAll
    45 @deprecated
    46 */
    47 {
    48 	EXmlElPanicInvalidDataItem = 1
    49 };
    50 
    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;
    55 
    56 //
    57 //  FUNCTION PROTOTYPES  
    58 //
    59 /**
    60 @publishedAll
    61 @deprecated
    62 */
    63 GLREF_C void Panic(TXmlElementPanic aPanic);
    64 
    65 //
    66 //  FORWARD DECLARATIONS
    67 //
    68 class RFile;
    69 class CAttributeLookupTable;
    70 
    71 //
    72 //  CLASS DEFINITIONS 
    73 //
    74 //##ModelId=3B66798702FF
    75 class CXmlElement : public CTypedNode<TXmlElementType, TXmlAttributeType>
    76 /**
    77 @publishedAll
    78 @deprecated
    79 */
    80 {
    81 public:
    82 	// Construction
    83 	//##ModelId=3B6679870364
    84 	static inline CXmlElement* NewL(TXmlElementType aType,CNode* aParent);
    85 
    86 	// Attributes
    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;
    93 
    94 	// Set attribute value
    95 	//##ModelId=3B6679870359
    96 	IMPORT_C void SetAttributeL(const TDesC& aAttributeName, const TDesC& aAttributeValue, CAttributeLookupTable& aAttributeLUT);
    97 
    98 	// Store a unicode descriptor as data value. 
    99 	//##ModelId=3B6679870357
   100 	IMPORT_C void SetTextL(const TDesC& aData);
   101 	// Get data value
   102 	//##ModelId=3B6679870352
   103 	inline const TDesC* Text() const;
   104 
   105 	// Children
   106 	//##ModelId=3B6679870350
   107 	inline void AppendChildL(CXmlElement* aElement);
   108 
   109 	//##ModelId=3B667987034D
   110 	IMPORT_C void InsertChildL(TInt aIndexToInsertBefore, CXmlElement* aElement);
   111 
   112 	//##ModelId=3B6679870347
   113 	inline TInt Count() const;
   114 
   115 	//##ModelId=3B6679870345
   116 	inline CXmlElement* Child(TInt aIndex) const;
   117 
   118 	// Find out the index of this child
   119 	// INPUT:
   120 	// aChild - Pointer to the child node
   121 	// RETURN:
   122 	// TInt - index to the child, -1 if no child found
   123 	//##ModelId=3B6679870343
   124 	IMPORT_C TInt ChildIndex(CXmlElement* aChild) const;
   125 
   126 	// Data item
   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);
   133 
   134 private:
   135 	// Data Item handling
   136 	class CDataItemAttribute : public CBase
   137 	{
   138 	public:
   139 		~CDataItemAttribute() { delete iDataItem; };
   140 		CBase* iDataItem;
   141 	};
   142 
   143 	//##ModelId=3B6679870335
   144 	CXmlElement() : CTypedNode<TXmlElementType, TXmlAttributeType>(NULL, NULL) {};
   145 
   146 // Debug stuff
   147 //#ifdef _DEBUG
   148 public:
   149 	//##ModelId=3B6679870334
   150 	IMPORT_C void WriteIntoFileL();
   151 	//##ModelId=3B6679870331
   152 	void StartWriteL(RFile& aFile, TInt aIndentation);
   153 private:
   154 	//##ModelId=3B6679870327
   155 	void WriteNameL(RFile& aFile, TInt aIndentation);
   156 //#endif
   157 };
   158 
   159 //
   160 //	INLINE METHODS
   161 //
   162 inline CXmlElement* CXmlElement::NewL(TXmlElementType aType,CNode* aParent) 
   163 {
   164 	return (CXmlElement*)CTypedNode<TXmlElementType, TXmlAttributeType>::NewL(aType, aParent);
   165 }
   166 
   167 inline const TDesC* CXmlElement::Attribute(TInt aIndex) const
   168 { 
   169 	return (TDesC*)((CDataDelete*)AttributeByIndex(aIndex))->Data();
   170 }
   171 
   172 inline const TDesC* CXmlElement::Text() const
   173 { 
   174 	return (const TDesC*)CTypedNode<TXmlElementType, TXmlAttributeType>::Data(); 
   175 }
   176 
   177 inline void CXmlElement::AppendChildL(CXmlElement* aElement)
   178 { 
   179 	CTypedNode<TXmlElementType, TXmlAttributeType>::AppendNodeToThisNodeL(aElement); 
   180 }
   181 
   182 inline TInt CXmlElement::Count() const
   183 { 
   184 	return NumberImmediateChildren(); 
   185 }
   186 
   187 inline CXmlElement* CXmlElement::Child(TInt aIndex) const
   188 { 
   189 	return (CXmlElement*)CTypedNode<TXmlElementType, TXmlAttributeType>::Child(aIndex); 
   190 }
   191 
   192 #endif //__XMLELEMT_H