Akonadi

exceptionbase.h
1 /*
2  Copyright (c) 2009 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef AKONADI_EXCEPTIONBASE_H
21 #define AKONADI_EXCEPTIONBASE_H
22 
23 #include "akonadicore_export.h"
24 
25 #include <QByteArray>
26 
27 #include <exception>
28 #include <memory>
29 
30 class QString;
31 
32 namespace Akonadi
33 {
34 
35 #ifdef _MSC_VER
36 #pragma warning(push)
37 #pragma warning(disable: 4275) // we are exporting a subclass of an unexported class, MSVC complains
38 #endif
39 
43 class AKONADICORE_EXPORT Exception : public std::exception //krazy:exclude=dpointer
44 {
45 public:
49  explicit Exception(const char *what);
50 
54  explicit Exception(const QByteArray &what);
55 
59  explicit Exception(const QString &what);
60 
64  Exception(const Exception &other);
65 
66  Exception(Exception &&other);
67 
71  ~Exception() override;
72 
76  const char *what() const noexcept override;
77 
81  virtual QByteArray type() const; // ### Akonadi 2: return const char *
82 
83 private:
84  class Private;
85  std::unique_ptr<Private> d;
86 };
87 #ifdef _MSC_VER
88 #pragma warning(pop)
89 #endif
90 
91 #define AKONADI_EXCEPTION_MAKE_TRIVIAL_INSTANCE(classname) \
92  class AKONADICORE_EXPORT classname : public Akonadi::Exception \
93  { \
94  public: \
95  explicit classname(const char *what): Akonadi::Exception(what) {} \
96  explicit classname(const QByteArray &what): Akonadi::Exception(what) {} \
97  explicit classname(const QString &what): Akonadi::Exception(what) {} \
98  ~classname() override; \
99  QByteArray type() const override; \
100  }
101 
102 AKONADI_EXCEPTION_MAKE_TRIVIAL_INSTANCE(PayloadException);
103 
104 #undef AKONADI_EXCEPTION_MAKE_TRIVIAL_INSTANCE
105 
106 }
107 
108 #endif
Helper integration between Akonadi and Qt.
Base class for exceptions used by the Akonadi library.
Definition: exceptionbase.h:43
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Sat May 30 2020 22:46:09 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.