xml/xmldomandxpath/src/xmlengineserializer/xmlenggzipbufferdeserializebm.cpp
changeset 0 e35f40988205
equal deleted inserted replaced
-1:000000000000 0:e35f40988205
       
     1 // Copyright (c) 2006-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 // GZIP output stream functions
       
    15 //
       
    16 
       
    17 #include "xmlenggzipbufferdeserializebm.h"
       
    18 #include <ezstream.h>
       
    19 #include <ezcompressor.h>
       
    20 
       
    21 
       
    22 
       
    23     CXmlEngGZipBufferDeserializeBM* CXmlEngGZipBufferDeserializeBM::NewLC(  Xml::CParser* aParser, const TDesC8& aInputBuffer, TInt aOutBufSize  )
       
    24 	    {
       
    25 	    CXmlEngGZipBufferDeserializeBM* bm = new (ELeave) CXmlEngGZipBufferDeserializeBM( aParser, aInputBuffer );
       
    26 	    CleanupStack::PushL( bm );
       
    27 	    bm->ConstructL( aOutBufSize );
       
    28 	    return bm;	
       
    29 	    }
       
    30 
       
    31     CXmlEngGZipBufferDeserializeBM* CXmlEngGZipBufferDeserializeBM::NewL( Xml::CParser* aParser, const TDesC8& aInputBuffer, TInt aOutBufSize )
       
    32 	    {
       
    33 	    CXmlEngGZipBufferDeserializeBM* bm = CXmlEngGZipBufferDeserializeBM::NewLC( aParser, aInputBuffer, aOutBufSize );
       
    34 	    CleanupStack::Pop( bm );
       
    35 	    return bm;	
       
    36 	    }
       
    37 
       
    38    CXmlEngGZipBufferDeserializeBM::CXmlEngGZipBufferDeserializeBM( Xml::CParser* aParser, const TDesC8& aInputBuffer )
       
    39         : iOutputDescriptor(NULL,0)
       
    40         {
       
    41         iParser = aParser;
       
    42         iInputDescriptor.Set(aInputBuffer);
       
    43         }
       
    44 
       
    45    void CXmlEngGZipBufferDeserializeBM::ConstructL( TInt aOutBufSize )
       
    46         {
       
    47 	    if ( aOutBufSize <= 0 ) 
       
    48 	        {
       
    49 	        User::Leave(KErrArgument);
       
    50 	        }
       
    51 	    iOutputBuffer = new (ELeave) TUint8[aOutBufSize];
       
    52 	    iOutputDescriptor.Set(iOutputBuffer,0,aOutBufSize);
       
    53         }
       
    54 
       
    55    CXmlEngGZipBufferDeserializeBM::~CXmlEngGZipBufferDeserializeBM()
       
    56         {
       
    57         delete iOutputBuffer;
       
    58         }
       
    59     
       
    60     void CXmlEngGZipBufferDeserializeBM::InitializeL( CEZZStream& aZStream )
       
    61     	{
       
    62     	iParser->ParseBeginL();
       
    63     	aZStream.SetInput( iInputDescriptor );
       
    64     	aZStream.SetOutput( iOutputDescriptor );
       
    65     	}
       
    66 
       
    67     void CXmlEngGZipBufferDeserializeBM::NeedInputL( CEZZStream& aZStream )
       
    68     	{
       
    69     	//no input except iInputDescriptor
       
    70         aZStream.SetInput( KNullDesC8 );
       
    71     	}
       
    72 
       
    73     void CXmlEngGZipBufferDeserializeBM::NeedOutputL( CEZZStream& aZStream )
       
    74     	{
       
    75     	TPtrC8 od = aZStream.OutputDescriptor();    	
       
    76     	iParser->ParseL( od );
       
    77     	aZStream.SetOutput( iOutputDescriptor );
       
    78     	}
       
    79 
       
    80     void CXmlEngGZipBufferDeserializeBM::FinalizeL( CEZZStream& aZStream )
       
    81         {
       
    82         TPtrC8 od = aZStream.OutputDescriptor();
       
    83         iParser->ParseL( od );
       
    84         iParser->ParseEndL();
       
    85     	}
       
    86 
       
    87