GammaRay API Documentation  2.11.3
Public Member Functions | Static Public Member Functions | List of all members
GammaRay::SourceLocation Class Reference

Specifies a source code location. More...

#include <sourcelocation.h>

Public Member Functions

 SourceLocation ()=default
 The default constructor creates a (invalid) cursor at position (-1, -1) with an invalid url.
 
 SourceLocation (const QUrl &url)
 This constructor creates a (valid) cursor at position (0, 0) with url.
 
int column () const
 Returns the zero-based column number.
 
QString displayString () const
 Returns a human-readable version of this source location. More...
 
bool isValid () const
 
int line () const
 Returns the zero-based line number.
 
bool operator== (const SourceLocation &other) const
 
void setOneBasedColumn (int column)
 
void setOneBasedLine (int line)
 
void setUrl (const QUrl &url)
 
void setZeroBasedColumn (int column)
 
void setZeroBasedLine (int line)
 
QUrl url () const
 

Static Public Member Functions

static SourceLocation fromOneBased (const QUrl &url, int line, int column=1)
 
static SourceLocation fromZeroBased (const QUrl &url, int line, int column=0)
 

Detailed Description

Specifies a source code location.

A source location consists of a document and cursor position

A Cursor represents a position in a Document through a tuple of two ints, namely the line() and column().

Note
Lines and columns start a 0 (=> zero-based numbering).

Member Function Documentation

◆ displayString()

QString GammaRay::SourceLocation::displayString ( ) const

Returns a human-readable version of this source location.

SourceLocation loc(QUrl::fromLocalFile("file.cpp", 0, 0);
qDebug() << loc.displayString();
=> Prints: file.cpp:1:1
Note
This will use one-based numbering (file.cpp:1:1 instead of file.cpp:0:0)
QUrl::fromLocalFile
QUrl fromLocalFile(const QString &localFile)
GammaRay::SourceLocation::SourceLocation
SourceLocation()=default
The default constructor creates a (invalid) cursor at position (-1, -1) with an invalid url.

© 2010-2021 Klarälvdalens Datakonsult AB (KDAB)
"The Qt, C++ and OpenGL Experts"
https://www.kdab.com/
GammaRay Qt-application inspection and manipulation tool
https://www.kdab.com/development-resources/qt-tools/gammaray/
Generated on Wed Mar 15 2023 01:05:10 for GammaRay API Documentation by doxygen 1.8.20