1// Copyright (C) 2016 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#ifndef QSYSTEMERROR_P_H
5#define QSYSTEMERROR_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtCore/private/qglobal_p.h>
19#include <qstring.h>
20
21QT_BEGIN_NAMESPACE
22
23class QSystemError
24{
25public:
26 enum ErrorScope
27 {
28 NoError,
29 StandardLibraryError,
30 NativeError
31 };
32
33 constexpr explicit QSystemError(int error, ErrorScope scope)
34 : errorCode(error), errorScope(scope)
35 {
36 }
37 constexpr QSystemError() = default;
38
39 QString toString() const { return string(errorScope, errorCode); }
40 constexpr ErrorScope scope() const { return errorScope; }
41 constexpr int error() const { return errorCode; }
42
43 static Q_CORE_EXPORT QString string(ErrorScope errorScope, int errorCode);
44 static Q_CORE_EXPORT QString stdString(int errorCode = -1);
45#ifdef Q_OS_WIN
46 static Q_CORE_EXPORT QString windowsString(int errorCode = -1);
47 using HRESULT = long;
48 static Q_CORE_EXPORT QString windowsComString(HRESULT hr);
49#endif
50
51 // data members
52 int errorCode = 0;
53 ErrorScope errorScope = NoError;
54};
55
56QT_END_NAMESPACE
57
58#endif // QSYSTEMERROR_P_H
59

source code of qtbase/src/corelib/kernel/qsystemerror_p.h