GoogleToolboxSubset/GTMNSData+zlib.h
author Olivier Scherler <oscherler@femto-byte.com>
Tue May 12 14:38:30 2009 +0200 (2009-05-12)
changeset 30 2befbe36c746
permissions -rw-r--r--
Changed -[MYDirectoryEvent relativePath] to work on standardised paths, in case symlinks are used. Fixes issue #28 in Murky.
     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 /// Return an autoreleased NSData w/ the result of gzipping the bytes.
    26 //
    27 //  Uses the default compression level.
    28 + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
    29                              length:(NSUInteger)length;
    30 
    31 /// Return an autoreleased NSData w/ the result of gzipping the payload of |data|.
    32 //
    33 //  Uses the default compression level.
    34 + (NSData *)gtm_dataByGzippingData:(NSData *)data;
    35 
    36 /// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level.
    37 //
    38 // |level| can be 1-9, any other values will be clipped to that range.
    39 + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
    40                              length:(NSUInteger)length
    41                    compressionLevel:(int)level;
    42 
    43 /// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level.
    44 + (NSData *)gtm_dataByGzippingData:(NSData *)data
    45                   compressionLevel:(int)level;
    46 
    47 // NOTE: deflate is *NOT* gzip.  deflate is a "zlib" stream.  pick which one
    48 // you really want to create.  (the inflate api will handle either)
    49 
    50 /// Return an autoreleased NSData w/ the result of deflating the bytes.
    51 //
    52 //  Uses the default compression level.
    53 + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
    54                               length:(NSUInteger)length;
    55 
    56 /// Return an autoreleased NSData w/ the result of deflating the payload of |data|.
    57 //
    58 //  Uses the default compression level.
    59 + (NSData *)gtm_dataByDeflatingData:(NSData *)data;
    60 
    61 /// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level.
    62 //
    63 // |level| can be 1-9, any other values will be clipped to that range.
    64 + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
    65                               length:(NSUInteger)length
    66                     compressionLevel:(int)level;
    67 
    68 /// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level.
    69 + (NSData *)gtm_dataByDeflatingData:(NSData *)data
    70                    compressionLevel:(int)level;
    71 
    72 
    73 /// Return an autoreleased NSData w/ the result of decompressing the bytes.
    74 //
    75 // The bytes to decompress can be zlib or gzip payloads.
    76 + (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
    77                               length:(NSUInteger)length;
    78 
    79 /// Return an autoreleased NSData w/ the result of decompressing the payload of |data|.
    80 //
    81 // The data to decompress can be zlib or gzip payloads.
    82 + (NSData *)gtm_dataByInflatingData:(NSData *)data;
    83 
    84 @end