Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qqmlprofilereventlocation_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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// Qt-Security score:significant
4
5#ifndef QQMLPROFILEREVENTLOCATION_P_H
6#define QQMLPROFILEREVENTLOCATION_P_H
7
8#include <QtCore/qstring.h>
9#include <QtCore/qhash.h>
10#include <QtCore/qdatastream.h>
11#include <QtCore/private/qglobal_p.h>
12
13//
14// W A R N I N G
15// -------------
16//
17// This file is not part of the Qt API. It exists purely as an
18// implementation detail. This header file may change from version to
19// version without notice, or even be removed.
20//
21// We mean it.
22//
23
25
26class QQmlProfilerEventLocation
27{
28public:
29 QQmlProfilerEventLocation() : m_line(-1),m_column(-1) {}
30 QQmlProfilerEventLocation(const QString &file, int lineNumber, int columnNumber) :
31 m_filename(file), m_line(lineNumber), m_column(columnNumber)
32 {}
33
34 void clear()
35 {
36 m_filename.clear();
37 m_line = m_column = -1;
38 }
39
40 bool isValid() const
41 {
42 return !m_filename.isEmpty();
43 }
44
45 QString filename() const { return m_filename; }
46 int line() const { return m_line; }
47 int column() const { return m_column; }
48
49private:
50 friend QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventLocation &location);
51 friend QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventLocation &location);
52
53 QString m_filename;
54 int m_line;
55 int m_column;
56};
57
58inline bool operator==(const QQmlProfilerEventLocation &location1,
59 const QQmlProfilerEventLocation &location2)
60{
61 // compare filename last as it's expensive.
62 return location1.line() == location2.line() && location1.column() == location2.column()
63 && location1.filename() == location2.filename();
64}
65
66inline bool operator!=(const QQmlProfilerEventLocation &location1,
67 const QQmlProfilerEventLocation &location2)
68{
69 return !(location1 == location2);
70}
71
72inline size_t qHash(const QQmlProfilerEventLocation &location)
73{
74 return qHash(location.filename())
75 ^ ((location.line() & 0xfff) // 12 bits of line number
76 | ((location.column() << 16) & 0xff0000)); // 8 bits of column
77
78}
79
80QDataStream &operator>>(QDataStream &stream, QQmlProfilerEventLocation &location);
81QDataStream &operator<<(QDataStream &stream, const QQmlProfilerEventLocation &location);
82
83Q_DECLARE_TYPEINFO(QQmlProfilerEventLocation, Q_RELOCATABLE_TYPE);
84
85QT_END_NAMESPACE
86
87#endif // QQMLPROFILEREVENTLOCATION_P_H
void setFlushInterval(quint32 flushInterval)
quint64 recordedFeatures() const
void traceFinished(qint64 timestamp, const QList< int > &engineIds)
void setRequestedFeatures(quint64 features)
void recordedFeaturesChanged(quint64 features)
void traceStarted(qint64 timestamp, const QList< int > &engineIds)
virtual void messageReceived(const QByteArray &) override
void recordingChanged(bool arg)
QQmlProfilerClient(QQmlProfilerClientPrivate &dd)
void onStateChanged(State status)
void sendRecordingStatus(int engineId=-1)
Combined button and popup list for selecting options.
QDataStream & operator<<(QDataStream &stream, const QQmlProfilerEventLocation &location)
size_t qHash(const QQmlProfilerEventLocation &location)
Q_DECLARE_TYPEINFO(QQmlProfilerEventLocation, Q_RELOCATABLE_TYPE)
bool operator!=(const QQmlProfilerEventLocation &location1, const QQmlProfilerEventLocation &location2)
bool operator==(const QQmlProfilerEventLocation &location1, const QQmlProfilerEventLocation &location2)
QDataStream & operator>>(QDataStream &stream, QQmlProfilerEventLocation &location)