Main MRPT website > C++ reference for MRPT 1.9.9
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-2018, 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 #pragma once
10 
11 #include <string>
12 #include <vector>
13 
14 namespace mrpt
15 {
16 namespace io
17 {
18 class CStream;
19 
20 /** Compression using the "zip" algorithm and from/to gzip (gz) files. \ingroup
21  * mrpt_io_grp */
22 namespace zip
23 {
24 /** Compress an array of bytes into another one. */
25 void compress(
26  void* inData, size_t inDataSize, std::vector<unsigned char>& outData);
27 
28 /** Compress an array of bytes into another one. */
29 void compress(
30  const std::vector<unsigned char>& inData,
31  std::vector<unsigned char>& outData);
32 
33 /** Compress an array of bytes and write the result into a stream. */
34 void compress(void* inData, size_t inDataSize, mrpt::io::CStream& out);
35 
36 /** Compress an array of bytes and write the result into a stream. */
37 void compress(const std::vector<unsigned char>& inData, mrpt::io::CStream& out);
38 
39 /** Decompress an array of bytes into another one
40  * \exception std::exception If the apriori estimated decompressed size is not
41  * enought */
42 void decompress(
43  void* inData, size_t inDataSize, std::vector<unsigned char>& outData,
44  size_t outDataEstimatedSize);
45 
46 /** Decompress an array of bytes into another one
47  * \exception std::exception If the apriori estimated decompressed size is not
48  * enought
49  */
50 void decompress(
51  void* inData, size_t inDataSize, void* outData, size_t outDataBufferSize,
52  size_t& outDataActualSize);
53 
54 /** Decompress an array of bytes into another one
55  * \exception std::exception If the apriori estimated decompressed size is not
56  * enought
57  */
58 void decompress(
59  mrpt::io::CStream& inStream, size_t inDataSize, void* outData,
60  size_t outDataBufferSize, size_t& outDataActualSize);
61 
62 /** Decompress a gzip file (xxxx.gz) into a memory buffer. If the file is not a
63  * .gz file, it just read the whole file unmodified.
64  * \return true on success, false on error.
65  * \sa compress_gz_file, decompress_gz_data_block
66  */
68  const std::string& file_path, std::vector<uint8_t>& buffer);
69 
70 /** Compress a memory buffer into a gzip file (xxxx.gz).
71  * compress_level: 0=no compression, 1=best speed, 9=maximum
72  * \return true on success, false on error.
73  * \sa decompress_gz_file, compress_gz_data_block
74  */
75 bool compress_gz_file(
76  const std::string& file_path, const std::vector<uint8_t>& buffer,
77  const int compress_level = 9);
78 
79 /** Compress a memory buffer in gz-file format and return it as a block a
80  * memory.
81  * compress_level: 0=no compression, 1=best speed, 9=maximum
82  * \return true on success, false on error.
83  * \note If in_data is empty, an empty buffer is returned in out_gz_data and no
84  * error is reported.
85  * \sa compress_gz_file, de
86  */
88  const std::vector<uint8_t>& in_data, std::vector<uint8_t>& out_gz_data,
89  const int compress_level = 9);
90 
91 /** Decompress an array of bytes storing a gz-compressed stream of data into a
92  * memory buffer. If the input data is not recognized as a .gz file, the output
93  * data will be an exact copy of the input.
94  * \return true on success, false on error.
95  * \sa decompress_gz_file, compress_gz_data_block
96  */
98  const std::vector<uint8_t>& in_gz_data, std::vector<uint8_t>& out_data);
99 
100 } // End of namespace
101 } // End of namespace
102 } // End of namespace
mrpt::io::zip::decompress_gz_file
bool decompress_gz_file(const std::string &file_path, std::vector< uint8_t > &buffer)
Decompress a gzip file (xxxx.gz) into a memory buffer.
Definition: zip.cpp:209
mrpt::io::zip::compress_gz_file
bool compress_gz_file(const std::string &file_path, const std::vector< uint8_t > &buffer, const int compress_level=9)
Compress a memory buffer into a gzip file (xxxx.gz).
Definition: zip.cpp:234
mrpt::utils::CStream
mrpt::io::CStream CStream
Definition: utils/CStream.h:7
mrpt::io::zip::compress
void compress(void *inData, size_t inDataSize, std::vector< unsigned char > &outData)
Compress an array of bytes into another one.
Definition: zip.cpp:35
mrpt::io::zip::decompress
void decompress(void *inData, size_t inDataSize, std::vector< unsigned char > &outData, size_t outDataEstimatedSize)
Decompress an array of bytes into another one.
Definition: zip.cpp:135
mrpt::io::zip::compress_gz_data_block
bool compress_gz_data_block(const std::vector< uint8_t > &in_data, std::vector< uint8_t > &out_gz_data, const int compress_level=9)
Compress a memory buffer in gz-file format and return it as a block a memory.
Definition: zip.cpp:260
mrpt
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
Definition: CKalmanFilterCapable.h:30
mrpt::io::zip::decompress_gz_data_block
bool decompress_gz_data_block(const std::vector< uint8_t > &in_gz_data, std::vector< uint8_t > &out_data)
Decompress an array of bytes storing a gz-compressed stream of data into a memory buffer.
Definition: zip.cpp:358
buffer
GLuint buffer
Definition: glext.h:3917
string
GLsizei const GLchar ** string
Definition: glext.h:4101
mrpt::io::CStream
This base class is used to provide a unified interface to files,memory buffers,..Please see the deriv...
Definition: io/CStream.h:30



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST