![]() ![]() ![]()
|
BREW C++ Class Library & GUI Framework & XML Middleware : SophiaFramework 4.1 |
#include <SFXZIPDecoder.h.hpp>
class SFXZIPDecoder : public SFXStorage;
typedef SFXZIPDecoder& SFXZIPDecoderRef; typedef SFXZIPDecoder* SFXZIPDecoderPtr; typedef SFXZIPDecoder*& SFXZIPDecoderPtrRef; typedef SFXZIPDecoder** SFXZIPDecoderHandle; typedef const SFXZIPDecoder ConstSFXZIPDecoder; typedef const SFXZIPDecoder& ConstSFXZIPDecoderRef; typedef const SFXZIPDecoder* ConstSFXZIPDecoderPtr; typedef const SFXZIPDecoder*& ConstSFXZIPDecoderPtrRef; typedef const SFXZIPDecoder** ConstSFXZIPDecoderHandle;


Register the DEFLATE compressed data of storage class such as SFXFile, SFXTCPSocket, etc. or SFBSource class or SFBAStream class, and then get the decompressed data.
How to use the SFXZIPDecoder class
Example 504. Sample code for decompress a gzip file
// define the SFXZIPDecoder instance, _decoder, as class member variable class MyClass { private: SFXFile _file; SFXZIPDecoder _decoder; // SFXZIPDecoder instance SFXAnsiStringStreamReader _reader; // input stream for reading data from ZIPDecoder SFXAnsiString _unzipString; // variable in which decompressed string is stored public: Void Start(Void); // callback function declaration CALLBACK_DECLARE_SFXANSISTRINGSTREAMREADER(OnFetch) }; Void MyClass::Start(Void) { SFCError error; // error value // open file in read only mode if ((error = _file.OpenReadOnly(SFXPath("/testdata.tar.gz"))) == SFERR_NO_ERROR) { // register file storage in ZIPDecoder if ((error = _decoder.Open(_file)) == SFERR_NO_ERROR) { // get input stream for reading data from ZIPDecoder if ((error = _decoder.GetStreamReader(&_reader)) == SFERR_NO_ERROR) { // read data from ZIPDecoder into input stream // OnFetch function is notified of the completion of this operation if ((error = _reader.Fetch(CALLBACK_FUNCTION(OnFetch))) != SFERR_NO_ERROR) { // if error occurs _reader.Release(); } } if (error != SFERR_NO_ERROR) { // if error occurs _decoder.Close(); } } if (error != SFERR_NO_ERROR) { // if error occurs _file.Close(); } } } // callback function notified after reading data from ZIPDecoder CALLBACK_IMPLEMENT_SFXANSISTRINGSTREAMREADER(MyClass, OnFetch, error) { if (error == SFERR_NO_ERROR) { // if no error // read decompressed data from input stream to _unzipString variable if ((error = _reader.ReadSFXAnsiString(&_unzipString)) == SFERR_NO_ERROR) { // display decompressed data TRACE("%s", _unzipString.GetCString()); } } // close _decoder.Close(); _file.Close(); }
| Constructor/Destructor |
|---|
|
SFXZIPDecoder( Void ) Constructor of SFXZIPDecoder class.
|
|
~SFXZIPDecoder( Void ) Destructor of SFXZIPDecoder class.
|
| Public Functions | |
|---|---|
| SFCError |
AsSFBAStream(
SFBAStreamSmpPtr result
) Convert the input stream used internally into the instance of SFBAStream class.
|
| SFCError |
AsSFBSource(
SFBSourceSmpPtr result
) Convert the input stream used internally into the instance of SFBSource class.
|
| Void |
Cancel( Void ) Cancel the registered callback functions.
|
| Void |
Close( Void ) Close the ZIPDecoder storage.
|
| SFBUnzipAStreamSmpConstRef |
GetSFBUnzipAStream( Void ) Get the instance of SFBUnzipAStream class used internally.
|
| SFCError |
GetStreamReader(
UInt32 size
, SFXStreamReaderPtr result
) GetStreamReader( SFXStreamReaderPtr result ) Get the input stream for reading data from ZIPDecoder.
|
| SFCError |
GetStreamWriter(
UInt32 size
, SFXStreamWriterPtr result
) GetStreamWriter( SFXStreamWriterPtr result ) [ This function cannot be used now. ]
|
| SFCError |
Open(
SFXStorageConstRef storage
) Open( SFBSourceSmpConstRef source ) Open( SFBAStreamSmpConstRef stream ) Register the storage in the ZIPDecoder.
|
| SFCError |
Read(
VoidPtr buffer
, UInt32Ptr size
) Read data from the ZIPDecorder storage without using the input stream..
|
| SFCError |
ScheduleRead(
CallbackSPP spp
, VoidPtr reference
) Register callback function and schedule the reading.
|
| SFCError |
ScheduleWrite(
CallbackSPP spp
, VoidPtr reference
) [ This function cannot be used now. ]
|
| SFCError |
Write(
VoidConstPtr buffer
, UInt32Ptr size
) [ This function cannot be used now. ]
|
| Types |
|---|
|
CallbackSPP
(inherits from SFXStorage)
The prototype of the callback function for the SFXStorage class.
|
[ public, explicit ] SFXZIPDecoder(Void);
SFBUnzipAStream interface is not reserved.
[ public, virtual ] virtual ~SFXZIPDecoder(Void);
The SFXZIPDecoder::Close function is called.
[ public, virtual, const ] SFCError AsSFBAStream( SFBAStreamSmpPtr result // pointer that stores the result );
[ public, virtual, const ] SFCError AsSFBSource( SFBSourceSmpPtr result // pointer that stores the result );
![]() |
Note |
|---|---|
| The SFBSourceUtil class is internally used in the SFXZIPDecoder::AsSFBSource function. | |
[ public, virtual ] Void Cancel(Void);
Cancel the callback functions registered in the instance of SFBUnzipAStream class used internally.
[ public ] Void Close(Void);
The register callback functions are canceled and the instance of SFBUnzipAStream class used internally is released.
[ public, const ] SFBUnzipAStreamSmpConstRef GetSFBUnzipAStream(Void);
[ public, virtual ] SFCError GetStreamReader( UInt32 size // buffer size SFXStreamReaderPtr result // pointer to the input stream );
[ public, virtual ] SFCError GetStreamReader( SFXStreamReaderPtr result // pointer to the input stream );
The buffer size of the input stream for reading data from ZIPDecorder can be specified. Use the SFXBinaryStreamReader, SFXAnsiStringStreamReader, or SFXWideStringStreamReader class for the input stream properly according to the type of data to read.
![]() |
Note |
|---|---|
| Before calling the SFXZIPDecoder::GetStreamReader function, it is necessary to register the source using the SFXZIPDecoder::Open function. | |
SFXZIPDecoder::Open | SFXZIPDecoder::GetStreamWriter | SFXBinaryStreamReader | SFXAnsiStringStreamReader | SFXWideStringStreamReader
[ public, virtual ] SFCError GetStreamWriter( UInt32 size // size SFXStreamWriterPtr result // pointer to the output stream );
[ public, virtual ] SFCError GetStreamWriter( SFXStreamWriterPtr result // pointer to the output stream );
SFERR_UNSUPPORTED is returned.
[ public ] SFCError Open( SFXStorageConstRef storage // storage of data to decompress );
[ public ] SFCError Open( SFBAStreamSmpConstRef stream // SFBAStream of data to decompress );
[ public ] SFCError Open( SFBSourceSmpConstRef source // SFBSource of data to decompress );
The instance of SFXStorage, SFBAStream or SFBSource class is set to the instance of SFBUnzipAStream class used internally.
[ public, virtual ] SFCError Read( VoidPtr buffer // buffer to read data from the ZIPDecorder storage UInt32Ptr size // buffer size );
Specify the buffer to read data from the ZIPDecorder storage.
Specify the size of buffer when calling SFXZIPDecoder::Read function. When the SFXZIPDecoder::Read function ends, the size of data that is actually read is stored.
![]() |
Note |
|---|---|
| Before calling the SFXZIPDecoder::Read function, it is necessary to register the source using the SFXZIPDecoder::Open function. | |
[ public, virtual ] SFCError ScheduleRead( CallbackSPP spp // callback function VoidPtr reference // data passed to callback function );
The SFXZIPDecoder::ScheduleRead function is used to register the callback function in which the SFXZIPDecoder::Read function is used to read data from the ZIPDecorder storage.
![]() |
Note |
|---|---|
| When the return value of SFXZIPDecoder::Read function is AEE_STREAM_WOULDBLOCK, register the callback function using the SFXZIPDecoder::ScheduleRead function, and then schedule the SFXZIPDecoder::Read function in the callback function again. | |
![]() |
Note |
|---|---|
| Before calling the SFXZIPDecoder::ScheduleRead function, it is necessary to register the source using the SFXZIPDecoder::Open function. | |
[ public, virtual ] SFCError ScheduleWrite( CallbackSPP spp // callback function VoidPtr reference // data passed to callback );
SFERR_UNSUPPORTED is returned.
[ public, virtual ] SFCError Write( VoidConstPtr buffer // data size UInt32Ptr size // data size );
SFERR_UNSUPPORTED is returned.
|
Copyright (C) 2002 - 2008 Sophia Cradle, Inc. All Rights Reserved. |
![]() ![]() ![]()
|