Main MRPT website > C++ reference
MRPT logo
zip.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | The Mobile Robot Programming Toolkit (MRPT) |
3  | |
4  | http://www.mrpt.org/ |
5  | |
6  | Copyright (c) 2005-2013, Individual contributors, see AUTHORS file |
7  | Copyright (c) 2005-2013, MAPIR group, University of Malaga |
8  | Copyright (c) 2012-2013, University of Almeria |
9  | All rights reserved. |
10  | |
11  | Redistribution and use in source and binary forms, with or without |
12  | modification, are permitted provided that the following conditions are |
13  | met: |
14  | * Redistributions of source code must retain the above copyright |
15  | notice, this list of conditions and the following disclaimer. |
16  | * Redistributions in binary form must reproduce the above copyright |
17  | notice, this list of conditions and the following disclaimer in the |
18  | documentation and/or other materials provided with the distribution. |
19  | * Neither the name of the copyright holders nor the |
20  | names of its contributors may be used to endorse or promote products |
21  | derived from this software without specific prior written permission.|
22  | |
23  | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
24  | 'AS IS' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
25  | TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR|
26  | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE |
27  | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL|
28  | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR|
29  | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
30  | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
31  | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
32  | ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
33  | POSSIBILITY OF SUCH DAMAGE. |
34  +---------------------------------------------------------------------------+ */
35 #ifndef ZipCompression_H
36 #define ZipCompression_H
37 
38 #include <mrpt/utils/utils_defs.h>
39 
40 namespace mrpt
41 {
42  namespace utils { class CStream; }
43 
44  /** Data compression/decompression algorithms. \ingroup mrpt_base_grp
45  */
46  namespace compress
47  {
48  using namespace mrpt::utils;
49 
50  /** Compression using the "zip" algorithm and from/to gzip (gz) files. \ingroup mrpt_base_grp
51  */
52  namespace zip
53  {
54  /** Compress an array of bytes into another one.
55  */
56  void BASE_IMPEXP compress(
57  void *inData,
58  size_t inDataSize,
59  std::vector<unsigned char> &outData);
60 
61  /** Compress an array of bytes into another one.
62  */
63  void BASE_IMPEXP compress(
64  const std::vector<unsigned char> &inData,
65  std::vector<unsigned char> &outData);
66 
67  /** Compress an array of bytes and write the result into a stream.
68  */
69  void BASE_IMPEXP compress(
70  void *inData,
71  size_t inDataSize,
72  CStream &out);
73 
74  /** Compress an array of bytes and write the result into a stream.
75  */
76  void BASE_IMPEXP compress(
77  const std::vector<unsigned char> &inData,
78  CStream &out);
79 
80  /** Decompress an array of bytes into another one
81  * \exception std::exception If the apriori estimated decompressed size is not enought
82  */
84  void *inData,
85  size_t inDataSize,
86  std::vector<unsigned char> &outData,
87  size_t outDataEstimatedSize);
88 
89  /** Decompress an array of bytes into another one
90  * \exception std::exception If the apriori estimated decompressed size is not enought
91  */
93  void *inData,
94  size_t inDataSize,
95  void *outData,
96  size_t outDataBufferSize,
97  size_t &outDataActualSize);
98 
99  /** Decompress an array of bytes into another one
100  * \exception std::exception If the apriori estimated decompressed size is not enought
101  */
102  void BASE_IMPEXP decompress(
103  CStream &inStream,
104  size_t inDataSize,
105  void *outData,
106  size_t outDataBufferSize,
107  size_t &outDataActualSize);
108 
109 
110  /** 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.
111  * \return true on success, false on error.
112  * \sa compress_gz_file, decompress_gz_data_block
113  */
115  const std::string &file_path,
116  vector_byte & buffer);
117 
118  /** Compress a memory buffer into a gzip file (xxxx.gz).
119  * compress_level: 0=no compression, 1=best speed, 9=maximum
120  * \return true on success, false on error.
121  * \sa decompress_gz_file, compress_gz_data_block
122  */
124  const std::string &file_path,
125  const vector_byte &buffer,
126  const int compress_level = 9
127  );
128 
129  /** Compress a memory buffer in gz-file format and return it as a block a memory.
130  * compress_level: 0=no compression, 1=best speed, 9=maximum
131  * \return true on success, false on error.
132  * \note If in_data is empty, an empty buffer is returned in out_gz_data and no error is reported.
133  * \sa compress_gz_file, de
134  */
136  const vector_byte &in_data,
137  vector_byte &out_gz_data,
138  const int compress_level = 9);
139 
140  /** 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.
141  * \return true on success, false on error.
142  * \sa decompress_gz_file, compress_gz_data_block
143  */
145  const vector_byte &in_gz_data,
146  vector_byte &out_data);
147 
148 
149  } // End of namespace
150  } // End of namespace
151 
152 } // End of namespace
153 
154 #endif
Classes for serialization, sockets, ini-file manipulation, streams, list of properties-values, timewatch, extensions to STL.
Definition: zip.h:42
void BASE_IMPEXP compress(const std::vector< unsigned char > &inData, CStream &out)
Compress an array of bytes and write the result into a stream.
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:62
std::vector< uint8_t > vector_byte
bool BASE_IMPEXP compress_gz_file(const std::string &file_path, const vector_byte &buffer, const int compress_level=9)
Compress a memory buffer into a gzip file (xxxx.gz).
bool BASE_IMPEXP decompress_gz_file(const std::string &file_path, vector_byte &buffer)
Decompress a gzip file (xxxx.gz) into a memory buffer.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
void BASE_IMPEXP decompress(CStream &inStream, size_t inDataSize, void *outData, size_t outDataBufferSize, size_t &outDataActualSize)
Decompress an array of bytes into another one.
bool BASE_IMPEXP compress_gz_data_block(const vector_byte &in_data, vector_byte &out_gz_data, const int compress_level=9)
Compress a memory buffer in gz-file format and return it as a block a memory.
bool BASE_IMPEXP decompress_gz_data_block(const vector_byte &in_gz_data, vector_byte &out_data)
Decompress an array of bytes storing a gz-compressed stream of data into a memory buffer...



Page generated by Doxygen 1.8.14 for MRPT 1.0.2 SVN: at lun oct 28 00:52:41 CET 2019 Hosted on:
SourceForge.net Logo