From ba4b222bea6694d654ab6b89bcd452dd5a67e42f Mon Sep 17 00:00:00 2001 From: "gtm.daemon" Date: Mon, 27 Feb 2012 22:30:11 +0000 Subject: [Author: thomasvl] Add support for raw inflate/deflate without a header. R=dmaclach DELTA=416 (327 added, 69 deleted, 20 changed) --- Foundation/GTMNSData+zlib.h | 50 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) (limited to 'Foundation/GTMNSData+zlib.h') diff --git a/Foundation/GTMNSData+zlib.h b/Foundation/GTMNSData+zlib.h index 3ea7db8..08fbb9a 100644 --- a/Foundation/GTMNSData+zlib.h +++ b/Foundation/GTMNSData+zlib.h @@ -26,6 +26,8 @@ // return nil when given such data. To handle data of that size you really // should be streaming it rather then doing it all in memory. +#pragma mark Gzip Compression + /// Return an autoreleased NSData w/ the result of gzipping the bytes. // // Uses the default compression level. @@ -48,6 +50,8 @@ + (NSData *)gtm_dataByGzippingData:(NSData *)data compressionLevel:(int)level; +#pragma mark Zlib "Stream" Compression + // NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one // you really want to create. (the inflate api will handle either) @@ -73,6 +77,7 @@ + (NSData *)gtm_dataByDeflatingData:(NSData *)data compressionLevel:(int)level; +#pragma mark Uncompress of Gzip or Zlib /// Return an autoreleased NSData w/ the result of decompressing the bytes. // @@ -85,4 +90,49 @@ // The data to decompress can be zlib or gzip payloads. + (NSData *)gtm_dataByInflatingData:(NSData *)data; + +#pragma mark "Raw" Compression Support + +// NOTE: raw deflate is *NOT* gzip or deflate. it does not include a header +// of any form and should only be used within streams here an external crc/etc. +// is done to validate the data. The RawInflate apis can be used on data +// processed like this. + +/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes. +// +// Uses the default compression level. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length; + +/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data|. +// +// Uses the default compression level. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data; + +/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes using |level| compression level. +// +// |level| can be 1-9, any other values will be clipped to that range. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes + length:(NSUInteger)length + compressionLevel:(int)level; + +/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data| using |level| compression level. +// *No* header is added to the resulting data. ++ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data + compressionLevel:(int)level; + +/// Return an autoreleased NSData w/ the result of *raw* decompressing the bytes. +// +// The data to decompress, it should *not* have any header (zlib nor gzip). ++ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes + length:(NSUInteger)length; + +/// Return an autoreleased NSData w/ the result of *raw* decompressing the payload of |data|. +// +// The data to decompress, it should *not* have any header (zlib nor gzip). ++ (NSData *)gtm_dataByRawInflatingData:(NSData *)data; + @end -- cgit v1.2.3