OLGzipOutStream Class Reference
[Streams]

A stream for zlib compression that writes data in the gzip format. More...

#import <ObjecitveLib/GzipOutStream.h>

Inheritance diagram for OLGzipOutStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - addExtraField:withBytes:count:
 Add an extra field.
(void) - close
 Close the stream.
(void) - freeStreamResources
 Free the stream's resources.
(void) - markModificationTime
 Set the modification time to now.
(void) - setComment:
 Set the comment of the gzip data.
(void) - setCommentText:
 Set the comment of the gzip data.
(void) - setOriginalFileName:includeModificationTime:
 Set the original file name of the data.
(void) - setOriginalFileNameText:includeModificationTime:
 Set the original file name of the data.
(unsigned) - writeBytes:count:
 Write a sequence of bytes to the stream.
Initializers and Deallocators
(id) - initWithOutStream:compressionLevel:bufferSize:writeZlibHeader:
 Initialize the compression stream.

Static Public Member Functions

(id) + streamWithOutStream:
 Create and return a new compression stream.
(id) + streamWithOutStream:compressionLevel:
 Create and return a new compression stream.

Protected Attributes

uint8_t * commentData
 The gzip comment.
uint32_t crc
 The CRC-32 value of the data.
OLDataOutStreamextraFields
 The extra fields.
uint8_t * fileNameData
 The original file name associated with the data.
BOOL headerWritten
 Whether the header has been written.
uint32_t modTime
 The modification time.
BOOL trailerWritten
 Whether the trailer has been written.

Detailed Description

A stream for zlib compression that writes data in the gzip format.

The data are written using the format described in RFC 1952, and can be read by the command-line tool gzip.

See also:
OLGzipInStream, OLZlibOutStream


Member Function Documentation

- (void) addExtraField: (const char *)  identifier
withBytes: (const uint8_t *)  buf
count: (unsigned)  num 

Add an extra field.

The bytes in buf are associated with identifier in the gzip data.

Note:
If this message is sent after the first bytes have been written to the stream, then adding an extra field will have no effect.
Precondition:
The length of the string identifier must be 2.
Exceptions:
OLInputOutputException if the length of identifier is not 2
Parameters:
identifier the identifier of the extra field
buf the bytes associated with the extra field
num the number of bytes in buffer

- (void) close  

Close the stream.

After receiving this message the stream will no longer be available for writing.

Exceptions:
OLInputOutputException if there is an error closing the stream

Reimplemented from OLZlibOutStream.

- (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 OLZlibOutStream.

- (id) initWithOutStream: (OLOutStream *)  underStream
compressionLevel: (int)  level
bufferSize: (unsigned)  size
writeZlibHeader: (BOOL)  zlibHeader 

Initialize the compression stream.

The the given compression level and buffer size. The given out stream underStream is the next lower stream in the stream stack. If zlibHeader is YES, then the zlib header will be written to the stream, otherwise it will not be written.

Attention:
You probably do not want to use this initializer. This initializer is overriden so that the argument zlibHeader will always be NO, as the gzip data format cannot be used with the zlib header.
Precondition:
The indicated compression level must be in the range [0,9].
Exceptions:
OLInvalidArgumentException if the compression level is not in the range [0,9]
OLInputOutputException if the stream cannot be created for deflation
Parameters:
underStream the next lower stream in the stack
level the compression level which must be in the range [0,9]
size the size of the internal buffer
zlibHeader it doesn't matter what you use, as it will be overridden
Returns:
a reference to this stream

Reimplemented from OLZlibOutStream.

- (void) markModificationTime  

Set the modification time to now.

This message should be sent if a modification time is desired, but there is no original file name in the data. The time is set to the current time.

Note:
If this message is sent after the first bytes have been written to the stream, then setting the modification time will have no effect.

- (void) setComment: (const char *)  comment  

Set the comment of the gzip data.

The string comment is set as the data's comment.

Note:
The data in comment must be encoded using the ISO 8859-1 encoding as described in RFC 1952.

If this message is sent after the first bytes have been written to the stream, then setting the comment will have no effect.

Parameters:
comment the gzip data's new comment

- (void) setCommentText: (OLText *)  comment  

Set the comment of the gzip data.

The string comment is set as the data's comment.

Note:
If this message is sent after the first bytes have been written to the stream, then setting the comment will have no effect.
Parameters:
comment the gzip data's new comment

- (void) setOriginalFileName: (const char *)  name
includeModificationTime: (BOOL)  mtime 

Set the original file name of the data.

To preserve the original file name when the data are extracted this message can be sent. Also, to set the modification time of the original file name, the arguement mtime can be YES, in which case the modification time of the gzip stream will be set to the modification time of the file at name.

Note:
The data in name must be encoded using the ISO 8859-1 encoding as described in RFC 1952.

If this message is sent after the first bytes have been written to the stream, then setting the file name will have no effect.

Precondition:
The file name should not contain any directories.
Parameters:
name the name of the original file
mtime YES if the modification time should be set, NO otherwise

- (void) setOriginalFileNameText: (OLText *)  name
includeModificationTime: (BOOL)  mtime 

Set the original file name of the data.

To preserve the original file name when the data are extracted this message can be sent. Also, to set the modification time of the original file name, the arguement mtime can be YES, in which case the modification time of the gzip stream will be set to the modification time of the file at name.

Note:
If this message is sent after the first bytes have been written to the stream, then setting the file name will have no effect.
Precondition:
The file name should not contain any directories.
Parameters:
name the name of the original file
mtime YES if the modification time should be set, NO otherwise

+ (id) streamWithOutStream: (OLOutStream *)  underStream  

Create and return a new compression stream.

The stream uses the default compression level and a buffer size of 1,024. The given out stream underStream is the next lower stream in the stream stack.

Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Exceptions:
OLInputOutputException if the stream cannot be created for deflation
Parameters:
underStream the next lower stream in the stack
Returns:
a reference to the newly created stream

Reimplemented from OLZlibOutStream.

+ (id) streamWithOutStream: (OLOutStream *)  underStream
compressionLevel: (int)  level 

Create and return a new compression stream.

The stream uses the given compression level and a buffer size of 1,024. The given out stream underStream is the next lower stream in the stream stack.

Precondition:
The indicated compression level must be in the range [0,9].
Note:
If OpenStep is present the returned object will be autoreleased before being returned.
Exceptions:
OLInvalidArgumentException if the compression level is not in the range [0,9]
OLInputOutputException if the stream cannot be created for deflation
Parameters:
underStream the next lower stream in the stack
level the compression level which must be in the range [0,9]
Returns:
a reference to the newly created stream

Reimplemented from OLZlibOutStream.

- (unsigned) writeBytes: (const uint8_t *)  bytes
count: (unsigned)  num 

Write a sequence of bytes to the stream.

Compress up to num bytes and return the number actually written.

Exceptions:
OLInputOutputException if there is an error writing to the stream
Parameters:
bytes the bytes to write
num the number of bytes to write
Returns:
the number of bytes written

Reimplemented from OLZlibOutStream.


Member Data Documentation

- (uint8_t*) commentData [protected]

The gzip comment.

- (uint32_t) crc [protected]

The CRC-32 value of the data.

- (OLDataOutStream*) extraFields [protected]

The extra fields.

- (uint8_t*) fileNameData [protected]

The original file name associated with the data.

- (BOOL) headerWritten [protected]

Whether the header has been written.

- (uint32_t) modTime [protected]

The modification time.

- (BOOL) trailerWritten [protected]

Whether the trailer has been written.


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