00001 /* +---------------------------------------------------------------------------+ 00002 | The Mobile Robot Programming Toolkit (MRPT) C++ library | 00003 | | 00004 | http://mrpt.sourceforge.net/ | 00005 | | 00006 | Copyright (C) 2005-2009 University of Malaga | 00007 | | 00008 | This software was written by the Machine Perception and Intelligent | 00009 | Robotics Lab, University of Malaga (Spain). | 00010 | Contact: Jose-Luis Blanco <jlblanco@ctima.uma.es> | 00011 | | 00012 | This file is part of the MRPT project. | 00013 | | 00014 | MRPT is free software: you can redistribute it and/or modify | 00015 | it under the terms of the GNU General Public License as published by | 00016 | the Free Software Foundation, either version 3 of the License, or | 00017 | (at your option) any later version. | 00018 | | 00019 | MRPT is distributed in the hope that it will be useful, | 00020 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 00021 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 00022 | GNU General Public License for more details. | 00023 | | 00024 | You should have received a copy of the GNU General Public License | 00025 | along with MRPT. If not, see <http://www.gnu.org/licenses/>. | 00026 | | 00027 +---------------------------------------------------------------------------+ */ 00028 #ifndef ZipCompression_H 00029 #define ZipCompression_H 00030 00031 #include <mrpt/utils/utils_defs.h> 00032 00033 namespace mrpt 00034 { 00035 namespace utils { class CStream; } 00036 00037 /** Data compression/decompression algorithms. 00038 */ 00039 namespace compress 00040 { 00041 using namespace mrpt::utils; 00042 00043 /** Compression using the "zip" algorithm and from/to gzip (gz) files. 00044 */ 00045 namespace zip 00046 { 00047 /** Compress an array of bytes into another one. 00048 */ 00049 void MRPTDLLIMPEXP compress( 00050 void *inData, 00051 size_t inDataSize, 00052 std::vector<unsigned char> &outData); 00053 00054 /** Compress an array of bytes into another one. 00055 */ 00056 void MRPTDLLIMPEXP compress( 00057 const std::vector<unsigned char> &inData, 00058 std::vector<unsigned char> &outData); 00059 00060 /** Compress an array of bytes and write the result into a stream. 00061 */ 00062 void MRPTDLLIMPEXP compress( 00063 void *inData, 00064 size_t inDataSize, 00065 CStream &out); 00066 00067 /** Compress an array of bytes and write the result into a stream. 00068 */ 00069 void MRPTDLLIMPEXP compress( 00070 const std::vector<unsigned char> &inData, 00071 CStream &out); 00072 00073 /** Decompress an array of bytes into another one 00074 * \exception std::exception If the apriori estimated decompressed size is not enought 00075 */ 00076 void MRPTDLLIMPEXP decompress( 00077 void *inData, 00078 size_t inDataSize, 00079 std::vector<unsigned char> &outData, 00080 size_t outDataEstimatedSize); 00081 00082 /** Decompress an array of bytes into another one 00083 * \exception std::exception If the apriori estimated decompressed size is not enought 00084 */ 00085 void MRPTDLLIMPEXP decompress( 00086 void *inData, 00087 size_t inDataSize, 00088 void *outData, 00089 size_t outDataBufferSize, 00090 size_t &outDataActualSize); 00091 00092 /** Decompress an array of bytes into another one 00093 * \exception std::exception If the apriori estimated decompressed size is not enought 00094 */ 00095 void MRPTDLLIMPEXP decompress( 00096 CStream &inStream, 00097 size_t inDataSize, 00098 void *outData, 00099 size_t outDataBufferSize, 00100 size_t &outDataActualSize); 00101 00102 00103 /** 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. 00104 * \return true on success, false on error. 00105 * \sa compress_gz_file, decompress_gz_data_block 00106 */ 00107 bool MRPTDLLIMPEXP decompress_gz_file( 00108 const std::string &file_path, 00109 vector_byte & buffer); 00110 00111 /** Compress a memory buffer into a gzip file (xxxx.gz). 00112 * compress_level: 0=no compression, 1=best speed, 9=maximum 00113 * \return true on success, false on error. 00114 * \sa decompress_gz_file, compress_gz_data_block 00115 */ 00116 bool MRPTDLLIMPEXP compress_gz_file( 00117 const std::string &file_path, 00118 const vector_byte &buffer, 00119 const int compress_level = 9 00120 ); 00121 00122 /** Compress a memory buffer in gz-file format and return it as a block a memory. 00123 * compress_level: 0=no compression, 1=best speed, 9=maximum 00124 * \return true on success, false on error. 00125 * \note If in_data is empty, an empty buffer is returned in out_gz_data and no error is reported. 00126 * \sa compress_gz_file, de 00127 */ 00128 bool MRPTDLLIMPEXP compress_gz_data_block( 00129 const vector_byte &in_data, 00130 vector_byte &out_gz_data, 00131 const int compress_level = 9); 00132 00133 /** 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. 00134 * \return true on success, false on error. 00135 * \sa decompress_gz_file, compress_gz_data_block 00136 */ 00137 bool MRPTDLLIMPEXP decompress_gz_data_block( 00138 const vector_byte &in_gz_data, 00139 vector_byte &out_data); 00140 00141 00142 } // End of namespace 00143 } // End of namespace 00144 00145 } // End of namespace 00146 00147 #endif
Page generated by Doxygen 1.5.7.1 for MRPT 0.7.1 SVN: at Mon Aug 17 23:02:22 EDT 2009 |