Main MRPT website > C++ reference
MRPT logo
zip.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) C++ library |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (C) 2005-2012 University of Malaga |
7  | |
8  | This software was written by the Machine Perception and Intelligent |
9  | Robotics Lab, University of Malaga (Spain). |
10  | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> |
11  | |
12  | This file is part of the MRPT project. |
13  | |
14  | MRPT is free software: you can redistribute it and/or modify |
15  | it under the terms of the GNU General Public License as published by |
16  | the Free Software Foundation, either version 3 of the License, or |
17  | (at your option) any later version. |
18  | |
19  | MRPT is distributed in the hope that it will be useful, |
20  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
21  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
22  | GNU General Public License for more details. |
23  | |
24  | You should have received a copy of the GNU General Public License |
25  | along with MRPT. If not, see <http://www.gnu.org/licenses/>. |
26  | |
27  +---------------------------------------------------------------------------+ */
28 #ifndef ZipCompression_H
29 #define ZipCompression_H
30 
31 #include <mrpt/utils/utils_defs.h>
32 
33 namespace mrpt
34 {
35  namespace utils { class CStream; }
36 
37  /** Data compression/decompression algorithms. \ingroup mrpt_base_grp
38  */
39  namespace compress
40  {
41  using namespace mrpt::utils;
42 
43  /** Compression using the "zip" algorithm and from/to gzip (gz) files. \ingroup mrpt_base_grp
44  */
45  namespace zip
46  {
47  /** Compress an array of bytes into another one.
48  */
49  void BASE_IMPEXP compress(
50  void *inData,
51  size_t inDataSize,
52  std::vector<unsigned char> &outData);
53 
54  /** Compress an array of bytes into another one.
55  */
56  void BASE_IMPEXP compress(
57  const std::vector<unsigned char> &inData,
58  std::vector<unsigned char> &outData);
59 
60  /** Compress an array of bytes and write the result into a stream.
61  */
62  void BASE_IMPEXP compress(
63  void *inData,
64  size_t inDataSize,
65  CStream &out);
66 
67  /** Compress an array of bytes and write the result into a stream.
68  */
69  void BASE_IMPEXP compress(
70  const std::vector<unsigned char> &inData,
71  CStream &out);
72 
73  /** Decompress an array of bytes into another one
74  * \exception std::exception If the apriori estimated decompressed size is not enought
75  */
77  void *inData,
78  size_t inDataSize,
79  std::vector<unsigned char> &outData,
80  size_t outDataEstimatedSize);
81 
82  /** Decompress an array of bytes into another one
83  * \exception std::exception If the apriori estimated decompressed size is not enought
84  */
86  void *inData,
87  size_t inDataSize,
88  void *outData,
89  size_t outDataBufferSize,
90  size_t &outDataActualSize);
91 
92  /** Decompress an array of bytes into another one
93  * \exception std::exception If the apriori estimated decompressed size is not enought
94  */
96  CStream &inStream,
97  size_t inDataSize,
98  void *outData,
99  size_t outDataBufferSize,
100  size_t &outDataActualSize);
101 
102 
103  /** Decompress a gzip file (xxxx.gz) into a memory buffer. If the file is not a .gz file, it just read the whole file unmodified.
104  * \return true on success, false on error.
105  * \sa compress_gz_file, decompress_gz_data_block
106  */
108  const std::string &file_path,
109  vector_byte & buffer);
110 
111  /** Compress a memory buffer into a gzip file (xxxx.gz).
112  * compress_level: 0=no compression, 1=best speed, 9=maximum
113  * \return true on success, false on error.
114  * \sa decompress_gz_file, compress_gz_data_block
115  */
117  const std::string &file_path,
118  const vector_byte &buffer,
119  const int compress_level = 9
120  );
121 
122  /** Compress a memory buffer in gz-file format and return it as a block a memory.
123  * compress_level: 0=no compression, 1=best speed, 9=maximum
124  * \return true on success, false on error.
125  * \note If in_data is empty, an empty buffer is returned in out_gz_data and no error is reported.
126  * \sa compress_gz_file, de
127  */
129  const vector_byte &in_data,
130  vector_byte &out_gz_data,
131  const int compress_level = 9);
132 
133  /** Decompress an array of bytes storing a gz-compressed stream of data into a memory buffer. If the input data is not recognized as a .gz file, the output data will be an exact copy of the input.
134  * \return true on success, false on error.
135  * \sa decompress_gz_file, compress_gz_data_block
136  */
138  const vector_byte &in_gz_data,
139  vector_byte &out_data);
140 
141 
142  } // End of namespace
143  } // End of namespace
144 
145 } // End of namespace
146 
147 #endif



Page generated by Doxygen 1.8.3 for MRPT 0.9.6 SVN: at Fri Feb 15 22:05:02 EST 2013