crypt/yapetexception.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: yapetexception.h,v 1.1 2008-02-07 23:39:11 rafi Exp $
00004 //
00005 // YAPET -- Yet Another Password Encryption Tool
00006 // Copyright (C) 2008  Rafael Ostertag
00007 //
00008 // This program is free software: you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation, either version 3 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020 //
00021 
00022 #ifndef _YAPETEXCEPTION_H
00023 #define _YAPETEXCEPTION_H
00024 
00025 #ifdef HAVE_CONFIG_H
00026 # include <config.h>
00027 #endif
00028 
00029 #ifdef HAVE_EXCEPTION
00030 # include <exception>
00031 #endif
00032 
00033 #ifdef HAVE_STRING
00034 # include <string>
00035 #endif
00036 
00037 namespace YAPET {
00038 
00044     class YAPETException : public std::exception {
00045     private:
00046         std::string message;
00047         
00048     public:
00054         inline YAPETException() 
00055         throw() : exception(),
00056               message("Generic exception message") {}
00064         inline YAPETException(std::string msg) 
00065         throw() : exception(),
00066               message(msg) {}
00067         inline YAPETException(const YAPETException& ex) throw() {
00068         message = ex.message;
00069         }
00070         inline virtual ~YAPETException() throw() { /* empty */ }
00071         inline const YAPETException& operator=(const YAPETException& ex)
00072         throw() {
00073         if (this == &ex) return *this;
00074         message = ex.message;
00075         return *this;
00076         }
00077         inline virtual const char* what() const throw() {
00078         return message.c_str();
00079         }
00080     };    
00081 
00090     class YAPETRetryException : public YAPETException {
00091     public:
00092         inline YAPETRetryException() 
00093         throw() : YAPETException("Retry") {}
00094         inline YAPETRetryException(std::string msg)
00095         throw() : YAPETException(msg) {}
00096         inline YAPETRetryException(const YAPETRetryException& ex)
00097         throw() : YAPETException(ex) {}
00098         inline virtual ~YAPETRetryException() throw() { /* Empty */ }
00099 
00100         inline const YAPETRetryException
00101         operator=(const YAPETRetryException& ex) throw() {
00102         if (this == &ex) return *this;
00103         YAPETException::operator=(ex);
00104         return *this;
00105         }
00106     };
00107 
00114     class YAPETEncryptionException : public YAPETException {
00115     public:
00116         inline YAPETEncryptionException()
00117         throw() : YAPETException("Encryption error") {}
00118         inline YAPETEncryptionException(std::string msg)
00119         throw() : YAPETException(msg) {}
00120         inline YAPETEncryptionException(const YAPETEncryptionException& ex)
00121         throw() : YAPETException(ex) {}
00122         inline virtual ~YAPETEncryptionException() throw() { /* Empty */ }
00123 
00124         inline const YAPETEncryptionException
00125         operator=(const YAPETEncryptionException& ex) throw() {
00126         if (this == &ex) return *this;
00127         YAPETException::operator=(ex);
00128         return *this;
00129         }
00130     };
00131 
00140     class YAPETInvalidPasswordException : public YAPETException {
00141     public:
00142         inline YAPETInvalidPasswordException()
00143         throw() : YAPETException("Invalid password") {}
00144         inline YAPETInvalidPasswordException(std::string msg)
00145         throw() : YAPETException(msg) {}
00146 
00147         inline
00148         YAPETInvalidPasswordException(const YAPETInvalidPasswordException& ex)
00149         throw() : YAPETException(ex) {}
00150         inline virtual ~YAPETInvalidPasswordException()
00151         throw() { /* Empty */ }
00152 
00153         inline const YAPETInvalidPasswordException
00154         operator=(const YAPETInvalidPasswordException& ex) throw() {
00155         if (this == &ex) return *this;
00156         YAPETException::operator=(ex);
00157         return *this;
00158         }
00159     };
00160                          
00161 }
00162 
00163 #endif // _YAPETEXCEPTION_H

Generated on Wed Feb 27 16:15:41 2008 for YAPET by  doxygen 1.5.4