QSourceLocation Class

The QSourceLocation class identifies a location in a resource by URI, line, and column. 更多...

头: #include <QSourceLocation>
qmake: QT += xmlpatterns
Since: Qt 4.4

该类在 Qt 4.4 引入。

注意: 此类的所有函数 可重入 .

公共函数

QSourceLocation (const QUrl & u , int l = -1, int c = -1)
QSourceLocation (const QSourceLocation & other )
QSourceLocation ()
QSourceLocation & operator= (const QSourceLocation & other )
~QSourceLocation ()
qint64 column () const
bool isNull () const
qint64 line () const
void setColumn (qint64 newColumn )
void setLine (qint64 newLine )
void setUri (const QUrl & newUri )
QUrl uri () const
bool operator!= (const QSourceLocation & other ) const
bool operator== (const QSourceLocation & other ) const
uint qHash (const QSourceLocation & location )
QDebug operator<< (QDebug debug , const QSourceLocation & sourceLocation )

详细描述

QSourceLocation is a simple value based class that has three properties, uri (), line (),和 column (), that, taken together, identify a certain point in a resource, e.g., a file or an in-memory document.

line () 和 column () refer to character counts (not byte counts), and they both start from 1, as opposed to 0.

成员函数文档编制

QSourceLocation:: QSourceLocation (const QUrl & u , int l = -1, int c = -1)

Constructs a QSourceLocation with URI u , line l and column c .

QSourceLocation:: QSourceLocation (const QSourceLocation & other )

Constructs a QSourceLocation that is a copy of other .

QSourceLocation:: QSourceLocation ()

Construct a QSourceLocation that doesn't identify anything at all.

For a default constructed QSourceLocation(), isNull () 返回 true .

QSourceLocation &QSourceLocation:: operator= (const QSourceLocation & other )

Assigns this QSourceLocation instance to other .

QSourceLocation:: ~QSourceLocation ()

析构函数。

qint64 QSourceLocation:: column () const

Returns the current column number. The column number refers to the count of characters, not bytes. The first column is column 1, not 0. The default value is -1, indicating the column number is unknown.

另请参阅 setColumn ().

bool QSourceLocation:: isNull () const

返回 true 若此 QSourceLocation doesn't identify anything.

For a default constructed QSourceLocation ,此函数返回 true . The same applies for any other QSourceLocation whose uri () is invalid.

qint64 QSourceLocation:: line () const

Returns the current line number. The first line number is 1, not 0. The default value is -1, indicating the line number is unknown.

另请参阅 setLine ().

void QSourceLocation:: setColumn ( qint64 newColumn )

Sets the column number to newColumn . 0 is an invalid column number. The first column number is 1.

另请参阅 column ().

void QSourceLocation:: setLine ( qint64 newLine )

Sets the line number to newLine . 0 is an invalid line number. The first line number is 1.

另请参阅 line ().

void QSourceLocation:: setUri (const QUrl & newUri )

Sets the URI to newUri .

另请参阅 uri ().

QUrl QSourceLocation:: uri () const

Returns the resource that this QSourceLocation refers to. For example, the resource could be a file in the local file system, if the URI scheme is file .

另请参阅 setUri ().

bool QSourceLocation:: operator!= (const QSourceLocation & other ) const

返回 true 若此 QSourceLocation 不等于 other ; false 否则。

bool QSourceLocation:: operator== (const QSourceLocation & other ) const

返回 true 若此 QSourceLocation 等于 other ; false 否则。

Two QSourceLocation instances are equal if their uri (), line () 和 column () are equal.

QSourceLocation instances for which isNull () returns true are considered equal.

相关非成员

uint qHash (const QSourceLocation & location )

Computes a hash key for the QSourceLocation location .

该函数在 Qt 4.4 引入。

QDebug operator<< ( QDebug debug , const QSourceLocation & sourceLocation )

Prints sourceLocation to the debug stream debug .

该函数在 Qt 4.4 引入。