SophiaFramework UNIVERSE 5.3 |
#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;
The SFXZIPDecoder class is used to decompress the DEFLATE compressed data by gzip to be read from the SFBSource or SFBAStream instance or the storage such as SFXFile or SFXTCPSocket.
Limitation | |
---|---|
Data can be read from the SFXZIPDecoder storage, but it cannot be written into this storage. The function to move the read pointer is not supported. |
How to use the SFXZIPDecoder class
Example 852. How to use the SFXZIPDecoder class
// _decoder is declared as class member variable since used the callback function class MyClass { private: SFXFile _file; // input file SFXZIPDecoder _decoder; // gzip decoder SFXAnsiStringStreamReader _reader; // input stream SFXAnsiString _unzipString; // decompressed string public: Void Start(Void); // callback function XALLBACK_DECLARE_SFXANSISTRINGSTREAMREADER(OnFetch) }; Void MyClass::Start(Void) { SFCError error; // error value // open the file in the read only mode if ((error = _file.OpenReadOnly(SFXPath("/testdata.tar.gz"))) == SFERR_NO_ERROR) { // set the file storage to the gzip decoder if ((error = _decoder.Open(_file)) == SFERR_NO_ERROR) { // get the input stream from the gzip decoder // * the stream buffer is variable since the size argument is not specified if ((error = _decoder.GetStreamReader(&_reader)) == SFERR_NO_ERROR) { // perform fetch: read the gzipped data from the gzip decoder into the stream buffer actually // *1. the fetch result will be notified to the OnFetch function // *2. the stream buffer will be expanded automatically depending on the size of data to be received if ((error = _reader.Fetch(XALLBACK_INTERNAL(OnFetch))) != SFERR_NO_ERROR) { // if an error occurs _reader.Release(); } } if (error != SFERR_NO_ERROR) { // if an error occurs _decoder.Close(); } } if (error != SFERR_NO_ERROR) { // if an error occurs _file.Close(); } } } // callback function notified of the fetch result XALLBACK_IMPLEMENT_SFXANSISTRINGSTREAMREADER(MyClass, OnFetch, error) { if (error == SFERR_NO_ERROR) { // if no error occurs in fetch // read data from the stream buffer into the _unzipString variable(at this time, data has already been decompressed) if ((error = _reader.ReadSFXAnsiString(&_unzipString)) == SFERR_NO_ERROR) { // display the _unzipString variable on BREW Output Window TRACE("%s", _unzipString.GetCString()); _reader.Release(); } } // termination _decoder.Close(); _file.Close(); }
Constructor/Destructor |
---|
SFXZIPDecoder( Void ) Constructor of the SFXZIPDecoder class.
|
~SFXZIPDecoder( Void ) Destructor of the SFXZIPDecoder class.
|
Public Functions | |
---|---|
SFCError |
AsSFBAStream(
SFBAStreamSmpPtr result
) Convert the input stream used internally by this SFXZIPDecoder storage into the SFBAStream instance.
|
SFCError |
AsSFBSource(
SFBSourceSmpPtr result
) Convert the input stream used internally by this SFXZIPDecoder storage into the SFBSource instance.
|
Void |
Cancel( Void ) Cancel the registered callback functions.
|
Void |
Close( Void ) Close this ZIPDecoder storage.
|
SFBUnzipAStreamSmpConstRef |
GetSFBUnzipAStream( Void ) Get the SFBUnzipAStream instance managed internally by this SFXZIPDecoder storage.
|
SFCError |
GetStreamReader(
UInt32 size
, SFXStreamReaderPtr result
) Get the input stream for reading data from this SFXZIPDecoder storage.
|
SFCError |
GetStreamReader(
SFXStreamReaderPtr result
) Get the input stream for reading data from this SFXZIPDecoder storage.
|
SFCError |
GetStreamWriter(
UInt32 size
, SFXStreamWriterPtr result
) [This function cannot be used now.]
|
SFCError |
GetStreamWriter(
SFXStreamWriterPtr result
) [This function cannot be used now.]
|
SFCError |
Open(
SFXStorageConstRef storage
) Set the specified compressed stream, storage or source to this SFXZIPDecoder storage.
|
SFCError |
Open(
SFBAStreamSmpConstRef stream
) Set the specified compressed stream, storage or source to this SFXZIPDecoder storage.
|
SFCError |
Open(
SFBSourceSmpConstRef source
) Set the specified compressed stream, storage or source to this SFXZIPDecoder storage.
|
SFCError |
Read(
VoidPtr buffer
, UInt32Ptr size
) Read data from this ZIPDecoder without input stream.
|
SFCError |
ScheduleRead(
CallbackSPP spp
, VoidPtr reference
) Schedule to read data from this ZIPDecoder without input stream.
|
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)
Type of the callback function for the Storage class.
|
[ public, explicit ] SFXZIPDecoder(Void);
This constructor does nothing.
[ public, virtual ] virtual ~SFXZIPDecoder(Void);
This destructor calls the SFXZIPDecoder::Close function.
Note | |
---|---|
Registered callback functions will be canceled. |
[ public, virtual, const ] SFCError AsSFBAStream( SFBAStreamSmpPtr result // pointer to the SFBAStream instance );
This function converts the input stream used internally by this SFXZIPDecoder storage into the SFBAStream instance.
As a result, a pointer to the SFBAStream instance will be returned into the result argument.
Note | |
---|---|
The contents of the SFXZIPDecoder storage can be handled as the SFBAStream instance. |
[ public, virtual, const ] SFCError AsSFBSource( SFBSourceSmpPtr result // pointer to the SFBSource instance );
This function converts the input stream used internally by this SFXZIPDecoder storage into the SFBSource instance.
As a result, a pointer to the SFBSource instance will be returned into the result argument.
Note | |
---|---|
This function internally calls the BREW API ISOURCEUTIL_SourceFromAStream function. |
Note | |
---|---|
The contents of the SFXZIPDecoder storage can be handled as the SFBSource instance. |
SFXZIPDecoder::Open | SFBUnzipAStream | SFBSource | SFBSourceUtil | BREW API ISOURCEUTIL_SourceFromAStream
[ public, virtual ] Void Cancel(Void);
This function cancels scheduling with the SFXZIPDecoder::ScheduleRead function.
The registered callback functions will be canceled.
Note | |
---|---|
This function is called in the SFXZIPDecoder::Close function. |
[ public ] Void Close(Void);
This function closes (or finishes) this ZIPDecoder storage.
Concretely, this function calls the SFXZIPDecoder::Cancel function and releases the SFBUnzipAStream instance that this ZIPDecoder storage internally manages.
Note | |
---|---|
The registered callback functions will be canceled. |
Note | |
---|---|
This function is called in the SFXZIPDecoder::~SFXZIPDecoder destructor. |
Tip | |
---|---|
When suspending, resources should be released by calling this function. |
SFXZIPDecoder::Cancel | SFXZIPDecoder::~SFXZIPDecoder | SFXZIPDecoder::Open | SFBUnzipAStream
[ public, const ] SFBUnzipAStreamSmpConstRef GetSFBUnzipAStream(Void);
SFBUnzipAStream instance managed internally by this SFXZIPDecoder storage.
This function gets the SFBUnzipAStream instance managed internally by this SFXZIPDecoder storage.
[ 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 );
This function gets the input stream for reading data from this SFXZIPDecoder storage.
If the size argument is specified, the buffer size of the input stream will be fixed with the specified value. Otherwise, the buffer size will be variable and the SFXElasticStreamReader class will be used internally.
Tip | |
---|---|
You have to use the SFXBinaryStreamReader, SFXAnsiStringStreamReader, or SFXWideStringStreamReader class for the input stream properly depending on the type of data to be read. |
Caution | |
---|---|
Before calling this function, you have to register the source into this SFXZIPDecoder storage with the SFXZIPDecoder::Open function. |
SFXZIPDecoder::Open | SFXBinaryStreamReader | SFXAnsiStringStreamReader | SFXWideStringStreamReader | Stream Buffer
[ 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
[This function cannot be used now.]
[ public ] SFCError Open( SFXStorageConstRef storage // storage to be decoded );
[ public ] SFCError Open( SFBAStreamSmpConstRef stream // stream to be decoded );
[ public ] SFCError Open( SFBSourceSmpConstRef source // source to be decoded );
This function sets the specified compressed stream, storage or source as the source for the SFBUnzipAStream instance that this SFXZIPDecoder storage manages internally.
The SFXStorage, SFBAStream or SFBSource instance can be specified in the argument.
After this function is executed, the gzipped data will be read and decoded at the same time by using the input stream obtained with the SFXZIPDecoder::GetStreamReader function or by calling the SFXZIPDecoder::Read function.
Note | |
---|---|
This function internally calls the SFBUnzipAStream::SetStream function to set the specified compressed stream, storage or source as the source for the SFBUnzipAStream instance that this SFXZIPDecoder storage manages internally. At this time, the storage and the source internally will be converted into the stream with the AsSFBAStream function and the SFBSourceUtil::AStreamFromSource function respectively. |
SFBUnzipAStream::SetStream | SFXZIPDecoder::Close | SFXZIPDecoder::GetStreamReader | SFXZIPDecoder::Read | SFXStorage | SFBAStream | SFBSource | SFBUnzipAStream | BREW API IUNZIPASTREAM_SetStream
[ public, virtual ] SFCError Read( VoidPtr buffer // buffer to read data UInt32Ptr size // before this function is called: size of the data to read; just after this function is returned: size of the data to be read actually );
Specify the buffer to read data.
Before calling this function, specify the buffer size to read data. Just after this function is returned, the size of data to be read actually will be stored into this argument.
This function reads data from this ZIPDecoder without input stream.
When all data has been read from this ZIPDecoder, this function will return SFERR_NO_ERROR and 0 will be returned into the area that the size argument points to.
* If this function returns AEE_STREAM_WOULDBLOCK, it will be necessary to register a callback function with the SFXZIPDecoder::ScheduleRead function where data will be read with this function.
Note | |
---|---|
This function internally calls the SFBAStream::Read function. |
Prerequisite | |
---|---|
This ZIPDecoder needs to be opened (or set) with the SFXZIPDecoder::Open function before this function is called. |
SFXZIPDecoder::Open | SFXZIPDecoder::ScheduleRead | SFBAStream::Read | BREW API IUNZIPASTREAM_Read
[ public, virtual ] SFCError ScheduleRead( CallbackSPP spp // callback function VoidPtr reference // data passed to callback function );
This function schedules to read data from this ZIPDecoder without input stream.
Concretely, this function registers the callback function that will read data with the SFXZIPDecoder::Read function. The registered callback function will be called by BREW AEE when it is possible to read data.
The status of this ZIPDecoder is "under scheduling to read data" until the callback function is called. And after the callback function is called, it will become the status before calling this function, i.e., "this ZIPDecoder is opened".
If you call the SFXZIPDecoder::Cancel function before the callback function is called, reading data will be canceled and the status will be returned to the status before calling this function, i.e., "this ZIPDecoder is opened".
*1. If the SFXZIPDecoder::Read function returns AEE_STREAM_WOULDBLOCK, it will be necessary to register a callback function with this function where data will be read with the SFXZIPDecoder::Read function.
*2. If this function returns the value other than SFERR_NO_ERROR, the specified callback function will not be called.
Note | |
---|---|
This function internally calls the SFBAStream::Readable function. |
Prerequisite | |
---|---|
This ZIPDecoder needs to be opened (or set) with the SFXZIPDecoder::Open function before this function is called. And if this ZIPDecoder has been already scheduled to read data, the SFERR_INVALID_STATE error will be returned. |
SFXZIPDecoder::Read | SFXZIPDecoder::Open | SFXZIPDecoder::Cancel | SFBAStream::Readable | SFXStorage::CallbackSPP | BREW API IUNZIPASTREAM_Readable
[ public, virtual ] SFCError ScheduleWrite( CallbackSPP spp // callback function VoidPtr reference // data passed to callback );
SFERR_UNSUPPORTED
[This function cannot be used now.]
[ public, virtual ] SFCError Write( VoidConstPtr buffer // data size UInt32Ptr size // data size );
SFERR_UNSUPPORTED
[This function cannot be used now.]
Copyright(c) 2002 - 2024 Sophia Cradle Incorporated All Rights Reserved. |