00001 /* 00002 * ============================================================================== 00003 * Name : SenBaseElement.h 00004 * Part of : Web Services Xml 00005 * Interface : 00006 * Description : Implementation of an XML element functionality 00007 * Version : 00008 * 00009 * Copyright © 2002-2005 Nokia. All rights reserved. 00010 * This material, including documentation and any related 00011 * computer programs, is protected by copyright controlled by 00012 * Nokia. All rights are reserved. Copying, including 00013 * reproducing, storing, adapting or translating, any 00014 * or all of this material requires the prior written consent of 00015 * Nokia. This material also contains confidential 00016 * information which may not be disclosed to others without the 00017 * prior written consent of Nokia. 00018 * ============================================================================== 00019 */ 00020 00021 #ifndef SEN_BASE_ELEMENT_H 00022 #define SEN_BASE_ELEMENT_H 00023 00024 // INCLUDES 00025 #include <s32mem.h> 00026 00027 #include <SenElement.h> 00028 #include <SenNamespace.h> 00029 #include <SenBaseAttribute.h> 00030 00031 // CLASS DECLARATION 00032 00045 class CSenBaseElement : public CSenElement 00046 { 00047 public: // Constructors and destructor 00048 00056 IMPORT_C static CSenBaseElement* NewL(const TDesC8& aLocalName); 00057 00066 IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri, 00067 const TDesC8& aLocalName); 00068 00079 IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri, 00080 const TDesC8& aLocalName, 00081 const TDesC8& aQName); 00082 00094 IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri, 00095 const TDesC8& aLocalName, 00096 const TDesC8& aQName, 00097 const RAttributeArray& apAttrs); 00098 00111 IMPORT_C static CSenBaseElement* NewL(const TDesC8& aNsUri, 00112 const TDesC8& aLocalName, 00113 const TDesC8& aQName, 00114 const RAttributeArray& apAttrs, 00115 CSenElement& aParent); 00116 00120 IMPORT_C virtual ~CSenBaseElement(); 00121 00122 // New functions 00123 00129 IMPORT_C virtual void SetAttributesL(const RAttributeArray& apAttrs); 00130 00131 // Functions from base classes 00132 00133 // From CSenElement 00134 00139 IMPORT_C virtual const TDesC8& LocalName() const; 00140 00145 IMPORT_C virtual const TDesC8& NamespaceURI() const; 00146 00151 IMPORT_C virtual const TDesC8& NsPrefix() const; 00152 00157 IMPORT_C virtual void SetPrefixL(const TDesC8& aPrefix); 00158 00163 IMPORT_C virtual TBool HasContent() const; 00164 00169 IMPORT_C virtual TPtrC8 Content() const; 00170 00175 IMPORT_C virtual HBufC* ContentUnicodeL() const; 00176 00182 IMPORT_C virtual TPtrC8 SetContentL(const TDesC8& aContent); 00183 00190 IMPORT_C virtual RWriteStream& ContentWriteStreamL(); 00191 00202 IMPORT_C virtual TBool ConsistsOfL(MSenElement& aCandidate); 00203 00208 IMPORT_C virtual void SetNamespaceL(const TDesC8& aNsUri); 00209 00215 IMPORT_C virtual void SetNamespaceL(const TDesC8& aNsPrefix, 00216 const TDesC8& aNsUri); 00217 00227 IMPORT_C virtual const CSenNamespace* AddNamespaceL( 00228 CSenNamespace& aNewNamespace, 00229 TBool aCheckInParent); 00236 IMPORT_C virtual const CSenNamespace* AddNamespaceL(const TDesC8& aPrefix, 00237 const TDesC8& aUri); 00243 IMPORT_C virtual const CSenNamespace* Namespace(); 00244 00251 IMPORT_C virtual const CSenNamespace* Namespace(const TDesC8& aNsPrefix); 00252 00263 IMPORT_C virtual const CSenNamespace* Namespace(const TDesC8& aNsPrefix, 00264 const TBool aCheckInParent); 00265 00273 IMPORT_C virtual const CSenNamespace* Namespace(const TDesC8& aNsPrefix, 00274 const TDesC8& aUri); 00275 00287 IMPORT_C virtual TInt ElementsL(RPointerArray<CSenElement>& aElementArray, 00288 const TDesC8& aNsUri, 00289 const TDesC8& aLocalName); 00290 00302 IMPORT_C virtual TInt ElementsL(RPointerArray<CSenElement>& aElementArray, 00303 const TDesC8& aLocalName); 00304 00311 IMPORT_C virtual RPointerArray<CSenElement>& ElementsL(); 00312 00318 IMPORT_C virtual RPointerArray<CSenBaseAttribute>& AttributesL(); 00319 00325 IMPORT_C virtual RPointerArray<CSenNamespace>& NamespacesL(); 00326 00333 IMPORT_C virtual const TDesC8* AttrValue(const TDesC8& aName); 00334 00339 IMPORT_C virtual void AddAttrL(const TDesC8& aName, const TDesC8& aValue); 00340 00346 IMPORT_C virtual CSenElement* Parent(); 00347 00355 IMPORT_C virtual CSenElement* SetParent(CSenElement* apParent); 00356 00361 IMPORT_C virtual MSenElement& Root(); 00362 00369 IMPORT_C virtual CSenElement* Element(const TDesC8& aLocalName); 00370 00376 IMPORT_C virtual CSenElement* Element( const TDesC8& aNsUri, 00377 const TDesC8& aLocalName); 00378 00391 IMPORT_C virtual CSenElement* CreateElementL(const TDesC8& aNsPrefix, 00392 const TDesC8& aLocalName); 00393 00406 IMPORT_C virtual CSenElement& InsertElementL(CSenElement& aElement, 00407 const CSenElement& aBeforeElement); 00408 00415 IMPORT_C virtual CSenElement& AddElementL(CSenElement& aElement); 00416 00427 IMPORT_C virtual CSenElement& AddElementL( const TDesC8& aNsUri, 00428 const TDesC8& aLocalName); 00429 00442 IMPORT_C virtual CSenElement& AddElementL(const TDesC8& aNsUri, 00443 const TDesC8& aLocalName, 00444 const TDesC8& aQName); 00445 00458 IMPORT_C virtual CSenElement& AddElementL(const TDesC8& aLocalName); 00459 00467 IMPORT_C virtual CSenElement* RemoveElement(CSenElement& aElement); 00468 00477 IMPORT_C virtual CSenElement* RemoveElement(const TDesC8& aNsUri, 00478 const TDesC8& aLocalName); 00479 00487 IMPORT_C virtual CSenElement* RemoveElement(const TDesC8& aLocalName); 00488 00499 IMPORT_C virtual CSenElement* ReplaceElementL(CSenElement& aElement); 00500 00505 IMPORT_C virtual HBufC8* AsXmlL(); 00506 00512 IMPORT_C virtual HBufC* AsXmlUnicodeL(); 00513 00518 IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWriteStream); 00519 00525 IMPORT_C virtual void WriteNamespacesToL(RWriteStream& aWriteStream); 00526 00533 IMPORT_C virtual MSenElement* AsElement(); 00534 00540 IMPORT_C void CopyFromL(CSenElement& aSource); 00541 00549 IMPORT_C virtual CSenElement* DetachL(); 00550 00557 IMPORT_C virtual CSenElement* Child(TInt aIndex); 00558 00569 IMPORT_C virtual void Set(const TDesC8& aNsUri, 00570 const TDesC8& aLocalName, 00571 const TDesC8& aQName); 00572 00577 IMPORT_C virtual void AddAttributesL(const RAttributeArray& apAttrs); 00578 00579 protected: 00580 00584 IMPORT_C CSenBaseElement(); 00585 00591 IMPORT_C void BaseConstructL( const TDesC8& aLocalName); 00592 00593 IMPORT_C void BaseConstructL( const TDesC8& aNsUri, 00594 const TDesC8& aLocalName); 00595 00596 IMPORT_C void BaseConstructL( const TDesC8& aNsUri, 00597 const TDesC8& aLocalName, 00598 const TDesC8& aQName); 00599 00600 IMPORT_C void BaseConstructL( const TDesC8& aNsUri, 00601 const TDesC8& aLocalName, 00602 const TDesC8& aQName, 00603 const RAttributeArray& apAttrs); 00604 00605 IMPORT_C void BaseConstructL( const TDesC8& aNsUri, 00606 const TDesC8& aLocalName, 00607 const TDesC8& aQName, 00608 const RAttributeArray& apAttrs, 00609 CSenElement& aParent); 00610 00611 // New functions 00612 00619 IMPORT_C virtual CSenBaseAttribute* FindAttr(const TDesC8& aName); 00620 00628 IMPORT_C virtual TInt IndexOfElement(const TDesC8& aNsUri, 00629 const TDesC8& aLocalName) const; 00630 00635 IMPORT_C virtual void WriteAttrsToL(RWriteStream& aWriteStream); 00636 00643 IMPORT_C virtual void WriteAttrToL(RWriteStream& aWriteStream, 00644 const TDesC8& aName, 00645 const TDesC8& aValue); 00646 00651 IMPORT_C virtual void WriteElementsToL(RWriteStream& aWriteStream); 00652 00657 IMPORT_C virtual void WriteContentToL(RWriteStream& aWriteStream); 00658 00671 IMPORT_C virtual const TDesC8& AddAttributeL(const TDesC8& aQName, 00672 const TDesC8& aLocalName, 00673 const TDesC8& aValue); 00674 00686 IMPORT_C virtual const TDesC8& AddAttributeL(const TDesC8& aAttrName, 00687 const TDesC8& aValue); 00688 00695 IMPORT_C const TDesC8& AddAttributeL(CSenBaseAttribute* apAttribute); 00696 00700 IMPORT_C virtual void AllocContentBufL(); 00701 00707 IMPORT_C virtual TPtrC8 WriteToBufL(CBufBase& aBuf); 00708 00709 private: // New functions 00710 00711 void AddNamespaceMissingFromL(RPointerArray<CSenNamespace>& aNamespaces); 00712 00713 private: // Data 00714 HBufC8* ipLocalName; // Owned 00715 HBufC8* iNotUsed; // Not used (kept for binary compatibility) 00716 CBufFlat* ipContentBuf; // Owned 00717 RBufWriteStream iContentWriteStream; 00718 RPointerArray<CSenBaseAttribute> iAttrs; // Elements owned 00719 RPointerArray<CSenElement> iElements; // Elements owned 00720 RPointerArray<CSenNamespace> iNamespaces; // Elements owned 00721 CSenElement* ipParent; // Not owned 00722 CSenNamespace* ipNamespace; // Not Owned (deleted in upper level array) 00723 }; 00724 00725 // SEN_BASE_ELEMENT_H 00726 #endif 00727 00728 // End of File 00729