jens@13: // jens@13: // GTMNSData+zlib.h jens@13: // jens@13: // Copyright 2007-2008 Google Inc. jens@13: // jens@13: // Licensed under the Apache License, Version 2.0 (the "License"); you may not jens@13: // use this file except in compliance with the License. You may obtain a copy jens@13: // of the License at jens@13: // jens@13: // http://www.apache.org/licenses/LICENSE-2.0 jens@13: // jens@13: // Unless required by applicable law or agreed to in writing, software jens@13: // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT jens@13: // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the jens@13: // License for the specific language governing permissions and limitations under jens@13: // the License. jens@13: // jens@13: jens@13: #import jens@13: #import "GTMDefines.h" jens@13: jens@13: /// Helpers for dealing w/ zlib inflate/deflate calls. jens@13: @interface NSData (GTMZLibAdditions) jens@13: jens@13: /// Return an autoreleased NSData w/ the result of gzipping the bytes. jens@13: // jens@13: // Uses the default compression level. jens@13: + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes jens@13: length:(NSUInteger)length; jens@13: jens@13: /// Return an autoreleased NSData w/ the result of gzipping the payload of |data|. jens@13: // jens@13: // Uses the default compression level. jens@13: + (NSData *)gtm_dataByGzippingData:(NSData *)data; jens@13: jens@13: /// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level. jens@13: // jens@13: // |level| can be 1-9, any other values will be clipped to that range. jens@13: + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes jens@13: length:(NSUInteger)length jens@13: compressionLevel:(int)level; jens@13: jens@13: /// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level. jens@13: + (NSData *)gtm_dataByGzippingData:(NSData *)data jens@13: compressionLevel:(int)level; jens@13: jens@13: // NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one jens@13: // you really want to create. (the inflate api will handle either) jens@13: jens@13: /// Return an autoreleased NSData w/ the result of deflating the bytes. jens@13: // jens@13: // Uses the default compression level. jens@13: + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes jens@13: length:(NSUInteger)length; jens@13: jens@13: /// Return an autoreleased NSData w/ the result of deflating the payload of |data|. jens@13: // jens@13: // Uses the default compression level. jens@13: + (NSData *)gtm_dataByDeflatingData:(NSData *)data; jens@13: jens@13: /// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level. jens@13: // jens@13: // |level| can be 1-9, any other values will be clipped to that range. jens@13: + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes jens@13: length:(NSUInteger)length jens@13: compressionLevel:(int)level; jens@13: jens@13: /// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level. jens@13: + (NSData *)gtm_dataByDeflatingData:(NSData *)data jens@13: compressionLevel:(int)level; jens@13: jens@13: jens@13: /// Return an autoreleased NSData w/ the result of decompressing the bytes. jens@13: // jens@13: // The bytes to decompress can be zlib or gzip payloads. jens@13: + (NSData *)gtm_dataByInflatingBytes:(const void *)bytes jens@13: length:(NSUInteger)length; jens@13: jens@13: /// Return an autoreleased NSData w/ the result of decompressing the payload of |data|. jens@13: // jens@13: // The data to decompress can be zlib or gzip payloads. jens@13: + (NSData *)gtm_dataByInflatingData:(NSData *)data; jens@13: jens@13: @end