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
qqmlsasourcelocation.cpp
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
// Qt-Security score:significant
4
5
#
include
"qqmlsasourcelocation.h"
6
#
include
"qqmlsasourcelocation_p.h"
7
8
QT_BEGIN_NAMESPACE
9
10
using
namespace
Qt::StringLiterals;
11
12
namespace
QQmlSA
{
13
14
static_assert
(SourceLocationPrivate::sizeOfSourceLocation() ==
sizeof
(
SourceLocation
));
15
16
/*!
17
\class QQmlSA::SourceLocation
18
\inmodule QtQmlCompiler
19
20
\brief Represents a location or region in the source code.
21
*/
22
23
/*!
24
Constructs a new SourceLocation with values given by \a offset, \a length,
25
\a line, and \a column.
26
*/
27
QQmlSA
::
SourceLocation
::
SourceLocation
(
quint32
offset
,
quint32
length
,
quint32
line
,
quint32
column
)
28
{
29
new
(
m_data
)
QQmlJS
::
SourceLocation
{
offset
,
length
,
line
,
column
};
30
}
31
32
// explicitly defaulted out-of-line for PIMPL
33
/*!
34
Creates a copy of \a other.
35
*/
36
QQmlSA
::
SourceLocation
::
SourceLocation
(
const
SourceLocation
&
other
) =
default
;
37
38
/*!
39
\fn SourceLocation::SourceLocation(SourceLocation &&other) noexcept
40
Move-Constructs a SourceLocation from \a other.
41
*/
42
43
/*!
44
Assigns \a other to this SourceLocation.
45
*/
46
QQmlSA
::
SourceLocation
&
QQmlSA
::
SourceLocation
::
operator
=(
const
QQmlSA
::
SourceLocation
&
other
) =
default
;
47
48
/*!
49
\fn SourceLocation &SourceLocation::operator=(SourceLocation &&other) noexcept
50
Move-assigns \a other to this SourceLocation.
51
*/
52
53
/*!
54
Destructs this SourceLocation instance.
55
*/
56
SourceLocation
::~
SourceLocation
() =
default
;
57
58
/*!
59
Returns \c true is this SourceLocation is valid, \c false otherwise.
60
*/
61
bool
QQmlSA
::
SourceLocation
::
isValid
()
const
62
{
63
return
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(*
this
).
isValid
();
64
}
65
66
/*!
67
Returns the offset of the beginning of this source location.
68
*/
69
quint32
QQmlSA
::
SourceLocation
::
begin
()
const
70
{
71
return
offset
();
72
}
73
74
/*!
75
Returns the offset of the end of this source location.
76
*/
77
quint32
QQmlSA
::
SourceLocation
::
end
()
const
78
{
79
return
offset
() +
length
();
80
}
81
82
/*!
83
Returns the offset of the beginning of this source location.
84
*/
85
quint32
QQmlSA
::
SourceLocation
::
offset
()
const
86
{
87
return
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(*
this
).
offset
;
88
}
89
90
/*!
91
Returns the length of this source location.
92
*/
93
quint32
QQmlSA
::
SourceLocation
::
length
()
const
94
{
95
return
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(*
this
).
length
;
96
}
97
98
/*!
99
Returns the line number containing the beginning of this source location.
100
*/
101
quint32
QQmlSA
::
SourceLocation
::
startLine
()
const
102
{
103
return
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(*
this
).
startLine
;
104
}
105
106
/*!
107
Returns the column number containing the beginning of this source location.
108
*/
109
quint32
QQmlSA
::
SourceLocation
::
startColumn
()
const
110
{
111
return
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(*
this
).
startColumn
;
112
}
113
114
/*!
115
Returns a source location of lenth zero pointing to the beginning of this
116
source location.
117
*/
118
QQmlSA
::
SourceLocation
QQmlSA
::
SourceLocation
::
startZeroLengthLocation
()
const
119
{
120
QQmlSA
::
SourceLocation
saLocation
;
121
auto
&
wrappedLocation
=
reinterpret_cast
<
QQmlJS
::
SourceLocation
&>(
saLocation
.
m_data
);
122
wrappedLocation
=
123
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(*
this
).
startZeroLengthLocation
();
124
125
return
saLocation
;
126
}
127
128
/*!
129
Returns a source location of lenth zero pointing to the end of this source
130
location pointing to \a text.
131
*/
132
QQmlSA
::
SourceLocation
QQmlSA
::
SourceLocation
::
endZeroLengthLocation
(
QStringView
text
)
const
133
{
134
QQmlSA
::
SourceLocation
saLocation
;
135
auto
&
wrappedLocation
=
reinterpret_cast
<
QQmlJS
::
SourceLocation
&>(
saLocation
.
m_data
);
136
wrappedLocation
=
wrappedLocation
.
endZeroLengthLocation
(
text
);
137
138
return
saLocation
;
139
}
140
141
/*!
142
\fn friend qsizetype SourceLocation::qHash(const SourceLocation &location, qsizetype seed)
143
Returns the hash value for \a location, using \a seed to seed the calculation.
144
*/
145
146
/*!
147
\fn friend bool SourceLocation::operator==(const SourceLocation &lhs, const SourceLocation &rhs)
148
Returns true if \a lhs equals \a rhs, and \c false otherwise.
149
Two SourceLocations are considered equal if they have the same values for
150
their offset, length, line, and column members.
151
*/
152
/*!
153
\fn friend bool SourceLocation::operator!=(const SourceLocation &lhs, const SourceLocation &rhs)
154
Returns true if \a lhs does not equal \a rhs, and \c false otherwise.
155
See \l {SourceLocation::operator==} for when two source locations are considered equal.
156
*/
157
158
qsizetype
QQmlSA
::
SourceLocation
::
qHashImpl
(
const
SourceLocation
&
location
,
qsizetype
seed
)
159
{
160
return
qHash
(
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(
location
),
seed
);
161
}
162
163
bool
QQmlSA
::
SourceLocation
::
operatorEqualsImpl
(
const
SourceLocation
&
lhs
,
164
const
SourceLocation
&
rhs
)
165
{
166
return
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(
lhs
)
167
==
QQmlSA
::
SourceLocationPrivate
::
sourceLocation
(
rhs
);
168
}
169
170
}
// namespace QQmlSA
171
172
QT_END_NAMESPACE
QQmlSA::SourceLocation
\inmodule QtQmlCompiler
Definition
qqmlsasourcelocation.h:23
QPlatformGraphicsBufferHelper
\inmodule QtGui
QQmlSA
\inmodule QtQmlCompiler
Definition
qqmljsscope_p.h:700
qtdeclarative
src
qmlcompiler
qqmlsasourcelocation.cpp
Generated on
for Qt by
1.14.0