License:
BSD style: see license.txt

Version:
Initial release: July 2007

author:
Daniel Keep

History:
Added support for "window bits", needed for Zip support.

  • class ZlibInput : tango.io.device.Conduit.InputFilter;
  • This input filter can be used to perform decompression of zlib streams.

  • this(InputStream stream);
    this(InputStream stream, int windowBits);
  • Constructs a new zlib decompression filter. You need to pass in the stream that the decompression filter will read from. If you are using this filter with a conduit, the idiom to use is:

            auto input = new ZlibInput(myConduit.input)
    ; input.read(myContent);


    The optional windowBits parameter is the base two logarithm of the window size, and should be in the range 8-15, defaulting to 15 if not specified. Additionally, the windowBits parameter may be negative to indicate that zlib should omit the standard zlib header and trailer, with the window size being -windowBits.

  • uint read (void[] dst);
  • Decompresses data from the underlying conduit into a target array.

    Returns the number of bytes stored into dst, which may be less than requested.



  • InputStream clear ();
  • Clear any buffered content. No-op.

  • class ZlibOutput : tango.io.device.Conduit.OutputFilter;
  • This output filter can be used to perform compression of data into a zlib stream.

  • enum Level ;
  • This enumeration represents several pre-defined compression levels.

    None instructs zlib to perform no compression whatsoever, and simply store the data stream. Note that this actually expands the stream slightly to accommodate the zlib stream metadata.

    Fast instructs zlib to perform a minimal amount of compression, Best indicates that you want the maximum level of compression and Normal (the default level) is a compromise between the two. The exact compression level Normal represents is determined by the underlying zlib library, but is typically level 6.

    Any integer between -1 and 9 inclusive may be used as a level, although the symbols in this enumeration should suffice for most use-cases.



  • this(OutputStream stream, Level level = (Level).Normal);
    this(OutputStream stream, Level level, int windowBits);
  • Constructs a new zlib compression filter. You need to pass in the stream that the compression filter will write to. If you are using this filter with a conduit, the idiom to use is:

            auto output = new ZlibOutput(myConduit.output);
            output.write(myContent);
    
    The optional windowBits parameter is the base two logarithm of the window size, and should be in the range 8-15, defaulting to 15 if not specified. Additionally, the windowBits parameter may be negative to indicate that zlib should omit the standard zlib header and trailer, with the window size being -windowBits.



  • uint write (void[] src);
  • Compresses the given data to the underlying conduit.

    Returns the number of bytes from src that were compressed; write should always consume all data provided to it, although it may not be immediately written to the underlying output stream.



  • uint written ();
  • This read-only property returns the number of compressed bytes that have been written to the underlying stream. Following a call to either close or commit, this will contain the total compressed size of the input data stream.

  • void close ();
  • commit the output

  • void commit ();
  • Purge any buffered content. Calling this will implicitly end the zlib stream, so it should not be called until you are finished compressing data. Any calls to either write or commit after a compression filter has been committed will throw an exception.

  • class ZlibClosedException : tango.core.Exception.IOException;
  • This exception is thrown if you attempt to perform a read, write or flush operation on a closed zlib filter stream. This can occur if the input stream has finished, or an output stream was flushed.

  • class ZlibException : tango.core.Exception.IOException;
  • This exception is thrown when an error occurs in the underlying zlib library. Where possible, it will indicate both the name of the error, and any textural message zlib has provided.

    )
    Copyright (C) 2007 Daniel Keep. All rights reserved. :: page rendered by CandyDoc