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@2: * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members williamr@2: * which accompanies this distribution, and is available williamr@2: * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html". williamr@2: * williamr@2: * Initial Contributors: williamr@2: * Nokia Corporation - initial contribution. williamr@2: * williamr@2: * Contributors: williamr@2: * williamr@2: * Description: Class implements basic functionality of an XML fragment williamr@2: * williamr@2: */ williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: williamr@2: #ifndef SEN_BASE_FRAGMENT_H williamr@2: #define SEN_BASE_FRAGMENT_H williamr@2: williamr@2: // INCLUDES williamr@2: #include williamr@2: #include williamr@2: #include williamr@2: williamr@2: // CONSTANTS williamr@2: williamr@2: // Fragment's internal states. williamr@2: const TInt KStateNotSet = -1; williamr@2: const TInt KStateIgnore = 0; williamr@2: const TInt KStateSave = 1; williamr@2: const TInt KStateResume = 2; williamr@2: williamr@2: // FORWARD DECLARATIONS williamr@2: class CSenXmlReader; williamr@2: williamr@2: // CLASS DECLARATION williamr@2: williamr@2: /** williamr@2: * Class implements basic functionality of an XML fragment williamr@2: * Typically BaseFragment is used to parse certain part of some XML document. williamr@2: * The element is identified by localname (or qualifiedname) and namespace. williamr@2: * All child elements between start tag and and end tag defined this fragment williamr@2: * will become content of this BaseFragment. In other words, BaseFragment has williamr@2: * all data inside a single element. williamr@2: * BaseFragment will parse only namespace (xmlns) attributes from a document williamr@2: * and rest of the attributes are to be handled by subclasses, which should williamr@2: * overwrite SetAttributesL() method to achieve this. williamr@2: * The CSenXmlReader class will do the actual parsing and this class will williamr@2: * act as content handler for XML parser SAX events. williamr@2: * @lib SenXML.dll williamr@2: * @since Series60 3.0 williamr@2: */ williamr@2: class CSenBaseFragment : public CSenFragment, public MSenContentHandlerClient williamr@2: { williamr@2: public: // Constructors and destructor williamr@2: williamr@2: /** williamr@2: * Standard 2 phase constructor. williamr@2: * @since Series60 3.0 williamr@2: * @param aElement is the element where construction williamr@2: * data will be copied from. williamr@2: */ williamr@2: IMPORT_C static CSenBaseFragment* NewL(const CSenElement& aElement); williamr@2: williamr@2: /** williamr@2: * Standard 2 phase constructor. williamr@2: * Leave codes: williamr@2: * KErrSenInvalidCharacters if aLocalName contains williamr@2: * illegal characters. williamr@2: * KErrSenZeroLengthDescriptor if aLocalName is zero length. williamr@2: * @since Series60 3.0 williamr@2: * @param aLocalName: is the XML localname for this fragment williamr@2: */ williamr@2: IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aLocalName); williamr@2: williamr@2: /** williamr@2: * Standard 2 phase constructor. williamr@2: * Leave codes: williamr@2: * KErrSenInvalidCharacters if aLocalName contains williamr@2: * illegal characters. williamr@2: * KErrSenZeroLengthDescriptor if aLocalName is zero length. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri: XML namespace URI williamr@2: * @param aLocalName: XML localname williamr@2: */ williamr@2: IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName); williamr@2: williamr@2: /** williamr@2: * Standard 2 phase constructor. williamr@2: * Leave codes: williamr@2: * KErrSenInvalidCharacters if aLocalName or aQName contains williamr@2: * illegal characters. williamr@2: * KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri: XML namespace URI williamr@2: * @param aLocalName: XML localname williamr@2: * @param aQName: XML qualifiedname williamr@2: */ williamr@2: IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName); williamr@2: williamr@2: /** williamr@2: * Standard 2 phase constructor. williamr@2: * Leave codes: williamr@2: * KErrSenInvalidCharacters if aLocalName or aQName contains williamr@2: * illegal characters. williamr@2: * KErrSenZeroLengthDescriptor if aLocalName or aQName is zero length. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri: XML namespace URI williamr@2: * @param aLocalName: XML localname williamr@2: * @param aQName: XML qualifiedname williamr@2: * @param apAttrs: XML attributes williamr@2: */ williamr@2: IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& apAttrs); williamr@2: williamr@2: /** williamr@2: * Standard 2 phase constructor. williamr@2: * @param aParent Element to be set as fragment's parent element. williamr@2: * Leave codes: williamr@2: * KErrSenInvalidCharacters if aLocalName or aQName contains williamr@2: * illegal characters. williamr@2: * KErrSenZeroLengthDescriptor if aLocalName or aQName is of williamr@2: * zero length. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri: XML namespace URI williamr@2: * @param aLocalName: XML localname williamr@2: * @param aQName: XML qualifiedname williamr@2: * @param apAttrs: XML attributes williamr@2: * @param aParent: Parent element williamr@2: */ williamr@2: IMPORT_C static CSenBaseFragment* NewL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& apAttrs, williamr@2: CSenElement& aParent); williamr@2: williamr@2: /** williamr@2: * Destructor. williamr@2: */ williamr@2: IMPORT_C virtual ~CSenBaseFragment(); williamr@2: williamr@2: williamr@2: // New functions williamr@2: williamr@2: /** williamr@2: * Getter for the content,which is returned as UTF-8 form XML. williamr@2: * @since Series60 3.0 williamr@2: * @return content as UTF-8 form XML. williamr@2: */ williamr@2: IMPORT_C virtual TPtrC8 Content(); williamr@2: /** williamr@2: * Gets the namespace object with a given prefix. williamr@2: * @since Series60 3.0 williamr@2: * @param aPrefix: prefix that wanted namespace should have. williamr@2: * @return namespace with the given prefix. If not found or given prefix williamr@2: * is zero length, will return NULL. williamr@2: */ williamr@2: IMPORT_C virtual CSenNamespace* Namespace(const TDesC8& aPrefix); williamr@2: williamr@2: /** williamr@2: * @since Series60 3.0 williamr@2: * @param aPrefix is the XML namespace prefix williamr@2: */ williamr@2: IMPORT_C virtual void EnsureNamespace(const TDesC8& aPrefix); williamr@2: williamr@2: /** williamr@2: * @since Series60 3.0 williamr@2: * @return Detaches this fragment from its owner. All namespace williamr@2: * references from possible parent fragments are declared in williamr@2: * the scope of this fragment prior detaching. williamr@2: */ williamr@2: IMPORT_C virtual void DetachL(); williamr@2: williamr@2: /** williamr@2: * @since Series60 3.0 williamr@2: * @param aAttrs are the attributes from which the namespaces williamr@2: * are searched from. williamr@2: * @param aEnsure if set to TRUE, the namespaces are copied into williamr@2: * this fragment. If FALSE, then the namespaces are only williamr@2: * referenced, but not copied and owned by this class. williamr@2: */ williamr@2: IMPORT_C virtual void SaveNamespacesL(const RAttributeArray& aAttrs, williamr@2: TBool aEnsure); williamr@2: williamr@2: /** williamr@2: * Resets the content of the fragment, and resets the namespaces. williamr@2: * @since Series60 3.0 williamr@2: */ williamr@2: IMPORT_C virtual void ResetContentL(); williamr@2: williamr@2: // Functions from base classes williamr@2: williamr@2: // From CSenFragment williamr@2: williamr@2: /** williamr@2: * @since Series60 3.0 williamr@2: * @return the localname of this fragment as UTF-8 form descriptor williamr@2: */ williamr@2: IMPORT_C virtual const TDesC8& LocalName() const; williamr@2: williamr@2: /** williamr@2: * Getter for Fragment's namespace URI.. williamr@2: * @since Series60 3.0 williamr@2: * @return Namespace URI or KNullDesC if not set. williamr@2: */ williamr@2: IMPORT_C virtual const TDesC8& NsUri() const; williamr@2: williamr@2: /** williamr@2: * Getter for namespace prefix of this fragment. williamr@2: * @since Series60 3.0 williamr@2: * @return namespace prefix or KNullDesC if not set. williamr@2: */ williamr@2: IMPORT_C virtual const TDesC8& NsPrefix() const; 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: * @since Series60 3.0 williamr@2: * @return the current object as element. Ownership is not transferred. williamr@2: */ williamr@2: IMPORT_C virtual CSenElement& AsElement(); williamr@2: williamr@2: /** williamr@2: * Etracts the XML element from the fragment, leaving the fragment empty. 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: * @since Series60 3.0 williamr@2: * @return the current object as element. May return NULL. williamr@2: * Ownership IS TRANSFERRED to the caller. williamr@2: */ williamr@2: IMPORT_C virtual CSenElement* ExtractElement(); williamr@2: williamr@2: /** williamr@2: * Gets the XML reader which this fragment uses for parsing. williamr@2: * @since Series60 3.0 williamr@2: * @return the XML reader. Ownerships is not transferred, williamr@2: * due even this class does not own the XML reader instance. williamr@2: */ williamr@2: IMPORT_C virtual CSenXmlReader* Reader(); williamr@2: williamr@2: /** williamr@2: * Sets the XML reader to be used for parsing for the fragment. williamr@2: * @since Series60 3.0 williamr@2: * @param aReader: the reader to be used. williamr@2: * Ownership is NOT transferred. williamr@2: */ williamr@2: IMPORT_C virtual void SetReader(CSenXmlReader& aReader); williamr@2: williamr@2: /** williamr@2: * Leave codes: williamr@2: * KErrSenXmlReaderNotSet if XML reader has not been set. williamr@2: * Method to invoke parsing of a XML data. williamr@2: * Note that SetReader() must be called before this method can be used. williamr@2: * Note that CSenBaseFragment does not parse any other williamr@2: * attributes, but XML namespace attributes only. This williamr@2: * is due to allow subclasses to process only those attributes williamr@2: * they are interested in, and not others. williamr@2: * @since Series60 3.0 williamr@2: * @param aXml: The data to be parsed. williamr@2: */ williamr@2: IMPORT_C virtual void ParseL(const TDesC8& aXml); 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: * @since Series60 3.0 williamr@2: * @param aXml: The data to be parsed. williamr@2: * @return KErrNone or other system-wide Symbian error codes. williamr@2: */ williamr@2: IMPORT_C virtual TInt BuildFrom(const TDesC8& aXml); williamr@2: williamr@2: /** williamr@2: * Leave codes: williamr@2: * KErrSenXmlReaderNotSet if XML reader has not been set. williamr@2: * Let the delegate MSenFragment handle the following SAX events. williamr@2: * This fragment is made the owner of the delegate and the delegate williamr@2: * is expected to make this MSenFragment the receiver of SAX events williamr@2: * once it has seen the end element for itself. williamr@2: * @since Series60 3.0 williamr@2: * @param aDelegate is the fragment to start handling the SAX events. williamr@2: */ williamr@2: IMPORT_C virtual void DelegateParsingL(MSenFragment& aDelegate); williamr@2: williamr@2: /** williamr@2: * Leave codes: williamr@2: * KErrSenXmlReaderNotSet if XML reader has not been set. williamr@2: * Creates a new fragment and lets the created MSenFragment handle the williamr@2: * following SAX events. This fragment is made the owner of the delegate williamr@2: * and the delegate is expected to make this MSenFragment act as receiver williamr@2: * for SAX events (callbacks) once it has seen the end element for itself. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri The XML namespace URI for the delegate to be created williamr@2: * @param aLocalName The XML localname for the delegate to be created williamr@2: * @param aQName The XML qualifiedname for the delegate to be created williamr@2: * @param aAttrs: The XML attributes for the delegate to be created williamr@2: */ williamr@2: IMPORT_C virtual void DelegateParsingL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs); 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: * @since Series60 3.0 williamr@2: * @param aReader is the XML parser to be used. williamr@2: */ williamr@2: IMPORT_C virtual void ParseWithL(CSenXmlReader& aReader); williamr@2: williamr@2: /** williamr@2: * Sets a new parent for this fragment. williamr@2: * @since Series60 3.0 williamr@2: * @param aFragment: the new parent. williamr@2: */ williamr@2: IMPORT_C virtual void SetOwner(MSenFragment& aFragment); williamr@2: williamr@2: /** williamr@2: * Leave codes: williamr@2: * KErrSenXmlReaderNotSet if XML reader has not been set. Resumes williamr@2: * parsing to be handled by this fragment. Usually called by some williamr@2: * delegate fragment which was set to be content handler because this williamr@2: * fragment called DelegateParsingL(). williamr@2: * @since Series60 3.0 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: IMPORT_C virtual void ResumeParsingFromL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName); williamr@2: williamr@2: /** williamr@2: * Sets the attributes for the fragment. BaseFragment parses only williamr@2: * namespace (xmlns) attributes from the document. williamr@2: * Subclasses should override this method if they are intrested williamr@2: * of handling any other XML attributes and their corresponding williamr@2: * values. williamr@2: * @since Series60 3.0 williamr@2: * @param aAttrs: the array of attributes. williamr@2: */ williamr@2: IMPORT_C virtual void SetAttributesL(const RAttributeArray& aAttrs); 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: * @since Series60 3.0 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 is the array of attributes. williamr@2: */ williamr@2: IMPORT_C void WriteStartElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs); 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: * @since Series60 3.0 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: IMPORT_C void WriteEndElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName); williamr@2: williamr@2: /** williamr@2: * Gets the fragment data as an unicode XML. williamr@2: * @since Series60 3.0 williamr@2: * @return fragment as XML. Caller takes ownership. williamr@2: */ williamr@2: IMPORT_C virtual HBufC* AsXmlUnicodeL(); williamr@2: williamr@2: /** williamr@2: * Gets the fragment data as an UTF-8 form XML. williamr@2: * @since Series60 3.0 williamr@2: * @return fragment as XML. Caller takes ownership. williamr@2: */ williamr@2: IMPORT_C virtual HBufC8* AsXmlL(); williamr@2: williamr@2: /** williamr@2: * Invokes AsElement()->WriteAsXMLToL(aWs); williamr@2: * @since Series60 3.0 williamr@2: * @param aWs is the stream into which the UTF-8 form XML will williamr@2: * be written. williamr@2: */ williamr@2: IMPORT_C virtual void WriteAsXMLToL(RWriteStream& aWs); 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: IMPORT_C virtual TBool ConsistsOfL(MSenFragment& aCandidate); williamr@2: williamr@2: protected: williamr@2: williamr@2: /** williamr@2: * C++ default constructor. williamr@2: */ williamr@2: IMPORT_C CSenBaseFragment(); williamr@2: williamr@2: /** williamr@2: * Following BaseConstructL methods should be called from ConstructL() williamr@2: * methods of some deriving (fragment) class. williamr@2: */ williamr@2: williamr@2: /** williamr@2: * BaseConstructL, where an element is given as initializer. williamr@2: * @since Series60 3.0 williamr@2: * @param aElement from which this fragment will be constructed from. williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(const CSenElement& aElement); williamr@2: williamr@2: /** williamr@2: * BaseConstructL setting XML localname for this fragment. williamr@2: * @since Series60 3.0 williamr@2: * @param aLocalName XML localname for this fragment williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(const TDesC8& aLocalName); williamr@2: williamr@2: /** williamr@2: * BaseConstructL offering possibility to set XML namespace and localname. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri XML namespace URI for this fragment williamr@2: * @param aLocalName XML localname for this fragment williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName); williamr@2: williamr@2: /** williamr@2: * Base constructor williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri XML namespace URI for this fragment williamr@2: * @param aLocalName XML localname for this fragment williamr@2: * @param aQName XML qualifiedname for this fragment williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName); williamr@2: /** williamr@2: * Base constructor williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri XML namespace URI for this fragment williamr@2: * @param aLocalName XML localname for this fragment williamr@2: * @param aQName XML qualifiedname for this fragment williamr@2: * @param aAttrs XML attributes for this fragment williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs); williamr@2: williamr@2: /** williamr@2: * Base constructor williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri XML namespace URI for this fragment williamr@2: * @param aLocalName XML localname for this fragment williamr@2: * @param aQName XML qualifiedname for this fragment williamr@2: * @param aAttrs XML attributes for this fragment williamr@2: * @param aParent parent to be set for this fragmemt williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs, williamr@2: CSenElement& aParent); williamr@2: williamr@2: /** williamr@2: * BaseConstructL() setting the XML reader for this fragment williamr@2: * @since Series60 3.0 williamr@2: * @param aReader is the XML reader for this fragment williamr@2: */ williamr@2: IMPORT_C void BaseConstructL(CSenXmlReader& aReader); williamr@2: williamr@2: // New functions williamr@2: williamr@2: /** williamr@2: * Makes the content internal stream for content saving available. williamr@2: * @since Series60 3.0 williamr@2: */ williamr@2: IMPORT_C virtual void AllocContentSaverL(); williamr@2: williamr@2: /** williamr@2: * Callback function implementing the XML content handler interface. williamr@2: * Inheriting classes can override these. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri The namespace URI of the new element williamr@2: * @param aLocalName The local name of the new element williamr@2: * @param aQName The qualified name of the new element williamr@2: * @param aAttrs The attributes of the new element williamr@2: */ williamr@2: IMPORT_C virtual void StartElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs); williamr@2: williamr@2: /** williamr@2: * Callback function which implement the XML content handler interface. williamr@2: * Inheriting classes can override these. williamr@2: * @since Series60 3.0 williamr@2: * @param aNsUri The namespace URI of the new element williamr@2: * @param aLocalName The local name of the new element williamr@2: * @param aQName The qualified name of the new element williamr@2: */ williamr@2: IMPORT_C virtual void EndElementL(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName); williamr@2: williamr@2: /** williamr@2: * Function which implement the XML content handler interface. williamr@2: * Inheriting classes can override these. williamr@2: * This one is called when content is starting. williamr@2: * @since Series60 3.0 williamr@2: * @param aChars The content characters. williamr@2: * @param aStart The starting index williamr@2: * @param aLength The length of the characters. williamr@2: */ williamr@2: IMPORT_C virtual void CharactersL(const TDesC8& aChars, williamr@2: TInt aStart, williamr@2: TInt aLength); williamr@2: williamr@2: /** williamr@2: * Callback function which implement the XML content handler interface. williamr@2: * Inheriting classes can override these. Note that overrides should williamr@2: * return TRUE (1) on success and FALSE (0) on failure to parser. williamr@2: * williamr@2: * @since Series60 3.0 williamr@2: * @param aName The entity name williamr@2: * williamr@2: */ williamr@2: IMPORT_C TInt StartEntity(TDesC8& aName); williamr@2: williamr@2: /** williamr@2: * Sets content to a child element. If no element with given local name williamr@2: * is not found, new one is added and content is set to that one. williamr@2: * @since Series60 3.0 williamr@2: * @param aLocalName The local name of element which content williamr@2: * is about to be set williamr@2: * @param aContent Content to be set. williamr@2: * @return the element where content was set. williamr@2: * Leave codes: williamr@2: * KErrSenInvalidCharacters if aLocalName contains illegal characters. williamr@2: * KErrSenZeroLengthDescriptor if aLocalName is zero length. williamr@2: */ williamr@2: IMPORT_C MSenElement& SetContentOfL(const TDesC8& aLocalName, williamr@2: const TDesC8& aContent); williamr@2: /** williamr@2: * Gets the content of a given element. williamr@2: * @since Series60 3.0 williamr@2: * @param aLocalName The local name of the element which content is williamr@2: * asked williamr@2: * @return the content which was asked williamr@2: */ williamr@2: IMPORT_C TPtrC8 ContentOf(const TDesC8& aLocalName); williamr@2: williamr@2: private: // New functions williamr@2: williamr@2: /** williamr@2: * Leaving variant which is then trapped in the non-leaving function. williamr@2: */ williamr@2: TPtrC8 ContentL(); williamr@2: williamr@2: // Functions from base classes williamr@2: williamr@2: // From MSenContentHandlerClient williamr@2: williamr@2: IMPORT_C virtual TInt StartDocument(); williamr@2: IMPORT_C virtual TInt EndDocument(); williamr@2: IMPORT_C virtual TInt StartElement(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName, williamr@2: const RAttributeArray& aAttrs); williamr@2: williamr@2: IMPORT_C virtual TInt EndElement(const TDesC8& aNsUri, williamr@2: const TDesC8& aLocalName, williamr@2: const TDesC8& aQName); williamr@2: williamr@2: IMPORT_C virtual TInt Characters(const TDesC8& aChars, williamr@2: const TInt aStart, williamr@2: const TInt aLength); williamr@2: williamr@2: IMPORT_C virtual TInt Error(TInt aErrorCode); williamr@2: williamr@2: //IMPORT_C TInt StartEntityL(const TDesC8& aName); williamr@2: williamr@2: williamr@2: protected: // Data williamr@2: williamr@2: // State variable indicating what this fragment williamr@2: // is currently parsing. Even states (like 0) williamr@2: // mean that this fragment is ignoring the williamr@2: // data, and odd states indicate, that fragment williamr@2: // is storing the data into itself. williamr@2: TInt iState; williamr@2: // Owned element containing this XML fragment data. williamr@2: CSenElement* ipElement; williamr@2: // Pointer to XML parser. Not owned. williamr@2: CSenXmlReader* iXmlReader; williamr@2: // Possible owner fragment, if such exists. Not owned. williamr@2: MSenFragment* ipOwner; williamr@2: // Internal write stream, into which UTF-8 form XML is stored williamr@2: RWriteStream iWs; williamr@2: williamr@2: private: // Data williamr@2: williamr@2: // Owned pointer to delegate fragment williamr@2: CSenFragment* ipDelegate; williamr@2: // Not owned. Holds namespaces that are referred to from williamr@2: // within the content but were not declared within this williamr@2: // BaseFragment. williamr@2: RPointerArray iNamespaces; williamr@2: // Owned. Holds prefixes that have been declared within the williamr@2: // scope of this BaseFragment williamr@2: RPointerArray iPrefixes; williamr@2: // Actual flat buffer to content which includes namespaces. williamr@2: CBufFlat* ipContentWithNamespaces; williamr@2: // Indicating that content writing stream is initialized. williamr@2: TBool hasContentWriteStream; williamr@2: // Indicates whether or not ipElement member is an owned williamr@2: TBool iElementOwned; williamr@2: }; williamr@2: williamr@2: #endif //SEN_BASE_FRAGMENT_H williamr@2: williamr@2: // End of File williamr@2: williamr@2: williamr@2: