| 1 | // Copyright (C) 2021 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | |
| 4 | // |
| 5 | // W A R N I N G |
| 6 | // ------------- |
| 7 | // |
| 8 | // This file is not part of the Qt API. It exists purely as an |
| 9 | // implementation detail. This header file may change from version to |
| 10 | // version without notice, or even be removed. |
| 11 | // |
| 12 | // We mean it. |
| 13 | // |
| 14 | |
| 15 | #ifndef QOPCUAX509UTILS_H |
| 16 | #define QOPCUAX509UTILS_H |
| 17 | |
| 18 | #include <functional> |
| 19 | #include <QString> |
| 20 | #include <private/qglobal_p.h> |
| 21 | |
| 22 | QT_BEGIN_NAMESPACE |
| 23 | |
| 24 | template <typename T> |
| 25 | class Deleter |
| 26 | { |
| 27 | public: |
| 28 | Deleter(T *data, std::function<void(T *value)> f) |
| 29 | : m_data(data) |
| 30 | , m_function(f) |
| 31 | { |
| 32 | } |
| 33 | ~Deleter() |
| 34 | { |
| 35 | if (m_data) |
| 36 | m_function(m_data); |
| 37 | } |
| 38 | void release() |
| 39 | { |
| 40 | m_data = nullptr; |
| 41 | m_function = nullptr; |
| 42 | } |
| 43 | private: |
| 44 | T *m_data {nullptr}; |
| 45 | std::function<void(T *attribute)> m_function; |
| 46 | }; |
| 47 | |
| 48 | QString getOpenSslError(); |
| 49 | |
| 50 | QT_END_NAMESPACE |
| 51 | |
| 52 | #endif // QOPCUAX509UTILS_H |
| 53 | |