OLZlibOutStream Class Reference
[Streams]

A stream for zlib compression. More...

#import <ObjectiveLib/ZlibOutStream.h>

Inheritance diagram for OLZlibOutStream:

Inheritance graph
[legend]
List of all members.

Public Member Functions

(void) - close
 Close the stream.
(void) - freeStreamResources
 Free the stream's resources.
(unsigned) - writeBytes:count:
 Write a sequence of bytes to the stream.
Initializers and Deallocators
(id) - initWithOutStream:
 Initialize the compression stream.
(id) - initWithOutStream:compressionLevel:
 Initialize the compression stream.
(id) - initWithOutStream:compressionLevel:bufferSize:
 Initialize the compression stream.
(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 * buffer
 The buffer required by zlib.
unsigned bufferSize
 The size of the zlib buffer.
BOOL isFinished
 Indicator of whether the compression has finished yet.
z_stream_s * zstream
 The opaque data type used by zlib to represent the stream.

Detailed Description

A stream for zlib compression.

This is a concrete layered stream that compresses all data written using the library zlib.

See also:
OLZlibInStream


Member Function Documentation

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

Reimplemented in OLGzipOutStream.

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

Reimplemented in OLGzipOutStream.

- (id) initWithOutStream: (OLOutStream *)  underStream  

Initialize the 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.

Exceptions:
OLInputOutputException if the stream cannot be created for deflation
Parameters:
underStream the next lower stream in the stack
Returns:
a reference to this stream

Reimplemented from OLLayeredOutStream.

- (id) initWithOutStream: (OLOutStream *)  underStream
compressionLevel: (int)  level 

Initialize the 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].
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 this stream

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

Initialize the compression stream.

The stream uses the given compression level and buffer size. 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].
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
Returns:
a reference to this stream

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

Initialize the compression stream.

The stream uses 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 exists so that subclasses will have maximum control over how the zstream is created. Do not use this initializer unless you know what you are doing.
Precondition:
The indicated compression level must be in the range [0,9].
Exceptions:
NSInvalidArgumentException 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 should be YES if the zlib header should be written to the stream, otherwise NO
Returns:
a reference to this stream

Reimplemented in OLGzipOutStream.

+ (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 in OLGzipOutStream.

+ (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 in OLGzipOutStream.

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

Reimplemented in OLGzipOutStream.


Member Data Documentation

- (uint8_t*) buffer [protected]

The buffer required by zlib.

- (unsigned) bufferSize [protected]

The size of the zlib buffer.

- (BOOL) isFinished [protected]

Indicator of whether the compression has finished yet.

- (struct z_stream_s*) zstream [protected]

The opaque data type used by zlib to represent the stream.


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