1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef QQMLJSLOGGINGUTILS_P_H
5#define QQMLJSLOGGINGUTILS_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/qstring.h>
19#include <private/qtqmlcompilerexports_p.h>
20
21#include "qqmljsloggingutils.h"
22
23QT_BEGIN_NAMESPACE
24
25namespace QQmlJS {
26
27using LoggerWarningId = QQmlSA::LoggerWarningId;
28
29class LoggerCategoryPrivate;
30
31class Q_QMLCOMPILER_EXPORT LoggerCategory
32{
33 Q_DECLARE_PRIVATE(LoggerCategory)
34
35public:
36 LoggerCategory();
37 LoggerCategory(QString name, QString settingsName, QString description, QtMsgType level,
38 bool ignored = false, bool isDefault = false);
39 LoggerCategory(const LoggerCategory &);
40 LoggerCategory(LoggerCategory &&) noexcept;
41 LoggerCategory &operator=(const LoggerCategory &);
42 LoggerCategory &operator=(LoggerCategory &&) noexcept;
43 ~LoggerCategory();
44
45 QString name() const;
46 QString settingsName() const;
47 QString description() const;
48 QtMsgType level() const;
49 bool isIgnored() const;
50 bool isDefault() const;
51
52 LoggerWarningId id() const;
53
54 void setLevel(QtMsgType);
55 void setIgnored(bool);
56
57private:
58 std::unique_ptr<QQmlJS::LoggerCategoryPrivate> d_ptr;
59};
60
61class LoggerCategoryPrivate
62{
63 friend class QT_PREPEND_NAMESPACE(QQmlJS::LoggerCategory);
64
65public:
66 LoggerWarningId id() const { return LoggerWarningId(m_name); }
67
68 void setLevel(QtMsgType);
69 void setIgnored(bool);
70
71 QString name() const;
72 QString settingsName() const;
73 QString description() const;
74 QtMsgType level() const;
75 bool isIgnored() const;
76 bool isDefault() const;
77 bool hasChanged() const;
78
79 static LoggerCategoryPrivate *get(LoggerCategory *);
80
81 friend bool operator==(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
82 {
83 return operatorEqualsImpl(lhs, rhs);
84 }
85 friend bool operator!=(const LoggerCategoryPrivate &lhs, const LoggerCategoryPrivate &rhs)
86 {
87 return !operatorEqualsImpl(lhs, rhs);
88 }
89
90 bool operator==(const LoggerWarningId warningId) const { return warningId.name() == m_name; }
91
92private:
93 static bool operatorEqualsImpl(const LoggerCategoryPrivate &, const LoggerCategoryPrivate &);
94
95 QString m_name;
96 QString m_settingsName;
97 QString m_description;
98 QtMsgType m_level;
99 bool m_ignored = false;
100 bool m_isDefault = false; // Whether or not the category can be disabled
101 bool m_changed = false;
102};
103
104} // namespace QQmlJS
105
106QT_END_NAMESPACE
107
108#endif // QQMLJSLOGGINGUTILS_P_H
109

source code of qtdeclarative/src/qmlcompiler/qqmljsloggingutils_p.h