lrc / src / include / Resource.hxx

Full commit
//      Resource.hxx
//      Copyright 2011, 2012 Andreas Tscharner <>
//      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
//      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 Resource.hxx
 * This file contains one of the main classes: Resource
 * \author Andreas Tscharner
 * \date 2012-06-10

#ifndef __RESOURCE_HXX__
#define __RESOURCE_HXX__

#include <stddef.h>
#include "CompressDecompress.hxx"
#include "EncryptDecrypt.hxx"

/*! \mainpage lrc - Linux Resource Compiler
 * \section intro Introduction
 * This documentation covers the classes and data structures of the \c lrc
 * compiler and the library \c liblrc.\n
 * \section options Compiler Options
 * The compiler needs at least one input file. It is called as follows:\n
 * <tt>lrc -h | [-d] [-o \<rdfFile\>] [-c \<compression type\>]\<RCFile\>|\<rifFile\></tt>\n\n
 * The options have the following meaning:\n
 * <tt>-h</tt>: Show the usage of the compiler and quit.\n
 * <tt>-d</tt>: Deny overwrite an existing .rdf file. This parameter is
 * optional and the default is overwriting allowed. If <tt>-d</tt> is set
 * and the file already exists, the compiler exits with an error message.\n
 * <tt>-o \<file\></tt>: Specify the resource output file (.rdf). This
 * parameter is optional. If it is omitted the output file will be the name
 * of the input file, but with .rdf as file extension.\n
 * <tt>-c \<compression type\></tt>: Specify the compression type for the
 * whole .rdf file. Allowed are all compression types that are allowed for a
 * single resource file. These are at the moment:
 * - zLib: zLib compression
 * - bzip2: bzip2 compression
 * \section liblrc The library liblrc
 * The library consists mainly of two classes: the \link
 * lrc::ResourceManager ResourceManager\endlink and the \link lrc::Resource
 * Resource\endlink class. One ResourceManager instance is used for one
 * resource data file (.rdf).\n
 * The resource manager provides two main methods: one lists all resource
 * entries from the .rdf file, the other returns an instance of a Resource
 * class, identified by its ID or index.
 * \section example Example
 * A few examples that demonstrates the \c lrc and \c liblrc can be found in
 * the <tt>src/example</tt> directory.
 * \author Andreas Tscharner
 * \date 2013-01-13

#define MAX_ID_LEN 80                  //!< Maximum length of resource ID

/*! \brief Data for one resource entry
 * This struct contains the data for one resource entry in a form to save to
 * the .rdf file
struct resEntry_ {
	char resID[MAX_ID_LEN];            //!< Resource ID
	unsigned int startOffset;          //!< Offset from the start
	unsigned int resSize;              //!< Size of resource
	lrc::EncryptionType encType;       //!< Type of encryption of this entry
	lrc::CompressionType compType;     //!< Type of compression of this entry

//! Define a better name for struct resEntry_
typedef struct resEntry_ resEntry;

/*! \namespace lrc
 *  \brief Namespace lrc for classes in the library and for extending \c lrc
 * The namespace lrc was introduced and used for classes and functions that
 * will be used in the \c liblrc library to avoid confusion with other
 * classes that may have the same name.
 * It is also used for two abstract classes: CompressDecompress and
 * EncryptDecrypt. These two classes are the base classes for compression
 * and decompression and for encryption and decryption of the resource data.
 * They can be found in the CompressDecompress.hxx and the
 * EncryptDecrypt.hxx file respectively.
namespace lrc
	/*! \class Resource
	 *  \brief Resource class for use with library
	 * This class is used to define one resource for the developer that uses
	 * lrc. It contains a pointer to the data and the size of the data. It
	 * also provides its ID.
	class Resource
			char *m_resID;             //!< Resource ID
			unsigned char *m_resData;  //!< Pointer to resource data
			size_t m_resSize;          //!< Size of resource data

			/*! \brief Constructor
			 * This is a standard constructor. It initializes all members
			 * to default values
			 * \remarks The values will be filled by the derived class
			/*! \brief Destructor
			 * Cleans up the used memory of the class

			/*! \brief Returns the ID of the resource
			 * Method to return the ID of the resource
			 * \return ID of resource
			char *get_ID(void);
			/*! \brief Actual resource data
			 * This method returns a pointer to the actual resource data as
			 * bytes
			 * \return Pointer to resource data
			unsigned char *get_res_data(void);
			/*! \brief Actual resource size
			 * Method to return the actual size of the resource (in bytes)
			 * \return Size of resource
			size_t get_res_size(void);

#endif /* __RESOURCE_HXX__ */