PageRenderTime 15ms CodeModel.GetById 9ms RepoModel.GetById 0ms 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
Possible License(s): Apache-2.0, BSD-3-Clause, GPL-2.0
  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. #import <Foundation/Foundation.h>
  19. #import "GTMDefines.h"
  20. /// Helpers for dealing w/ zlib inflate/deflate calls.
  21. @interface NSData (GTMZLibAdditions)
  22. // NOTE: For 64bit, none of these apis handle input sizes >32bits, they will
  23. // return nil when given such data. To handle data of that size you really
  24. // should be streaming it rather then doing it all in memory.
  25. #pragma mark Gzip Compression
  26. /// Return an autoreleased NSData w/ the result of gzipping the bytes.
  27. //
  28. // Uses the default compression level.
  29. + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
  30. length:(NSUInteger)length;
  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. /// Return an autoreleased NSData w/ the result of gzipping the bytes using |level| compression level.
  36. //
  37. // |level| can be 1-9, any other values will be clipped to that range.
  38. + (NSData *)gtm_dataByGzippingBytes:(const void *)bytes
  39. length:(NSUInteger)length
  40. compressionLevel:(int)level;
  41. /// Return an autoreleased NSData w/ the result of gzipping the payload of |data| using |level| compression level.
  42. + (NSData *)gtm_dataByGzippingData:(NSData *)data
  43. compressionLevel:(int)level;
  44. #pragma mark Zlib "Stream" Compression
  45. // NOTE: deflate is *NOT* gzip. deflate is a "zlib" stream. pick which one
  46. // you really want to create. (the inflate api will handle either)
  47. /// Return an autoreleased NSData w/ the result of deflating the bytes.
  48. //
  49. // Uses the default compression level.
  50. + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
  51. length:(NSUInteger)length;
  52. /// Return an autoreleased NSData w/ the result of deflating the payload of |data|.
  53. //
  54. // Uses the default compression level.
  55. + (NSData *)gtm_dataByDeflatingData:(NSData *)data;
  56. /// Return an autoreleased NSData w/ the result of deflating the bytes using |level| compression level.
  57. //
  58. // |level| can be 1-9, any other values will be clipped to that range.
  59. + (NSData *)gtm_dataByDeflatingBytes:(const void *)bytes
  60. length:(NSUInteger)length
  61. compressionLevel:(int)level;
  62. /// Return an autoreleased NSData w/ the result of deflating the payload of |data| using |level| compression level.
  63. + (NSData *)gtm_dataByDeflatingData:(NSData *)data
  64. compressionLevel:(int)level;
  65. #pragma mark Uncompress of Gzip or Zlib
  66. /// Return an autoreleased NSData w/ the result of decompressing the bytes.
  67. //
  68. // The bytes to decompress can be zlib or gzip payloads.
  69. + (NSData *)gtm_dataByInflatingBytes:(const void *)bytes
  70. length:(NSUInteger)length;
  71. /// Return an autoreleased NSData w/ the result of decompressing the payload of |data|.
  72. //
  73. // The data to decompress can be zlib or gzip payloads.
  74. + (NSData *)gtm_dataByInflatingData:(NSData *)data;
  75. #pragma mark "Raw" Compression Support
  76. // NOTE: raw deflate is *NOT* gzip or deflate. it does not include a header
  77. // of any form and should only be used within streams here an external crc/etc.
  78. // is done to validate the data. The RawInflate apis can be used on data
  79. // processed like this.
  80. /// Return an autoreleased NSData w/ the result of *raw* deflating the bytes.
  81. //
  82. // Uses the default compression level.
  83. // *No* header is added to the resulting data.
  84. + (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes
  85. length:(NSUInteger)length;
  86. /// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data|.
  87. //
  88. // Uses the default compression level.
  89. // *No* header is added to the resulting data.
  90. + (NSData *)gtm_dataByRawDeflatingData:(NSData *)data;
  91. /// Return an autoreleased NSData w/ the result of *raw* deflating the bytes using |level| compression level.
  92. //
  93. // |level| can be 1-9, any other values will be clipped to that range.
  94. // *No* header is added to the resulting data.
  95. + (NSData *)gtm_dataByRawDeflatingBytes:(const void *)bytes
  96. length:(NSUInteger)length
  97. compressionLevel:(int)level;
  98. /// Return an autoreleased NSData w/ the result of *raw* deflating the payload of |data| using |level| compression level.
  99. // *No* header is added to the resulting data.
  100. + (NSData *)gtm_dataByRawDeflatingData:(NSData *)data
  101. compressionLevel:(int)level;
  102. /// Return an autoreleased NSData w/ the result of *raw* decompressing the bytes.
  103. //
  104. // The data to decompress, it should *not* have any header (zlib nor gzip).
  105. + (NSData *)gtm_dataByRawInflatingBytes:(const void *)bytes
  106. length:(NSUInteger)length;
  107. /// Return an autoreleased NSData w/ the result of *raw* decompressing the payload of |data|.
  108. //
  109. // The data to decompress, it should *not* have any header (zlib nor gzip).
  110. + (NSData *)gtm_dataByRawInflatingData:(NSData *)data;
  111. @end