Pretty Diagnostics
Create your own pretty diagnostics
Loading...
Searching...
No Matches
pretty_diagnostics::Location Class Reference

A position inside a Source, expressed as (row, column, index) More...

#include <source.hpp>

Public Member Functions

 Location (size_t row, size_t column, size_t index)
 Constructs a location with the given coordinates and absolute index. More...
 
 Location ()
 Constructs a default-initialized location (all -1). More...
 
auto column () const
 Returns the 0-based column number. More...
 
auto index () const
 Returns the 0-based absolute character index. More...
 
auto row () const
 Returns the 0-based row (line) number. More...
 

Friends

bool operator< (const Location &lhs, const Location &rhs)
 Orders locations by their absolute index. More...
 
bool operator<= (const Location &lhs, const Location &rhs)
 Less-than-or-equal comparison derived from >= More...
 
bool operator> (const Location &lhs, const Location &rhs)
 Greater-than comparison derived from < More...
 
bool operator>= (const Location &lhs, const Location &rhs)
 Greater-than-or-equal comparison derived from < More...
 
bool operator== (const Location &lhs, const Location &rhs)
 Equality compares row, column and index. More...
 
bool operator!= (const Location &lhs, const Location &rhs)
 Inequality based on operator== More...
 

Detailed Description

A position inside a Source, expressed as (row, column, index)

The index is a 0-based absolute character offset into the source contents. row and column represent human-readable coordinates, the index defines ordering

Constructor & Destructor Documentation

◆ Location() [1/2]

pretty_diagnostics::Location::Location ( size_t  row,
size_t  column,
size_t  index 
)

Constructs a location with the given coordinates and absolute index.

Parameters
row0-based line number
column0-based column number
index0-based absolute character index

◆ Location() [2/2]

pretty_diagnostics::Location::Location ( )

Constructs a default-initialized location (all -1).

Member Function Documentation

◆ column()

auto pretty_diagnostics::Location::column ( ) const
inline

Returns the 0-based column number.

Returns
0-based column number

◆ index()

auto pretty_diagnostics::Location::index ( ) const
inline

Returns the 0-based absolute character index.

Returns
0-based absolute index

◆ row()

auto pretty_diagnostics::Location::row ( ) const
inline

Returns the 0-based row (line) number.

Returns
0-based row number

Friends And Related Function Documentation

◆ operator!=

bool operator!= ( const Location lhs,
const Location rhs 
)
friend

Inequality based on operator==

Parameters
lhsLeft-hand location
rhsRight-hand location
Returns
True if the locations differ

◆ operator<

bool operator< ( const Location lhs,
const Location rhs 
)
friend

Orders locations by their absolute index.

Parameters
lhsLeft-hand location
rhsRight-hand location
Returns
True if lhs precedes rhs by absolute index

◆ operator<=

bool operator<= ( const Location lhs,
const Location rhs 
)
friend

Less-than-or-equal comparison derived from >=

Parameters
lhsLeft-hand location
rhsRight-hand location
Returns
True if lhs is not greater than rhs

◆ operator==

bool operator== ( const Location lhs,
const Location rhs 
)
friend

Equality compares row, column and index.

Parameters
lhsLeft-hand location
rhsRight-hand location
Returns
True if all coordinates and index are equal

◆ operator>

bool operator> ( const Location lhs,
const Location rhs 
)
friend

Greater-than comparison derived from <

Parameters
lhsLeft-hand location
rhsRight-hand location
Returns
True if lhs succeeds rhs by absolute index

◆ operator>=

bool operator>= ( const Location lhs,
const Location rhs 
)
friend

Greater-than-or-equal comparison derived from <

Parameters
lhsLeft-hand location
rhsRight-hand location
Returns
True if lhs is not less than rhs

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