Main MRPT website > C++ reference
MRPT logo
zip.h
Go to the documentation of this file.
1 /* +---------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | http://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2014, Individual contributors, see AUTHORS file |
6  | See: http://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See details in http://www.mrpt.org/License |
8  +---------------------------------------------------------------------------+ */
9 #ifndef ZipCompression_H
10 #define ZipCompression_H
11 
12 #include <mrpt/utils/utils_defs.h>
13 
14 namespace mrpt
15 {
16  namespace utils { class CStream; }
17 
18  /** Data compression/decompression algorithms. \ingroup mrpt_base_grp
19  */
20  namespace compress
21  {
23 
24  /** Compression using the "zip" algorithm and from/to gzip (gz) files. \ingroup mrpt_base_grp
25  */
26  namespace zip
27  {
28  /** Compress an array of bytes into another one.
29  */
30  void BASE_IMPEXP compress(
31  void *inData,
32  size_t inDataSize,
33  std::vector<unsigned char> &outData);
34 
35  /** Compress an array of bytes into another one.
36  */
37  void BASE_IMPEXP compress(
38  const std::vector<unsigned char> &inData,
39  std::vector<unsigned char> &outData);
40 
41  /** Compress an array of bytes and write the result into a stream.
42  */
43  void BASE_IMPEXP compress(
44  void *inData,
45  size_t inDataSize,
46  CStream &out);
47 
48  /** Compress an array of bytes and write the result into a stream.
49  */
50  void BASE_IMPEXP compress(
51  const std::vector<unsigned char> &inData,
52  CStream &out);
53 
54  /** Decompress an array of bytes into another one
55  * \exception std::exception If the apriori estimated decompressed size is not enought
56  */
58  void *inData,
59  size_t inDataSize,
60  std::vector<unsigned char> &outData,
61  size_t outDataEstimatedSize);
62 
63  /** Decompress an array of bytes into another one
64  * \exception std::exception If the apriori estimated decompressed size is not enought
65  */
67  void *inData,
68  size_t inDataSize,
69  void *outData,
70  size_t outDataBufferSize,
71  size_t &outDataActualSize);
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  CStream &inStream,
78  size_t inDataSize,
79  void *outData,
80  size_t outDataBufferSize,
81  size_t &outDataActualSize);
82 
83 
84  /** 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.
85  * \return true on success, false on error.
86  * \sa compress_gz_file, decompress_gz_data_block
87  */
89  const std::string &file_path,
90  vector_byte & buffer);
91 
92  /** Compress a memory buffer into a gzip file (xxxx.gz).
93  * compress_level: 0=no compression, 1=best speed, 9=maximum
94  * \return true on success, false on error.
95  * \sa decompress_gz_file, compress_gz_data_block
96  */
98  const std::string &file_path,
99  const vector_byte &buffer,
100  const int compress_level = 9
101  );
102 
103  /** Compress a memory buffer in gz-file format and return it as a block a memory.
104  * compress_level: 0=no compression, 1=best speed, 9=maximum
105  * \return true on success, false on error.
106  * \note If in_data is empty, an empty buffer is returned in out_gz_data and no error is reported.
107  * \sa compress_gz_file, de
108  */
110  const vector_byte &in_data,
111  vector_byte &out_gz_data,
112  const int compress_level = 9);
113 
114  /** 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.
115  * \return true on success, false on error.
116  * \sa decompress_gz_file, compress_gz_data_block
117  */
119  const vector_byte &in_gz_data,
120  vector_byte &out_data);
121 
122 
123  } // End of namespace
124  } // End of namespace
125 
126 } // End of namespace
127 
128 #endif
void BASE_IMPEXP compress(const std::vector< unsigned char > &inData, CStream &out)
Compress an array of bytes and write the result into a stream.
class BASE_IMPEXP CStream
Definition: math_frwds.h:26
void BASE_IMPEXP decompress(void *inData, size_t inDataSize, std::vector< unsigned char > &outData, size_t outDataEstimatedSize)
Decompress an array of bytes into another one If the apriori estimated decompressed size is not enoug...
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: CStream.h:38
std::vector< uint8_t > vector_byte
Definition: types_simple.h:23
void BASE_IMPEXP compress(void *inData, size_t inDataSize, std::vector< unsigned char > &outData)
Compress an array of bytes into another one.
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.
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.8 for MRPT 1.2.2 SVN:Unversioned directory at Tue Oct 14 02:14:08 UTC 2014