PrevNextUpHome SophiaFramework UNIVERSE 5.3
SFBUnzipAStream
Wrapper Class for the IUnzipAStream interface.
#include <SFBUnzipAStream.h.hpp>
class SFBUnzipAStream : public SFBAStream;
SFMTYPEDEFWRAPPER(SFBUnzipAStream)

Inheritance diagram

 Inheritance diagram of SFBUnzipAStreamClass

Version

BREW 2.0 BREW 2.1 BREW 3.1 BREW 4.0
O O O O

Reference

BREW API IUnzipAStream

Member

Public Functions
static
SFBUnzipAStreamSmp
NewInstance( SFCErrorPtr exception = null )
Create a new SFBUnzipAStream instance.
static
SFBUnzipAStreamSmp
NewInstance( AEECLSID id , SFCErrorPtr exception = null )
Create a new SFBUnzipAStream instance.
Void SetStream( SFBAStreamSmpConstRef stream )
Set an input compressed stream of gzip.
SFCError SetStream( SFXStorageConstRef storage )
Set an input compressed stream of gzip.
Void Cancel( Void ) (inherits from SFBAStream)
Cancel a callback that was scheduled with SFBAStream::Readable().
SInt32 Read( VoidPtr buffer , UInt32 count ) (inherits from SFBAStream)
Attempt to read data from a stream, and returns the number of bytes read. If no data is available for reading, it returns the value AEE_STREAM_WOULDBLOCK.
SInt32 Read( SFXBufferPtr buffer ) (inherits from SFBAStream)
Attempt to read data from a stream, and returns the number of bytes read. If no data is available for reading, it returns the value AEE_STREAM_WOULDBLOCK.
Void Readable( PFNNOTIFY notify , VoidPtr data = null ) (inherits from SFBAStream)
Register a callback that checks whether data is available to be read. It is called when the SFBAStream::Read() returns AEE_STREAM_WOULDBLOCK.
Protected Functions
static
SFBBaseSmp
FactoryByCreate( AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface.
static
SFBBaseSmp
FactoryByQuery( SFBQuerySmpConstRef query , AEECLSID id , SFCErrorPtr exception = null ) (inherits from SFBBase)
Create the instance for the specified ClassID's interface using the SFBQuery instance.

SFBUnzipAStream::NewInstance
Create a new SFBUnzipAStream instance.
[ public, static ]
SFBUnzipAStreamSmp NewInstance(
    SFCErrorPtr exception = null   // Error
);
[ public, static ]
SFBUnzipAStreamSmp NewInstance(
    AEECLSID id                    // Class ID
    SFCErrorPtr exception = null   // Error
);

SFBUnzipAStream::SetStream
Set an input compressed stream of gzip.
[ public ]
Void SetStream(
    SFBAStreamSmpConstRef stream   // gzip compressed stream
);
[ public ]
SFCError SetStream(
    SFXStorageConstRef storage   // gzip compressed storage
);

Return value

  • If succeeds: SFERR_NO_ERROR
  • storage is closed: SFERR_INVALID_STATE
  • Argument is null: SFERR_INVALID_PARAM

Example

Show log when compress or decompress the text data with gzip

// gzip file name
#define MY_STRINGFILE_NAME  "MyString.txt.gz"

SFBFileMgrSmp           filemgr;
SFBFileSmp              file;
SFBUnzipAStreamSmp      unzip;
FileInfo                info;
ACharPtr                buffer;

// Create the SFBFileMgr instance
filemgr = SFBFileMgr::NewInstance();

// Get the file size
filemgr->GetInfo(MY_STRINGFILE_NAME, &info);

// Open the file
file = filemgr->OpenFile(MY_STRINGFILE_NAME, _OFM_READ);

// Create the SFBUnzipStream instance
unzip = SFBUnzipAStream::NewInstance();

// set the gzip compressed stream
unzip->SetStream(file);

// Create the data operation area
buffer = (ACharPtr)MALLOC(info.dwSize);

// decompress the gzip compressed text data
unzip->Read(buffer, info.dwSize);

// show the text in log
TRACE("*** text: %s ***", buffer);

// release the buffer
FREE(buffer);

Reference

BREW API IUNZIPASTREAM_SetStream