williamr@2: /* williamr@2: * Copyright (c) 2002-2005 Nokia Corporation and/or its subsidiary(-ies). williamr@2: * All rights reserved. williamr@2: * This component and the accompanying materials are made available williamr@4: * under the terms of "Eclipse Public License v1.0" williamr@2: * which accompanies this distribution, and is available williamr@4: * at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Central place for debug-type macros williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef SEN_FRAGMENT_H williamr@2: #define SEN_FRAGMENT_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@4: #include williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Abstract base class declaring XML fragment interface. williamr@2: * @lib SenXML.dll williamr@2: * @since Series60 3.0 williamr@2: */ williamr@2: class CSenFragment : public CBase, public MSenFragment williamr@2: { williamr@2: public: // New functions williamr@2: williamr@2: /** williamr@2: * Getting the fragment as an XML element. This method will panic if williamr@2: * element has not been initialized for any reason. williamr@2: * @return the current object as element. Ownership is not transferred. williamr@2: */ williamr@2: virtual CSenElement& AsElement() = 0; williamr@2: williamr@2: /** williamr@2: * @return the current object as element. May return NULL. williamr@2: * Caller takes ownership. williamr@2: * williamr@2: * Note(!): the return value (CSenElement) STRONGLY suggests that williamr@2: * subclasses INHERIT CSenFragment in order properly comply the williamr@2: * requirement of the ExtractElement() implementation. williamr@2: */ williamr@2: virtual CSenElement* ExtractElement() = 0; williamr@2: williamr@2: /** williamr@2: * Sets the XML reader to be used for parsing for the fragment. williamr@2: * @param aReader: the reader to be used. williamr@2: * Ownership is NOT transferred. williamr@2: */ williamr@2: virtual void SetReader(CSenXmlReader& aReader) = 0; williamr@2: williamr@2: /** williamr@2: * Gets the XML reader which this fragment uses for parsing. williamr@2: * @param aReader: the reader to be used. williamr@2: * Ownerships is not transferred. williamr@2: */ williamr@2: virtual CSenXmlReader* Reader() = 0; williamr@2: williamr@2: /** williamr@2: * Method to invoke parsing of a XML data. williamr@2: * Note: SetReader() must be called before this method can be used. williamr@2: * @param aXml: The XML data to be parsed. williamr@2: */ williamr@2: virtual void ParseL(const TDesC8& aXml) = 0; williamr@2: williamr@2: /** williamr@2: * Same as ParseL() except that it doesn't leave in case of an error. williamr@2: * Instead errors are trapped and error is returned. williamr@2: * SetReader() must be called before this method can be used. williamr@2: * @return KErrNone or other system-wide Symbian error codes. williamr@2: */ williamr@2: virtual TInt BuildFrom(const TDesC8& aBuf) = 0; williamr@2: williamr@2: /** williamr@2: * Let the delegate MSenFragment handle the following SAX events. williamr@2: * This fragment is made the owner of the delegate and williamr@2: * the delegate is expected to make this MSenFragment the receiver williamr@2: * of SAX events once it has seen the end element for itself. williamr@2: * @param aDelegate: the fragment to start handling the SAX events. williamr@2: */ williamr@2: virtual void DelegateParsingL(MSenFragment& aDelegate) = 0; williamr@2: williamr@2: /** williamr@2: * Creates a new fragment and lets the created MSenFragment handle williamr@2: * the following SAX events. williamr@2: * This fragment is made the owner of the delegate and williamr@2: * the delegate is expected to make this MSenFragment the receiver williamr@2: * of SAX events once it has seen the end element for itself. williamr@2: * @param aNsUri: the namespace URI of the new delegate williamr@2: * @param aLocalName: the local name of the new delegate williamr@2: * @param aQName: the qualified name of the new delegate williamr@2: * @param aAttrs: the attributes which to be set for the new delegate williamr@2: */ williamr@2: virtual void DelegateParsingL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs) = 0; williamr@2: williamr@2: /** williamr@2: * Sets the reader for this fragment and sets this to be the williamr@2: * content handler of the following SAX events. williamr@2: * @param aReader: Reader to be used. williamr@2: */ williamr@2: virtual void ParseWithL(CSenXmlReader& aReader) = 0; williamr@2: williamr@2: /** williamr@2: * Sets a new parent for this fragment. williamr@2: * @param aFragment: the new parent. williamr@2: */ williamr@2: virtual void SetOwner(MSenFragment& aFragment) = 0; williamr@2: williamr@2: /** williamr@2: * Resumes the parsing. Usually called by the delegate fragment which was williamr@2: * parsing itself after DelegateParsingL(). williamr@2: * @param aNsUri The namespace URI of the current element williamr@2: * @param aLocalName The local name of the current element williamr@2: * @param aQName The qualified name of the current element williamr@2: */ williamr@2: virtual void ResumeParsingFromL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName) = 0; williamr@2: williamr@2: /** williamr@2: * Sets the attributes for the fragment. williamr@2: * @param aAttrs: the array of attributes. williamr@2: */ williamr@2: virtual void SetAttributesL(const RAttributeArray& aAttrs) = 0; williamr@2: williamr@2: /** williamr@2: * Writes the start element tag to the content stream. williamr@2: * Derivants can override the basic usage used in BaseFragment. williamr@2: * @param aNsUri The namespace URI of the current element williamr@2: * @param aLocalName The local name of the current element williamr@2: * @param aQName The qualified name of the current element williamr@2: * @param aAttrs: the array of attributes. williamr@2: */ williamr@2: virtual void WriteStartElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs) = 0; williamr@2: williamr@2: /** williamr@2: * Writes the end element tag to the content stream. williamr@2: * Derivants can override the basic usage used in BaseFragment. williamr@2: * @param aNsUri The namespace URI of the current element williamr@2: * @param aLocalName The local name of the current element williamr@2: * @param aQName The qualified name of the current element williamr@2: */ williamr@2: virtual void WriteEndElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName) = 0; williamr@2: williamr@2: /** williamr@2: * Getter for Fragment's local name. williamr@2: * @return Localname or KNullDesC if not set. williamr@2: */ williamr@2: virtual const TDesC8& LocalName() const = 0; williamr@2: williamr@2: /** williamr@2: * Getter for Fragment's namespace URI. williamr@2: * @return Namespace URI or KNullDesC if not set. williamr@2: */ williamr@2: virtual const TDesC8& NsUri() const = 0; williamr@2: williamr@2: /** williamr@2: * Getter for namespace prefix of this fragment. williamr@2: * @return namespace prefix or KNullDesC if not set. williamr@2: */ williamr@2: virtual const TDesC8& NsPrefix() const = 0; williamr@2: williamr@2: /** williamr@2: * Fragment writes itself to a write stream using UTF-8 charset encoding. williamr@2: * @param aWriteStream: The stream to write to. williamr@2: */ williamr@2: virtual void WriteAsXMLToL(RWriteStream& aWriteStream) = 0; williamr@2: williamr@2: /** williamr@2: * Gets the fragment as an unicode XML buffer. williamr@2: * Buffer will contain all the childs etc. williamr@2: * @return fragment as XML. Caller takes ownership. williamr@2: */ williamr@2: virtual HBufC* AsXmlUnicodeL() = 0; williamr@2: williamr@2: /** williamr@2: * Gets the fragment as an XML buffer. williamr@2: * @return fragment as XML. Caller takes ownership. williamr@2: */ williamr@2: virtual HBufC8* AsXmlL() = 0; williamr@2: williamr@2: /** williamr@2: * Getter for the content. Returns content namespaces if there are any. williamr@2: * @return Content. williamr@2: */ williamr@2: virtual TPtrC8 Content() = 0; williamr@2: williamr@2: /** williamr@2: * Checks if fragment matches to another fragment williamr@2: * by its content and child elements. williamr@2: * Fragment can contain more data than the given candidate. williamr@2: * @since Series60 3.0 williamr@2: * @param aCandidate The pattern to be matched. Must contain same or williamr@2: * less data for match to come true. williamr@2: * @return ETrue if content and possible children match exactly williamr@2: * to given pattern. EFalse otherwise. williamr@2: */ williamr@2: virtual TBool ConsistsOfL(MSenFragment& aCandidate) = 0; williamr@2: }; williamr@2: williamr@2: #endif // SEN_FRAGMENT_H williamr@2: williamr@2: // End of File williamr@2: williamr@2: