SourceLocation Class

class QQmlSA::SourceLocation

Represents a location or region in the source code. More...

Header: #include <SourceLocation>
CMake: find_package(Qt6 REQUIRED COMPONENTS QmlCompiler)
target_link_libraries(mytarget PRIVATE Qt6::QmlCompiler)
Status: Technical Preview

Public Functions

SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)
SourceLocation(const QQmlSA::SourceLocation &other)
SourceLocation(QQmlSA::SourceLocation &&other)
~SourceLocation()
quint32 begin() const
quint32 end() const
QQmlSA::SourceLocation endZeroLengthLocation(QStringView text) const
bool isValid() const
quint32 length() const
quint32 offset() const
quint32 startColumn() const
quint32 startLine() const
QQmlSA::SourceLocation startZeroLengthLocation() const
QQmlSA::SourceLocation &operator=(QQmlSA::SourceLocation &&other)
QQmlSA::SourceLocation &operator=(const QQmlSA::SourceLocation &other)
qsizetype qHash(const QQmlSA::SourceLocation &location, qsizetype seed = 0)
bool operator!=(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs)
bool operator==(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs)

Detailed Description

Member Function Documentation

[explicit] SourceLocation::SourceLocation(quint32 offset = 0, quint32 length = 0, quint32 line = 0, quint32 column = 0)

Constructs a new SourceLocation with values given by offset, length, line, and column.

SourceLocation::SourceLocation(const QQmlSA::SourceLocation &other)

Creates a copy of other.

[noexcept] SourceLocation::SourceLocation(QQmlSA::SourceLocation &&other)

Move-Constructs a SourceLocation from other.

[noexcept] SourceLocation::~SourceLocation()

Destructs this SourceLocation instance.

quint32 SourceLocation::begin() const

Returns the offset of the beginning of this source location.

quint32 SourceLocation::end() const

Returns the offset of the end of this source location.

QQmlSA::SourceLocation SourceLocation::endZeroLengthLocation(QStringView text) const

Returns a source location of lenth zero pointing to the end of this source location pointing to text.

bool SourceLocation::isValid() const

Returns true is this SourceLocation is valid, false otherwise.

quint32 SourceLocation::length() const

Returns the length of this source location.

quint32 SourceLocation::offset() const

Returns the offset of the beginning of this source location.

quint32 SourceLocation::startColumn() const

Returns the column number containing the beginning of this source location.

quint32 SourceLocation::startLine() const

Returns the line number containing the beginning of this source location.

QQmlSA::SourceLocation SourceLocation::startZeroLengthLocation() const

Returns a source location of lenth zero pointing to the beginning of this source location.

[noexcept] QQmlSA::SourceLocation &SourceLocation::operator=(QQmlSA::SourceLocation &&other)

Move-assigns other to this SourceLocation.

QQmlSA::SourceLocation &SourceLocation::operator=(const QQmlSA::SourceLocation &other)

Assigns other to this SourceLocation.

Related Non-Members

qsizetype qHash(const QQmlSA::SourceLocation &location, qsizetype seed = 0)

Returns the hash value for location, using seed to seed the calculation.

bool operator!=(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs)

Returns true if lhs does not equal rhs, and false otherwise. See SourceLocation::operator== for when two source locations are considered equal.

bool operator==(const QQmlSA::SourceLocation &lhs, const QQmlSA::SourceLocation &rhs)

Returns true if lhs equals rhs, and false otherwise. Two SourceLocations are considered equal if they have the same values for their offset, length, line, and column members.

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.