Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qqmlsasourcelocation.h
Go to the documentation of this file.
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 QQMLSASOURCELOCATION_H
5#define QQMLSASOURCELOCATION_H
6
7#include <QtQmlCompiler/qtqmlcompilerexports.h>
8
9#include <QtCore/qstringview.h>
10
12
13namespace QQmlJS {
14class SourceLocation;
15} // namespace QQmlJS
16
17namespace QQmlSA {
18
19class SourceLocationPrivate;
20
21class Q_QMLCOMPILER_EXPORT SourceLocation
22{
23 friend class QT_PREPEND_NAMESPACE(QQmlSA::SourceLocationPrivate);
24
25public:
26 explicit SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0,
27 quint32 column = 0);
28 SourceLocation(const SourceLocation &);
29 SourceLocation(SourceLocation &&other) noexcept
30 {
31 memcpy(m_data, other.m_data, sizeofSourceLocation);
32 memset(other.m_data, 0, sizeofSourceLocation);
33 }
36 {
37 memcpy(m_data, other.m_data, sizeofSourceLocation);
38 memset(other.m_data, 0, sizeofSourceLocation);
39 return *this;
40 }
42
43 bool isValid() const;
44
45 quint32 begin() const;
46 quint32 end() const;
47
48 quint32 offset() const;
49 quint32 length() const;
50 quint32 startLine() const;
51 quint32 startColumn() const;
52
53 SourceLocation startZeroLengthLocation() const;
54 SourceLocation endZeroLengthLocation(QStringView text) const;
55
57 {
58 return qHashImpl(location, seed);
59 }
60
61 friend bool operator==(const SourceLocation &lhs, const SourceLocation &rhs)
62 {
63 return operatorEqualsImpl(lhs, rhs);
64 }
65
66 friend bool operator!=(const SourceLocation &lhs, const SourceLocation &rhs)
67 {
68 return !(lhs == rhs);
69 }
70
71private:
72 static qsizetype qHashImpl(const SourceLocation &location, qsizetype seed);
73 static bool operatorEqualsImpl(const SourceLocation &, const SourceLocation &);
74
75 static constexpr qsizetype sizeofSourceLocation = 4 * sizeof(quint32);
76 alignas(int) char m_data[sizeofSourceLocation] = {};
77};
78
79} // namespace QQmlSA
80
82
83#endif // QQMLSASOURCELOCATION_H
NSData * m_data
\inmodule QtQmlCompiler
friend bool operator!=(const SourceLocation &lhs, const SourceLocation &rhs)
friend qsizetype qHash(const SourceLocation &location, qsizetype seed=0)
SourceLocation & operator=(SourceLocation &&other) noexcept
SourceLocation & operator=(const SourceLocation &)
friend bool operator==(const SourceLocation &lhs, const SourceLocation &rhs)
\inmodule QtCore
Definition qstringview.h:78
QString text
\inmodule QtQmlCompiler
Combined button and popup list for selecting options.
GLint location
GLuint GLuint end
GLenum GLuint GLenum GLsizei length
GLenum GLuint GLintptr offset
static Q_CONSTINIT QBasicAtomicInteger< unsigned > seed
Definition qrandom.cpp:196
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
unsigned int quint32
Definition qtypes.h:50
ptrdiff_t qsizetype
Definition qtypes.h:165
#define explicit
QSharedPointer< T > other(t)
[5]