Source

lrc / src / lrcExceptions.hxx

Full commit
//      lrcExceptions.hxx
//
//      Copyright 2011, 2012 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 lrcExceptions.hxx
 *
 * This file contains all exception classes for lrc project
 *
 * \author Andreas Tscharner
 * \date 2012-01-07
 */

#ifndef __LRC_EXCEPTIONS_HXX__
#define __LRC_EXCEPTIONS_HXX__


// Includefiles
#include <exception>


/*! \class lrcFileNotFoundException
 *  \brief Exception class if a file could not be found
 *
 * This is the exception that gets thrown if a file could not be found
 */
class lrcFileNotFoundException : public std::exception
{
	private:
		char *m_fileNotFound;          //!< Filename of file that could not be found

	public:
		/*! \brief Constructor
		 *
		 * The constructor expects the filename of the file that could not
		 * be found
		 *
		 * \param[in] p_fileNotFoundName Name of file that could not be found
		 */
		lrcFileNotFoundException(char *);
		/*! \brief Destructor
		 */
		~lrcFileNotFoundException(void) throw();

		/*! \brief Method to return reason
		 *
		 * The overwritten method what is used to return the reason of the
		 * exception
		 *
		 * \return Reason of exception
		 */
		virtual const char *what(void) const throw();
};

/*! \class lrcFileExistsException
 *  \brief Exception if an existing file should be overwritten
 *
 * This exception is thrown if an existing file should be overwritten, but
 * overwriting is not allowed
 */
class lrcFileExistsException : public std::exception
{
	private:
		char *m_fileOverwrite;         //!< Filename of file that should have been overwritten

	public:
		/*! \brief Constructor
		 *
		 * The constructor expects the filename of the file that should be
		 * overwritten
		 *
		 * \param[in] p_filename File of file to be overwritten
		 */
		lrcFileExistsException(char *);
		/*! \brief Destructor
		 *
		 * Frees up memory needed by the class
		 */
		~lrcFileExistsException(void) throw();

		/*! \brief Gives a reason for the exception
		 *
		 * Returns the reason the exception
		 *
		 * \return Reason for exception
		 */
		virtual const char *what(void) const throw();
};

/*! \class lrcEncryptionDisabledException
 *  \brief Exception if encryption is disabled but required
 *
 * This exception is thrown if the compiler is compiled without encryption
 * support, but the defined input file (.rc or .rif) defines to encrypt a
 * resource
 */
class lrcEncryptionDisabledException : public std::exception
{
	private:
		char *m_resourceID;            //!< Resource that requires encryption

	public:
		/*! \brief Constructor
		 *
		 * The constructor expects the name of the resource that requires
		 * encryption
		 *
		 * \param[in] p_resourceID Resource ID
		 */
		lrcEncryptionDisabledException(char *);
		/*! \brief Destructor
		 *
		 * Frees the memory of the exception
		 */
		~lrcEncryptionDisabledException(void) throw();

		/*! \brief Gives a reason for the exception
		 *
		 * Returns a message explaining that the user disabled encryption at
		 * compile time and therefore encryption of the resource is not
		 * possible
		 *
		 * \return Reason for exception
		 */
		virtual const char *what(void) const throw();
};


#endif /* __LRC_EXCEPTIONS_HXX__ */