Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-15 10:24:13

0001 // Copyright (C) 2016 The Qt Company Ltd.
0002 // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
0003 
0004 #ifndef QTCORE_QEXCEPTION_H
0005 #define QTCORE_QEXCEPTION_H
0006 
0007 #include <QtCore/qatomic.h>
0008 #include <QtCore/qshareddata.h>
0009 
0010 #ifndef QT_NO_EXCEPTIONS
0011 #  include <exception>
0012 #endif
0013 
0014 QT_REQUIRE_CONFIG(future);
0015 
0016 QT_BEGIN_NAMESPACE
0017 
0018 
0019 #if !defined(QT_NO_EXCEPTIONS) || defined(Q_QDOC)
0020 
0021 class Q_CORE_EXPORT QException : public std::exception
0022 {
0023 public:
0024     QException() = default;
0025     ~QException() noexcept;
0026     QException(const QException &) = default;
0027     QException &operator=(const QException &) = default;
0028     virtual void raise() const;
0029     virtual QException *clone() const;
0030 };
0031 
0032 class QUnhandledExceptionPrivate;
0033 class Q_CORE_EXPORT QUnhandledException final : public QException
0034 {
0035 public:
0036     QUnhandledException(std::exception_ptr exception = nullptr) noexcept;
0037     ~QUnhandledException() noexcept override;
0038 
0039     QUnhandledException(QUnhandledException &&other) noexcept;
0040     QUnhandledException(const QUnhandledException &other) noexcept;
0041 
0042     void swap(QUnhandledException &other) noexcept { d.swap(other.d); }
0043 
0044     QT_MOVE_ASSIGNMENT_OPERATOR_IMPL_VIA_PURE_SWAP(QUnhandledException)
0045     QUnhandledException &operator=(const QUnhandledException &other) noexcept;
0046 
0047     void raise() const override;
0048     QUnhandledException *clone() const override;
0049 
0050     std::exception_ptr exception() const;
0051 
0052 private:
0053     QSharedDataPointer<QUnhandledExceptionPrivate> d;
0054 };
0055 
0056 namespace QtPrivate {
0057 
0058 class Q_CORE_EXPORT ExceptionStore
0059 {
0060 public:
0061     void setException(const QException &e);
0062     void setException(std::exception_ptr e);
0063     bool hasException() const;
0064     std::exception_ptr exception() const;
0065     void throwPossibleException();
0066     Q_NORETURN void rethrowException() const;
0067     std::exception_ptr exceptionHolder;
0068 };
0069 
0070 } // namespace QtPrivate
0071 
0072 #else // QT_NO_EXCEPTIONS
0073 
0074 namespace QtPrivate {
0075 
0076 class Q_CORE_EXPORT ExceptionStore
0077 {
0078 public:
0079     ExceptionStore() { }
0080     inline void throwPossibleException() {}
0081     inline void rethrowException() const { }
0082 };
0083 
0084 } // namespace QtPrivate
0085 
0086 #endif // QT_NO_EXCEPTIONS
0087 
0088 QT_END_NAMESPACE
0089 
0090 #endif