Symbian3/PDK/Source/GUID-C3086910-D7B4-5549-BF65-374C8B602E8F.dita
author Dominic Pinkman <Dominic.Pinkman@Nokia.com>
Thu, 11 Mar 2010 18:02:22 +0000
changeset 3 46218c8b8afa
parent 1 25a17d01db0c
child 5 f345bda72bc4
permissions -rw-r--r--
week 10 bug fix submission (SF PDK version): Bug 1892, Bug 1897, Bug 1319. Also 3 or 4 documents were found to contain code blocks with SFL, which has been fixed. Partial fix for broken links, links to Forum Nokia, and the 'Symbian platform' terminology issues.

<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies) All rights reserved. -->
<!-- This component and the accompanying materials are made available under the terms of the License 
"Eclipse Public License v1.0" which accompanies this distribution, 
and is available at the URL "http://www.eclipse.org/legal/epl-v10.html". -->
<!-- Initial Contributors:
    Nokia Corporation - initial contribution.
Contributors: 
-->
<!DOCTYPE task
  PUBLIC "-//OASIS//DTD DITA Task//EN" "task.dtd">
<task id="GUID-C3086910-D7B4-5549-BF65-374C8B602E8F" xml:lang="en"><title>Compressing
and Decompressing Memory Streams </title><shortdesc>The Zip Compression Library, EZLib provides stream compression
and decompression functionality for the Symbian platforms. This tutorial summarizes
the procedure involved in the compression and decompression of memory streams
by EZLib. </shortdesc><prolog><metadata><keywords/></metadata></prolog><taskbody>
<context id="GUID-FF2527FF-1DFC-59B3-AC6D-5D7FDF7CCDF7"><p>The functions used
for memory stream compression and decompression are provided by the <xref href="GUID-AEF8BCC8-6B24-3D59-AD3A-17B5203B3AA5.dita"><apiname>CEZCompressor</apiname></xref> class. </p> <p>The
compression can be executed in single or multiple steps. This is depenedent
on the buffer size of the memory stream. Small buffers are compressed in a
single step. Larger buffers are compressed in small chunks repeatedly till
the entire buffer is compressed. Clients must respond to callbacks from the
library to provide information and resources required to complete the task. </p> </context>
<steps id="GUID-9F423FB8-8AC5-54EC-B879-04EFA022FD38">
<step id="GUID-D640BCC5-5F5D-5377-9553-F86F5E5D0D56"><cmd/>
<info>Define a buffer manager that implements <xref href="GUID-B90BA6D6-72A2-3EB8-B8EF-CD5408107A9E.dita"><apiname>MEZBufferManager</apiname></xref>. </info>
</step>
<step id="GUID-C8020D99-632E-578A-85A4-4934380A0FD2"><cmd/>
<info>Create an instance of the classs <xref href="GUID-AEF8BCC8-6B24-3D59-AD3A-17B5203B3AA5.dita"><apiname>CEZCompressor</apiname></xref>. </info>
<substeps id="GUID-F4B79439-492C-56A1-A1D9-D92139842405">
<substep id="GUID-C43B76C8-7A9A-5F41-9A9F-210A9267D50E"><cmd/>
<info>Invoke <xref href="GUID-AEF8BCC8-6B24-3D59-AD3A-17B5203B3AA5.dita#GUID-AEF8BCC8-6B24-3D59-AD3A-17B5203B3AA5/GUID-8A60D49C-5E3A-3CF8-9738-B53E7439910A"><apiname>CEZCompressor::CompressL()</apiname></xref> for small buffers. </info>
</substep>
<substep id="GUID-06D723F2-2B7A-5865-B32F-945CE361A4E9"><cmd/>
<info>Invoke <xref href="GUID-AEF8BCC8-6B24-3D59-AD3A-17B5203B3AA5.dita#GUID-AEF8BCC8-6B24-3D59-AD3A-17B5203B3AA5/GUID-03E4E3A2-3830-3209-9D7B-A2238B5AF219"><apiname>CEZCompressor::DeflateL()</apiname></xref> repeatedly on larger
buffers until the entire buffer is compressed. </info>
</substep>
</substeps>
<stepxmp><codeblock xml:space="preserve">class CBufferManager : public CBase, public MEZBufferManager
    {
public:
  CBufferManager* CBufferManager::NewLC();
  CBufferManager* CBufferManager::NewL();
    ~CBufferManager();
    void InitializeL(CEZZStream &amp;aZStream);
    void NeedInputL(CEZZStream &amp;aZStream);
    void NeedOutputL(CEZZStream &amp;aZStream);
    void FinalizeL(CEZZStream &amp;aZStream);
    };
        
CBufferManager* CBufferManager::NewLC()
    {
    CBufferManager* bm = new (ELeave) CBufferManager();
    CleanupStack::PushL(bm);
    return bm;
    }

CBufferManager* CBufferManager::NewL()
    {
    CBufferManager* bm = new (ELeave) CBufferManager();
    CleanupStack::PushL(bm);
    CleanupStack::Pop();
    return bm;
    }
 
static void doExampleL()
    {
    
  CBufferManager* bm = CBufferManager::NewLC();
  //TInt aLevel = EDefaultCompression, TInt aWindowBits = EMaxWBits, TInt aMemLevel = EDefMemLevel, TStrategy aStrategy = EDefaultStrategy);
  CEZCompressor* iCEZCompressor = CEZCompressor::NewLC(*bm); // all other flag values are default in its constructer
   
  while(icompressor-&gt;DeflateL())
        {       
        }     
   

  CleanupStack::PopAndDestroy(2);

    }
</codeblock></stepxmp>
</step>
</steps>
<postreq id="GUID-4B702763-6D4E-5C32-803B-042024622BAE"><p>To decompress the
memory streams: </p> <ol id="GUID-F4AEDE06-67FC-5624-9D36-FC08D5B460C2">
<li id="GUID-5F44590E-8F53-5B75-ADC9-59073140BA57"><p>Define a buffer manager
that implements <xref href="GUID-B90BA6D6-72A2-3EB8-B8EF-CD5408107A9E.dita"><apiname>MEZBufferManager</apiname></xref>. </p> </li>
<li id="GUID-014484C5-7F1A-5350-B0AD-383091DDA300"><p>Create an instance of
the classs <xref href="GUID-BC3CEC02-B747-38FB-8B35-E7390DB06E35.dita"><apiname>CEZDecompressor</apiname></xref>. </p> </li>
<li id="GUID-EAE82B73-E86B-5E81-8E19-22FCD5EA95AC"><p>Invoke <xref href="GUID-BC3CEC02-B747-38FB-8B35-E7390DB06E35.dita#GUID-BC3CEC02-B747-38FB-8B35-E7390DB06E35/GUID-D9133787-E96C-3E9B-8991-0F0184C7AE7E"><apiname>CEZDecompressor::DecompressL()</apiname></xref> for
small buffers. </p> <p>Invoke <xref href="GUID-BC3CEC02-B747-38FB-8B35-E7390DB06E35.dita#GUID-BC3CEC02-B747-38FB-8B35-E7390DB06E35/GUID-0AC99B66-412B-3CCF-84DA-D7BC0F0D32B2"><apiname>CEZDecompressor::InflateL()</apiname></xref> repeatedly
on larger buffers until the entire buffer is compressed. </p> </li>
</ol> </postreq>
</taskbody></task>