PageRenderTime 25ms CodeModel.GetById 13ms app.highlight 9ms RepoModel.GetById 1ms app.codeStats 0ms

/core/externals/google-toolbox-for-mac/Foundation/GTMNSData+zlib.h

http://macfuse.googlecode.com/
C++ Header | 138 lines | 38 code | 27 blank | 73 comment | 0 complexity | b424435a755f4be6becd085a3441de9b MD5 | raw file
  1//
  2//  GTMNSData+zlib.h
  3//
  4//  Copyright 2007-2008 Google Inc.
  5//
  6//  Licensed under the Apache License, Version 2.0 (the "License"); you may not
  7//  use this file except in compliance with the License.  You may obtain a copy
  8//  of the License at
  9//
 10//  http://www.apache.org/licenses/LICENSE-2.0
 11//
 12//  Unless required by applicable law or agreed to in writing, software
 13//  distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 14//  WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
 15//  License for the specific language governing permissions and limitations under
 16//  the License.
 17//
 18
 19#import <Foundation/Foundation.h>
 20#import "GTMDefines.h"
 21
 22/// Helpers for dealing w/ zlib inflate/deflate calls.
 23@interface NSData (GTMZLibAdditions)
 24
 25// NOTE: For 64bit, none of these apis handle input sizes >32bits, they will
 26// return nil when given such data.  To handle data of that size you really
 27// should be streaming it rather then doing it all in memory.
 28
 29#pragma mark Gzip Compression
 30
 31/// Return an autoreleased NSData w/ the result of gzipping the bytes.
 32//
 33//  Uses the default compression level.
 34+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
 35                             length:(NSUInteger)length;
 36
 37/// Return an autoreleased NSData w/ the result of gzipping the payload of |data|.
 38//
 39//  Uses the default compression level.
 40+ (NSData *)gtm_dataByGzippingData:(NSData *)data;
 41
 42/// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level.
 43//
 44// |level| can be 1-9, any other values will be clipped to that range.
 45+ (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
 46                             length:(NSUInteger)length
 47                   compressionLevel:(int)level;
 48
 49/// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level.
 50+ (NSData *)gtm_dataByGzippingData:(NSData *)data
 51                  compressionLevel:(int)level;
 52
 53#pragma mark Zlib "Stream" Compression
 54
 55// NOTE: deflate is *NOT* gzip.  deflate is a "zlib" stream.  pick which one
 56// you really want to create.  (the inflate api will handle either)
 57
 58/// Return an autoreleased NSData w/ the result of deflating the bytes.
 59//
 60//  Uses the default compression level.
 61+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
 62                              length:(NSUInteger)length;
 63
 64/// Return an autoreleased NSData w/ the result of deflating the payload of |data|.
 65//
 66//  Uses the default compression level.
 67+ (NSData *)gtm_dataByDeflatingData:(NSData *)data;
 68
 69/// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level.
 70//
 71// |level| can be 1-9, any other values will be clipped to that range.
 72+ (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
 73                              length:(NSUInteger)length
 74                    compressionLevel:(int)level;
 75
 76/// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level.
 77+ (NSData *)gtm_dataByDeflatingData:(NSData *)data
 78                   compressionLevel:(int)level;
 79
 80#pragma mark Uncompress of Gzip or Zlib
 81
 82/// Return an autoreleased NSData w/ the result of decompressing the bytes.
 83//
 84// The bytes to decompress can be zlib or gzip payloads.
 85+ (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
 86                              length:(NSUInteger)length;
 87
 88/// Return an autoreleased NSData w/ the result of decompressing the payload of |data|.
 89//
 90// The data to decompress can be zlib or gzip payloads.
 91+ (NSData *)gtm_dataByInflatingData:(NSData *)data;
 92
 93
 94#pragma mark "Raw" Compression Support
 95
 96// NOTE: raw deflate is *NOT* gzip or deflate.  it does not include a header
 97// of any form and should only be used within streams here an external crc/etc.
 98// is done to validate the data.  The RawInflate apis can be used on data
 99// processed like this.
100
101/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes.
102//
103//  Uses the default compression level.
104//  *No* header is added to the resulting data.
105+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes
106                                 length:(NSUInteger)length;
107
108/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data|.
109//
110//  Uses the default compression level.
111//  *No* header is added to the resulting data.
112+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data;
113
114/// Return an autoreleased NSData w/ the result of *raw* deflating the bytes using |level| compression level.
115//
116// |level| can be 1-9, any other values will be clipped to that range.
117//  *No* header is added to the resulting data.
118+ (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes
119                                 length:(NSUInteger)length
120                       compressionLevel:(int)level;
121
122/// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data| using |level| compression level.
123//  *No* header is added to the resulting data.
124+ (NSData *)gtm_dataByRawDeflatingData:(NSData *)data
125                      compressionLevel:(int)level;
126
127/// Return an autoreleased NSData w/ the result of *raw* decompressing the bytes.
128//
129// The data to decompress, it should *not* have any header (zlib nor gzip).
130+ (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes
131                                 length:(NSUInteger)length;
132
133/// Return an autoreleased NSData w/ the result of *raw* decompressing the payload of |data|.
134//
135// The data to decompress, it should *not* have any header (zlib nor gzip).
136+ (NSData *)gtm_dataByRawInflatingData:(NSData *)data;
137
138@end