|  | Home · All Classes · Main Classes · Grouped Classes · Modules · Functions |

# QSourceLocation Class Reference
[QtXmlPatterns module]

The QSourceLocation class is used to identify a location in a resource, using a URI, line number and column number. More...

     #include <QSourceLocation>

Note: All the functions in this class are reentrant.

This class was introduced in Qt 4.4.

- List of all members, including inherited members

### Public Functions

- QSourceLocation ()
- QSourceLocation ( const QSourceLocation & other )
- QSourceLocation ( const QUrl & u, int l = -1, int c = -1 )
- ~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
- QSourceLocation & operator= ( const QSourceLocation & other )
- bool operator== ( const QSourceLocation & other ) const

### Related Non-Members

- uint qHash ( const QSourceLocation & location )
- QDebug operator<< ( QDebug debug, const QSourceLocation & sourceLocation )

## Detailed Description

The QSourceLocation class is used to identify a location in a resource, using a URI, line number and column number.

QSourceLocation is a simple value based class that has three properties, uri(), line(), and column(), that together identifies a certain point in a resource, such as a file or an in-memory document.

line() and column() refer to character count(not for instance byte count) and they both starts from 1, as opposed to 0.

## Member Function Documentation

### QSourceLocation::QSourceLocation ()

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

For a default constructed QSourceLocation(), isNull() returns `true`.

### QSourceLocation::QSourceLocation ( const QSourceLocation & other )

Constructs a QSourceLocation instance that is a copy of other.

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

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

### QSourceLocation::~QSourceLocation ()

Destructs this QSourceLocation instance.

### qint64 QSourceLocation::column () const

Returns the current column number. The column number refers to the count of characters, not bytes.

The first column has number 1, not 0.

The default value is -1, signalling that the column number is unknown.

See also setColumn().

### bool QSourceLocation::isNull () const

Returns `true` if this QSourceLocation doesn't identify anything.

For instance, for a default constructed QSourceLocation this function returns `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, signalling that the line number is unknown.

See also setLine().

### void QSourceLocation::setColumn ( qint64 newColumn )

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

See also column().

### void QSourceLocation::setLine ( qint64 newLine )

Sets the line number to newLine.

See also line().

### void QSourceLocation::setUri ( const QUrl & newUri )

Sets the URI to newUri.

See also uri().

### QUrl QSourceLocation::uri () const

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

See also setUri().

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

Returns the opposite of applying operator==() for this QXmlName and other.

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

Assigns this QSourceLocation instance to other.

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

Returns true if this QSourceLocation is identical to other.

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

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

## Related Non-Members

### uint qHash ( const QSourceLocation & location )

Computes a hash key for the QSourceLocation location.

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

This is an overloaded member function, provided for convenience.

Prints sourceLocation to the debug stream debug.