williamr@4: // Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). williamr@4: // All rights reserved. williamr@4: // This component and the accompanying materials are made available williamr@4: // under the terms of "Eclipse Public License v1.0" williamr@4: // which accompanies this distribution, and is available williamr@4: // at the URL "http://www.eclipse.org/legal/epl-v10.html". williamr@4: // williamr@4: // Initial Contributors: williamr@4: // Nokia Corporation - initial contribution. williamr@4: // williamr@4: // Contributors: williamr@4: // williamr@4: // Description: williamr@4: // XML Deserializer to DOM tree williamr@4: // williamr@4: williamr@4: williamr@4: williamr@4: /** williamr@4: @file williamr@4: @publishedAll williamr@4: @released williamr@4: */ williamr@4: #ifndef XMLENGDESERIALIZERDOM_H williamr@4: #define XMLENGDESERIALIZERDOM_H williamr@4: williamr@4: #include williamr@4: williamr@4: #include williamr@4: #include williamr@4: williamr@4: williamr@4: class RFs; williamr@4: class RXmlEngDOMImplementation; williamr@4: class RXmlEngDocument; williamr@4: williamr@4: /** williamr@4: Deserializes a XML file to a DOM tree. williamr@4: williamr@4: Sample code for deserialization to a DOM tree: williamr@4: @code williamr@4: // create deserializer williamr@4: CXmlEngDeserializerDOM* deserializer = CXmlEngDeserializerDOM::NewL(); williamr@4: CleanupStack::PushL(deserializer); williamr@4: // configure deserializer williamr@4: deserializer->SetInputFileL(KInputFile, EDeserializerGZip); williamr@4: // Set the DOM Implementation williamr@4: deserializer->UseDOMImplementationL(iDomImpl); williamr@4: // deserialize williamr@4: RXmlEngDocument doc = deserializer->DeserializeL(); williamr@4: CleanupStack::PopAndDestroy();// deserializer williamr@4: @endcode williamr@4: */ williamr@4: class CXmlEngDeserializerDOM: public CBase williamr@4: { williamr@4: public: williamr@4: /** williamr@4: Creates an instance of CXmlEngDeserializerDOM. williamr@4: @return The DOM deserializer instance williamr@4: @leave KErrNoMemory Memory allocation failure williamr@4: */ williamr@4: IMPORT_C static CXmlEngDeserializerDOM* NewL(); williamr@4: williamr@4: /** williamr@4: Sets the input type to file and saves the file name for later williamr@4: deserialization. williamr@4: @param aFileName The file name of the file to deserialize williamr@4: @param aType The deserialization format williamr@4: @leave - One of the system-wide error codes williamr@4: */ williamr@4: IMPORT_C void SetInputFileL(const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault); williamr@4: williamr@4: /** williamr@4: Sets the input to to buffer and saves the buffer for later deserialization. williamr@4: @param aBuffer The buffer to deserialize williamr@4: @param aType The deserialization format williamr@4: */ williamr@4: IMPORT_C void SetInputBuffer(const TDesC8& aBuffer, TXmlEngDeserializerType aType = EDeserializerDefault); williamr@4: williamr@4: /** williamr@4: Sets a list of data containers and indicates that the XML to be williamr@4: deserialized contains references (such as xop:include) to data stored williamr@4: outside the DOM tree. williamr@4: williamr@4: Upon deserialization, the references are substituted with the matching data williamr@4: containers and returned via the content handler. williamr@4: williamr@4: This often occurs when a multipart MIME message is received. The text XML williamr@4: content may be in one part, while the binary content is in another part. williamr@4: Each part containing binary content must be placed into a data container using williamr@4: RXmlEngDocument::CreateBinaryContainerL() or similar. When deserialization williamr@4: of the XML occurs, the data containers are retrieved by content-id. williamr@4: williamr@4: Ownership is not transferred and the list must stay in scope for the williamr@4: lifetime of the deserializer. williamr@4: williamr@4: @param aList The list of data containers williamr@4: @leave - Any system-wide error code williamr@4: */ williamr@4: IMPORT_C void UseExternalDataL(RArray& aList); williamr@4: williamr@4: /** williamr@4: Gets the list of external data containers. williamr@4: @return The list of data containers or NULL if no external data is registered williamr@4: */ williamr@4: IMPORT_C RArray* ExternalData(); williamr@4: williamr@4: /** williamr@4: Sets the DOM implementation that will be used to create the DOM tree williamr@4: @param aImpl The DOM implementation williamr@4: @leave - Does not leave williamr@4: */ williamr@4: IMPORT_C void UseDOMImplementationL(RXmlEngDOMImplementation& aImpl); williamr@4: williamr@4: /** williamr@4: Deserializes the file or buffer previously set by SetInputFileL() or williamr@4: SetInputBuffer() and creates a new document that holds the DOM tree. williamr@4: williamr@4: @return The document that holds the DOM tree williamr@4: @leave KXmlEngErrNoParameters No file or buffer has been previously set williamr@4: @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set williamr@4: @leave - One of the system-wide error codes williamr@4: */ williamr@4: IMPORT_C RXmlEngDocument DeserializeL(); williamr@4: williamr@4: /** williamr@4: Deserializes the given file and creates a new document that holds the DOM williamr@4: tree. Any filename previously set with SetInputFileL() is ignored. williamr@4: williamr@4: @param aFileName The file to be deserialized williamr@4: @param aType The deserialization format williamr@4: @return The document that holds the DOM tree williamr@4: @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set williamr@4: @leave - One of the system wide error codes williamr@4: */ williamr@4: IMPORT_C RXmlEngDocument DeserializeL( const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault); williamr@4: williamr@4: /** williamr@4: Deserializes the given file and creates a new document that holds the DOM williamr@4: tree. Any filename previously set with SetInputFileL() is ignored. williamr@4: williamr@4: @param aRFs File Server session williamr@4: @param aFileName The file to be deserialized williamr@4: @param aType The deserialization format williamr@4: @return The document that holds the DOM tree williamr@4: @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set williamr@4: @leave - One of the system wide error codes williamr@4: */ williamr@4: IMPORT_C RXmlEngDocument DeserializeL( RFs& aRFs, const TDesC& aFileName, TXmlEngDeserializerType aType = EDeserializerDefault); williamr@4: williamr@4: /** williamr@4: Deserializes the given buffer and creates a new document that holds the DOM williamr@4: tree. Any buffer previously set with SetInputBuffer() is ignored. williamr@4: williamr@4: @param aBuffer Buffer to be parsed williamr@4: @param aType Input type williamr@4: @return The document that holds the DOM tree williamr@4: @leave KXmlEngErrWrongUseOfAPI DOM Implementation not set williamr@4: @leave - One of the system wide error codes williamr@4: */ williamr@4: IMPORT_C RXmlEngDocument DeserializeL( const TDesC8& aBuffer, TXmlEngDeserializerType aType = EDeserializerDefault); williamr@4: williamr@4: /** Destructor. */ williamr@4: ~CXmlEngDeserializerDOM(); williamr@4: williamr@4: protected: williamr@4: /** Default constructor. */ williamr@4: CXmlEngDeserializerDOM(); williamr@4: williamr@4: protected: williamr@4: /** File to be parsed */ williamr@4: HBufC* iInputFileName; williamr@4: /** Buffer to be parsed */ williamr@4: TPtrC8 iBuffer; williamr@4: /** Array of external data */ williamr@4: RArray* iDataList; williamr@4: /** Deserializer type */ williamr@4: TXmlEngDeserializerType iType; williamr@4: /** DOM implementation */ williamr@4: RXmlEngDOMImplementation* iImpl; williamr@4: williamr@4: }; //class CXmlEngDeserializerDOM williamr@4: williamr@4: #endif /* XMLENGDESERIALIZERDOM_H */ williamr@4: