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
Location Class Reference

The Location class provides a way to mark a location in a file. More...

#include <location.h>

+ Collaboration diagram for Location:

Public Member Functions

 Location ()
 Constructs an empty location.
 
 Location (const QString &filePath)
 Constructs a location with (fileName, 1, 1) on its file position stack.
 
 Location (const Location &other)
 The copy constructor copies the contents of other into this Location using the assignment operator.
 
 ~Location ()
 
Locationoperator= (const Location &other)
 The assignment operator does a deep copy of the entire state of other into this Location.
 
void start ()
 If the file position on top of the stack has a line number less than 1, set its line number to 1 and its column number to 1.
 
void advance (QChar ch)
 Advance the current file position, using ch to decide how to do that.
 
void advanceLines (int n)
 
void push (const QString &filePath)
 Pushes filePath onto the file position stack.
 
void pop ()
 Pops the top of the internal stack.
 
void setEtc (bool etc)
 
void setLineNo (int no)
 
void setColumnNo (int no)
 
bool isEmpty () const
 Returns true if there is no file name set yet; returns false otherwise.
 
int depth () const
 
const QStringfilePath () const
 Returns the current path and file name.
 
QString fileName () const
 Returns the file name part of the file path, ie the current file.
 
QString fileSuffix () const
 Returns the suffix of the file name.
 
int lineNo () const
 Returns the current line number.
 
int columnNo () const
 Returns the current column number.
 
bool etc () const
 
QString toString () const
 Converts the location to a string to be prepended to error messages.
 
void warning (const QString &message, const QString &details=QString()) const
 Writes message and details to stderr as a formatted warning message.
 
void error (const QString &message, const QString &details=QString()) const
 Writes message and details to stderr as a formatted error message.
 
void fatal (const QString &message, const QString &details=QString()) const
 Writes message and details to stderr as a formatted error message and then exits the program.
 
void report (const QString &message, const QString &details=QString()) const
 Writes message and details to stderr as a formatted report message.
 

Static Public Member Functions

static void initialize ()
 Gets several parameters from the config, including tab size, program name, and a regular expression that appears to be used for matching certain error messages so that emitMessage() can avoid printing them.
 
static void terminate ()
 Apparently, all this does is delete the regular expression used for intercepting certain error messages that should not be emitted by emitMessage().
 
static void information (const QString &message)
 Prints message to stdout followed by a {'
'}.
 
static void internalError (const QString &hint)
 Report a program bug, including the hint.
 
static int exitCode ()
 Returns the error code QDoc should exit with; EXIT_SUCCESS or the number of documentation warnings if they exceeded the limit set by warninglimit configuration variable.
 

Friends

class QTypeInfo< StackEntry >
 

Detailed Description

The Location class provides a way to mark a location in a file.

It maintains a stack of file positions. A file position consists of the file path, line number, and column number. The location is used for printing error messages that are tied to a location in a file.

Definition at line 14 of file location.h.

Constructor & Destructor Documentation

◆ Location() [1/3]

Location::Location ( )

Constructs an empty location.

Definition at line 40 of file location.cpp.

Referenced by TagFileWriter::generateTagFile(), Tokenizer::initialize(), Generator::initializeFormat(), internalError(), and loadIndexFiles().

+ Here is the caller graph for this function:

◆ Location() [2/3]

Location::Location ( const QString & filePath)
explicit

Constructs a location with (fileName, 1, 1) on its file position stack.

Definition at line 49 of file location.cpp.

References Location().

Referenced by Location().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Location() [3/3]

Location::Location ( const Location & other)

The copy constructor copies the contents of other into this Location using the assignment operator.

Definition at line 59 of file location.cpp.

References Location(), and operator=().

Referenced by Location().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ~Location()

Location::~Location ( )
inline

Definition at line 20 of file location.h.

Member Function Documentation

◆ advance()

void Location::advance ( QChar ch)

Advance the current file position, using ch to decide how to do that.

If ch is a {'\n'}, increment the current line number and set the column number to 1. If \ch is a {'\t'}, increment to the next tab column. Otherwise, increment the column number by 1.

The current file position is the one on top of the position stack.

Definition at line 111 of file location.cpp.

◆ advanceLines()

void Location::advanceLines ( int n)
inline

Definition at line 26 of file location.h.

◆ columnNo()

int Location::columnNo ( ) const
inlinenodiscard

Returns the current column number.

Must not be called on an empty Location object.

See also
filePath(), lineNo()

Definition at line 44 of file location.h.

Referenced by Doc::trimCStyleComment().

+ Here is the caller graph for this function:

◆ depth()

int Location::depth ( ) const
inlinenodiscard

Definition at line 39 of file location.h.

◆ error()

void Location::error ( const QString & message,
const QString & details = QString() ) const

Writes message and details to stderr as a formatted error message.

Does not write the message if qdoc is in the Prepare phase.

Definition at line 232 of file location.cpp.

◆ etc()

bool Location::etc ( ) const
inlinenodiscard

Definition at line 45 of file location.h.

◆ exitCode()

int Location::exitCode ( )
static

Returns the error code QDoc should exit with; EXIT_SUCCESS or the number of documentation warnings if they exceeded the limit set by warninglimit configuration variable.

Definition at line 244 of file location.cpp.

Referenced by main().

+ Here is the caller graph for this function:

◆ fatal()

void Location::fatal ( const QString & message,
const QString & details = QString() ) const

Writes message and details to stderr as a formatted error message and then exits the program.

qdoc prints fatal errors in either phase (Prepare or Generate).

Definition at line 263 of file location.cpp.

◆ fileName()

QString Location::fileName ( ) const
nodiscard

Returns the file name part of the file path, ie the current file.

Returns an empty string if the file path is empty.

Definition at line 185 of file location.cpp.

◆ filePath()

const QString & Location::filePath ( ) const
inlinenodiscard

Returns the current path and file name.

If the Location is empty, the returned string is null.

See also
lineNo(), columnNo()

Definition at line 40 of file location.h.

◆ fileSuffix()

QString Location::fileSuffix ( ) const
nodiscard

Returns the suffix of the file name.

Returns an empty string if the file path is empty.

Definition at line 195 of file location.cpp.

◆ information()

void Location::information ( const QString & message)
static

Prints message to stdout followed by a {'
'}.

Definition at line 333 of file location.cpp.

◆ initialize()

void Location::initialize ( )
static

Gets several parameters from the config, including tab size, program name, and a regular expression that appears to be used for matching certain error messages so that emitMessage() can avoid printing them.

Definition at line 297 of file location.cpp.

References Config::singleExec().

Referenced by processQdocconfFile().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ internalError()

void Location::internalError ( const QString & hint)
static

Report a program bug, including the hint.

Definition at line 342 of file location.cpp.

References Location().

+ Here is the call graph for this function:

◆ isEmpty()

bool Location::isEmpty ( ) const
inlinenodiscard

Returns true if there is no file name set yet; returns false otherwise.

The functions filePath(), lineNo() and columnNo() must not be called on an empty Location object.

Definition at line 38 of file location.h.

Referenced by toString().

+ Here is the caller graph for this function:

◆ lineNo()

int Location::lineNo ( ) const
inlinenodiscard

Returns the current line number.

Must not be called on an empty Location object.

See also
filePath(), columnNo()

Definition at line 43 of file location.h.

◆ operator=()

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

The assignment operator does a deep copy of the entire state of other into this Location.

Definition at line 69 of file location.cpp.

Referenced by Location().

+ Here is the caller graph for this function:

◆ pop()

void Location::pop ( )

Pops the top of the internal stack.

The current file position becomes the next one in the new top of stack.

See also
push()

Definition at line 149 of file location.cpp.

Referenced by toString().

+ Here is the caller graph for this function:

◆ push()

void Location::push ( const QString & filePath)

Pushes filePath onto the file position stack.

The current file position becomes (filePath, 1, 1).

See also
pop()

Definition at line 129 of file location.cpp.

◆ report()

void Location::report ( const QString & message,
const QString & details = QString() ) const

Writes message and details to stderr as a formatted report message.

A report does not include any filename/line number information. Recurring reports with an identical message are ignored.

A report is generated only in generate or {single-exec} phase. In {prepare} phase, this function does nothing.

Definition at line 282 of file location.cpp.

◆ setColumnNo()

void Location::setColumnNo ( int no)
inline

Definition at line 36 of file location.h.

Referenced by fromCXSourceLocation().

+ Here is the caller graph for this function:

◆ setEtc()

void Location::setEtc ( bool etc)
inline

Definition at line 34 of file location.h.

Referenced by toString().

+ Here is the caller graph for this function:

◆ setLineNo()

void Location::setLineNo ( int no)
inline

Definition at line 35 of file location.h.

Referenced by fromCXSourceLocation().

+ Here is the caller graph for this function:

◆ start()

void Location::start ( )

If the file position on top of the stack has a line number less than 1, set its line number to 1 and its column number to 1.

Otherwise, do nothing.

Definition at line 95 of file location.cpp.

◆ terminate()

void Location::terminate ( )
static

Apparently, all this does is delete the regular expression used for intercepting certain error messages that should not be emitted by emitMessage().

Definition at line 324 of file location.cpp.

Referenced by processQdocconfFile().

+ Here is the caller graph for this function:

◆ toString()

QString Location::toString ( ) const
nodiscard

Converts the location to a string to be prepended to error messages.

Definition at line 393 of file location.cpp.

References isEmpty(), pop(), and setEtc().

+ Here is the call graph for this function:

◆ warning()

void Location::warning ( const QString & message,
const QString & details = QString() ) const

Writes message and details to stderr as a formatted warning message.

Does not write the message if qdoc is in the Prepare phase.

Definition at line 220 of file location.cpp.

Friends And Related Symbol Documentation

◆ QTypeInfo< StackEntry >

friend class QTypeInfo< StackEntry >
friend

Definition at line 57 of file location.h.


The documentation for this class was generated from the following files: