namespace mrpt::io::zip
Overview
Compression using the “zip” algorithm and from/to gzip (gz) files.
namespace zip { // global functions void compress(void* inData, size_t inDataSize, std::vector<unsigned char>& outData); void compress( const std::vector<unsigned char>& inData, std::vector<unsigned char>& outData ); void compress(void* inData, size_t inDataSize, mrpt::io::CStream& out); void compress(const std::vector<unsigned char>& inData, mrpt::io::CStream& out); void decompress( void* inData, size_t inDataSize, std::vector<unsigned char>& outData, size_t outDataEstimatedSize ); size_t decompress( void* inData, size_t inDataSize, void* outData, size_t outDataBufferSize ); size_t decompress(mrpt::io::CStream& inStream, size_t inDataSize, void* outData, size_t outDataBufferSize); bool decompress_gz_file(const std::string& file_path, std::vector<uint8_t>& buffer); bool compress_gz_file( const std::string& file_path, const std::vector<uint8_t>& buffer, const int compress_level = 9 ); bool compress_gz_data_block( const std::vector<uint8_t>& in_data, std::vector<uint8_t>& out_gz_data, const int compress_level = 9 ); bool decompress_gz_data_block(const std::vector<uint8_t>& in_gz_data, std::vector<uint8_t>& out_data); } // namespace zip
Global Functions
void compress( void* inData, size_t inDataSize, std::vector<unsigned char>& outData )
Compress an array of bytes into another one.
void compress( const std::vector<unsigned char>& inData, std::vector<unsigned char>& outData )
Compress an array of bytes into another one.
void compress(void* inData, size_t inDataSize, mrpt::io::CStream& out)
Compress an array of bytes and write the result into a stream.
void compress(const std::vector<unsigned char>& inData, mrpt::io::CStream& out)
Compress an array of bytes and write the result into a stream.
void decompress( void* inData, size_t inDataSize, std::vector<unsigned char>& outData, size_t outDataEstimatedSize )
Decompress an array of bytes into another one.
Parameters:
std::exception |
If the apriori estimated decompressed size is not enough |
size_t decompress( void* inData, size_t inDataSize, void* outData, size_t outDataBufferSize )
Decompress an array of bytes into another one.
Parameters:
std::exception |
If the apriori estimated decompressed size is not enough. |
Returns:
Output uncompressed data size in bytes.
size_t decompress( mrpt::io::CStream& inStream, size_t inDataSize, void* outData, size_t outDataBufferSize )
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
bool decompress_gz_file( const std::string& file_path, std::vector<uint8_t>& buffer )
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.
Returns:
true on success, false on error.
See also:
compress_gz_file, decompress_gz_data_block
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).
compress_level: 0=no compression, 1=best speed, 9=maximum
Returns:
true on success, false on error.
See also:
decompress_gz_file, 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.
compress_level: 0=no compression, 1=best speed, 9=maximum If in_data is empty, an empty buffer is returned in out_gz_data and no error is reported.
Returns:
true on success, false on error.
See also:
compress_gz_file, de
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.
If the input data is not recognized as a .gz file, the output data will be an exact copy of the input.
Returns:
true on success, false on error.
See also: