Source

lrc / src / include / CompressDecompress.hxx

//      CompressDecompress.hxx
//
//      Copyright 2011, 2012, 2013 Andreas Tscharner <andy@vis.ethz.ch>
//
//      This program is free software; you can redistribute it and/or modify
//      it under the terms of the GNU Lesser General Public License as
//      published by the Free Software Foundation; either version 3 of the
//      License, or (at your option) any later version.
//
//      This program is distributed in the hope that it will be useful,
//      but WITHOUT ANY WARRANTY; without even the implied warranty of
//      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//      GNU General Public License for more details.
//
//      You should have received a copy of the GNU Lesser General Public
//      License along with this program; if not, write to the Free Software
//      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
//      MA 02110-1301, USA.


/*! \file CompressDecompress.hxx
 *
 * File that contains the CompressDecompress class, the base class for all
 * compression/decompression algorithms used in \c lrc
 *
 * \author Andreas Tscharner
 * \date 2013-09-08
 */


#ifndef __COMPRESSDECOMPRESS_HXX__
#define __COMPRESSDECOMPRESS_HXX__


#include <stddef.h>


namespace lrc
{
	/*! Possible compression types for resource
	 *
	 * \todo Add more possibilities to compress resource
	 */
	enum CompressionType {
		 NoneCompression,              //!< No compression at all
		 zLibCompression,              //!< zlib compression
		 bz2LibCompression,            //!< bzip2 compression
		 lastCompression               //!< Marker for last entry
	};

	/*! German names of all possible compression types for a resource
	 */
	static const char *CompressionTypeNames[] = {"Keine", "zLib", "bzip2"};


	/*! \class CompressDecompress
	 *  \brief Compression and Decompression base class
	 *
	 * The class CompressDecompress is the base class for all compression
	 * and decompression in \c lrc and \c liblrc.
	 */
	class CompressDecompress
	{
		public:
			/*! \brief Abstract method for compression
			 *
			 * This abstract method has to be implemented by a dervied class
			 * for compression
			 *
			 * \param[in] p_decompData Not yet compressed resource data
			 * \param[in] p_decompSize Size of the not yet compressed resource data
			 * \param[out] p_compData Compressed resource data
			 * \param[out] p_compSize Size of the compressed resource data
			 *
			 * \retval NO_ERROR Data successfully compressed
			 *
			 * \remarks The caller is responsible to free the used memory
			 */
			virtual int compress(const unsigned char *, size_t, unsigned char **, size_t &) = 0;
			/*! \brief Abstract method for decompression
			 *
			 * This abstract method has to be implemented by a derived class
			 * for decompression
			 *
			 * \param[in] p_compData Compressed resource data
			 * \param[in] p_compSize Size of compressed resource data
			 * \param[out] p_decompData Decompressed resource data
			 * \param[out] p_decompSize Size of decompressed resource data
			 *
			 * \retval NO_ERROR Data successfully decompressed
			 *
			 * \remarks The caller is responsible to free the used memory
			 */
			virtual int decompress(const unsigned char *, size_t, unsigned char **, size_t &) = 0;
	};
}


#endif /* __COMPRESSDECOMPRESS_HXX__ */
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.