exception.h

00001 /*
00002     Copyright (c) 2009 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00019 
00020 #ifndef AKONADI_EXCEPTION_H
00021 #define AKONADI_EXCEPTION_H
00022 
00023 #include "akonadi_export.h"
00024 
00025 #include <QtCore/QByteArray>
00026 #include <exception>
00027 
00028 class QString;
00029 
00030 namespace Akonadi {
00031 
00035 class AKONADI_EXPORT Exception : public std::exception
00036 {
00037   public:
00041     Exception( const char *what ) throw();
00042 
00046     Exception( const QByteArray &what ) throw();
00047 
00051     Exception( const QString &what ) throw();
00052 
00056     Exception( const Exception &other ) throw();
00057 
00061     virtual ~Exception() throw();
00062 
00066     const char* what() const throw();
00067 
00071     virtual QByteArray type() const throw();
00072 
00073   private:
00074     class Private;
00075     Private * const d;
00076 };
00077 
00078 #define AKONADI_EXCEPTION_MAKE_TRIVIAL_INSTANCE( classname ) \
00079 class classname : public Akonadi::Exception \
00080 { \
00081   public: \
00082     classname ( const char *what ) throw() : Akonadi::Exception( what ) {} \
00083     classname ( const QByteArray &what ) throw() : Akonadi::Exception( what ) {} \
00084     classname ( const QString &what ) throw() : Akonadi::Exception( what ) {} \
00085     QByteArray type() const throw() { return QByteArray( "Akonadi::" #classname ); } \
00086 }
00087 
00088 AKONADI_EXCEPTION_MAKE_TRIVIAL_INSTANCE( PayloadException );
00089 
00090 #undef AKONADI_EXCEPTION_MAKE_TRIVIAL_INSTANCE
00091 
00092 }
00093 
00094 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys