• Main Page
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

crypt/yapetexception.h

Go to the documentation of this file.
00001 // -*- c++ -*-
00002 //
00003 // $Id: yapetexception.h 3342 2010-09-17 18:32:00Z java $
00004 //
00005 // Copyright (C) 2008-2010  Rafael Ostertag
00006 //
00007 // This file is part of YAPET.
00008 //
00009 // YAPET is free software: you can redistribute it and/or modify it under the
00010 // terms of the GNU General Public License as published by the Free Software
00011 // Foundation, either version 3 of the License, or (at your option) any later
00012 // version.
00013 //
00014 // YAPET is distributed in the hope that it will be useful, but WITHOUT ANY
00015 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00016 // FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
00017 // details.
00018 //
00019 // You should have received a copy of the GNU General Public License along with
00020 // YAPET.  If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Additional permission under GNU GPL version 3 section 7
00023 //
00024 // If you modify this program, or any covered work, by linking or combining it
00025 // with the OpenSSL project's OpenSSL library (or a modified version of that
00026 // library), containing parts covered by the terms of the OpenSSL or SSLeay
00027 // licenses, Rafael Ostertag grants you additional permission to convey the
00028 // resulting work.  Corresponding Source for a non-source form of such a
00029 // combination shall include the source code for the parts of OpenSSL used as
00030 // well as that of the covered work.
00031 //
00032 
00033 #ifndef _YAPETEXCEPTION_H
00034 #define _YAPETEXCEPTION_H
00035 
00036 #ifdef HAVE_CONFIG_H
00037 # include <config.h>
00038 #endif
00039 
00040 #ifdef HAVE_EXCEPTION
00041 # include <exception>
00042 #endif
00043 
00044 #ifdef HAVE_STRING
00045 # include <string>
00046 #endif
00047 
00048 #include "../intl.h"
00049 
00050 namespace YAPET {
00051 
00060     enum EXNUM {
00061     BDBUFFER_TOO_SMALL = 1,
00062     BDBUFFER_TOO_BIG = 2,
00063     NULLPOINTER = 3,
00064     NOTUSED = 255
00065     };
00066 
00074     class YAPETException : public std::exception {
00075         private:
00076         EXNUM exnum;
00077             std::string message;
00078 
00079     protected:
00080         inline void setExNum(EXNUM n) { exnum = n ; }
00081         public:
00087             inline YAPETException()
00088             throw() : exception(),
00089               exnum(NOTUSED),
00090                     message (_ ("Generic exception message") ) {}
00098             inline YAPETException (std::string msg) throw() : exception(),
00099                                   exnum(NOTUSED),
00100                                   message (msg) {}
00101             inline YAPETException (std::string msg, EXNUM n) throw() : exception(),
00102                                        exnum(n),
00103                                        message (msg) {}
00104             inline YAPETException (const YAPETException& ex) throw() {
00105         exnum = ex.exnum;
00106                 message = ex.message;
00107             }
00108             inline virtual ~YAPETException() throw() { /* empty */ }
00109             inline const YAPETException& operator= (const YAPETException& ex)
00110             throw() {
00111                 if (this == &ex) return *this;
00112 
00113         exnum = ex.exnum;
00114                 message = ex.message;
00115                 return *this;
00116             }
00117             inline virtual const char* what() const throw() {
00118                 return message.c_str();
00119             }
00120         inline EXNUM getExNum() const throw() { return exnum; }
00121     };
00122 
00131     class YAPETRetryException : public YAPETException {
00132         public:
00133             inline YAPETRetryException()
00134             throw() : YAPETException (_ ("Retry") ) {}
00135             inline YAPETRetryException (std::string msg)
00136             throw() : YAPETException (msg) {}
00137             inline YAPETRetryException (const YAPETRetryException& ex)
00138             throw() : YAPETException (ex) {}
00139             inline virtual ~YAPETRetryException() throw() { /* Empty */ }
00140 
00141             inline const YAPETRetryException
00142             operator= (const YAPETRetryException& ex) throw() {
00143                 if (this == &ex) return *this;
00144 
00145                 YAPETException::operator= (ex);
00146                 return *this;
00147             }
00148     };
00149 
00156     class YAPETEncryptionException : public YAPETException {
00157         public:
00158             inline YAPETEncryptionException()
00159             throw() : YAPETException (_ ("Encryption error") ) {}
00160             inline YAPETEncryptionException (std::string msg)
00161             throw() : YAPETException (msg) {}
00162             inline YAPETEncryptionException (const YAPETEncryptionException& ex)
00163             throw() : YAPETException (ex) {}
00164             inline virtual ~YAPETEncryptionException() throw() { /* Empty */ }
00165 
00166             inline const YAPETEncryptionException
00167             operator= (const YAPETEncryptionException& ex) throw() {
00168                 if (this == &ex) return *this;
00169 
00170                 YAPETException::operator= (ex);
00171                 return *this;
00172             }
00173     };
00174 
00183     class YAPETInvalidPasswordException : public YAPETException {
00184         public:
00185             inline YAPETInvalidPasswordException()
00186             throw() : YAPETException (_ ("Invalid password") ) {}
00187             inline YAPETInvalidPasswordException (std::string msg)
00188             throw() : YAPETException (msg) {}
00189 
00190             inline
00191             YAPETInvalidPasswordException (const YAPETInvalidPasswordException& ex)
00192             throw() : YAPETException (ex) {}
00193             inline virtual ~YAPETInvalidPasswordException()
00194             throw() { /* Empty */ }
00195 
00196             inline const YAPETInvalidPasswordException
00197             operator= (const YAPETInvalidPasswordException& ex) throw() {
00198                 if (this == &ex) return *this;
00199 
00200                 YAPETException::operator= (ex);
00201                 return *this;
00202             }
00203     };
00204 
00205 }
00206 
00207 #endif // _YAPETEXCEPTION_H

Generated on Sun Sep 19 2010 15:37:13 for YAPET by  doxygen 1.7.1