OLGzipInStream Class Reference
[Streams]

A stream for zlib decompression that reads data in gzip format. More...

#import <ObjectiveLib/GzipInStream.h>

Inheritance diagram for OLGzipInStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(const char *) - comment
 Return the comment in the gzip data.
(const uint8_t *) - extraField:count:
 Return an extra field.
(void) - freeStreamResources
 Free the stream's resources.
(uint32_t) - modificationTime
 Return the modification time embedded in the data.
(const char *) - originalFileName
 Return the original file name associated with the data.
(unsigned) - readBytes:count:
 Read a sequence of bytes from the stream.
Initializers and Deallocators
(id) - initWithInStream:bufferSize:readZlibHeader:
 Initialize the stream.

Static Public Member Functions

(id) + streamWithInStream:
 Create and return a newly created stream.

Protected Attributes

char * comment
 The gzip comment.
uint32_t crc
 The CRC-32 of the data.
BOOL endOfStream
 Whether we have reached the end of the stream.
OLMapextraFields
 The extra fields.
char * fileName
 The original file name.
uint32_t modTime
 The modification time of the original file.

Detailed Description

A stream for zlib decompression that reads data in gzip format.

The data are read as if they were written with the format specified in RFC 1952. The command-line tool gzip writes data in this format, so this class can be used to read files written by gzip.

See also:
OLGzipOutStream, OLZlibInStream


Member Function Documentation

- (const char*) comment  

Return the comment in the gzip data.

If the data contains no comment, then nil is returned.

Returns:
the gzip comment or nil if there is no comment

- (const uint8_t*) extraField: (const char *)  identifier
count: (unsigned *)  countOut 

Return an extra field.

Extra fields are identified by a two-letter identifier. If the requested extra field does not exist in the gzip data, then NULL is returned.

Exceptions:
OLInputOutputException if the length of identifier is not equal to 2
Parameters:
identifier the identifier of the extra field
countOut a pointer to a unsigned int that will contain the length of the extra field's data on exit, or zero if no extra field with the given identifier can be found
Returns:
the data of the extra field or nil if the extra field does not exist in the data

- (void) freeStreamResources  

Free the stream's resources.

This secondary freeing method is necessary to allow the reference count to be properly manipulated from within the normal free (OLReferenceCountedStream) method.

Note:
All sublcasses that allocate resources must implement this method to free those resources and call [super freeStreamResources].

Reimplemented from OLZlibInStream.

- (id) initWithInStream: (OLInStream *)  underStream
bufferSize: (unsigned)  size
readZlibHeader: (BOOL)  zlibHeader 

Initialize the stream.

The stream is created with the given buffer size. The given stream underStream will become the next layer down in the stack of streams. If zlibHeader is YES, then the stream will attempt to read the zlib header.

Attention:
You probably do not want to use this initializer. This initializer is overriden to ignore the given value of zlibHeader and always set it to NO. The zlib header cannot be used when dealing with the gzip data format.
Exceptions:
OLInputOutputException if the stream cannot be created for inflation
Parameters:
underStream the stream from which to read data
size the buffer size
zlibHeader it doesn't matter what you use for this, as it will be overriden
Returns:
a reference to this stream

Reimplemented from OLZlibInStream.

- (uint32_t) modificationTime  

Return the modification time embedded in the data.

This is expressed in Unix format, which is the number of seconds since 00:00:00 GMT, Jan. 1, 1970. If no modification time was available when the data were created, then 0 is returned.

Returns:
the modification time or zero if there is no modification time available

- (const char*) originalFileName  

Return the original file name associated with the data.

If no file name was recorded in the data, then nil is returned.

Returns:
the original file name or nil if no file name is present in the data

- (unsigned) readBytes: (uint8_t *)  dest
count: (unsigned)  max 

Read a sequence of bytes from the stream.

Bytes are decompressed up to the value of max and the number decompressed is returned. If no more bytes are available from the stream, then UINT_MAX is returned.

Exceptions:
OLInputOutputException if there is an error reading from the stream
Parameters:
dest the address to which the bytes should be read
max the maximum number bytes that should be read
Returns:
the number of bytes read or UINT_MAX if no bytes could be read

Reimplemented from OLZlibInStream.

+ (id) streamWithInStream: (OLInStream *)  underStream  

Create and return a newly created stream.

The stream is created with a buffer size of 1,024. The given stream underStream will become the next layer down in the stack of streams.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Exceptions:
OLInputOutputException if the stream cannot be created for inflation
Parameters:
underStream the stream from which to read data
Returns:
a reference to a newly created stream

Reimplemented from OLZlibInStream.


Member Data Documentation

- (char*) comment [protected]

The gzip comment.

- (uint32_t) crc [protected]

The CRC-32 of the data.

- (BOOL) endOfStream [protected]

Whether we have reached the end of the stream.

- (OLMap*) extraFields [protected]

The extra fields.

- (char*) fileName [protected]

The original file name.

- (uint32_t) modTime [protected]

The modification time of the original file.


The documentation for this class was generated from the following file:
ObjectiveLibGenerated Sun Apr 22 15:18:33 2007, © 2004-2007 Will Mason
SourceForge.net Logo