Location
#include <tpau-cpp-kernal/Location.h>
class Location
Represents a location within a file, including the file name, start position, and end position.
Line and column numbers are 1-based, and 0 indicates that it is not specified.
class Position
A position within a file.
Line and column numbers are 1-based, and 0 indicates that it is not specified.
constructor Position
Create an empty position.
| Position | ( | ); |
constructor Position
Create a position.
| Position | ( | size_t line_number, | |
| size_t column | ); |
| PARAMETER | DESCRIPTION |
|---|---|
line_number |
The line number, or |
column |
The column number, or |
method column_indexconst
Get the 0-based column index of the position. If the column number is not specified, 0 is returned.
| size_t column_index | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
The 0-based column index of the position, or |
method emptyconst
Check if the position is empty (i.e. has no line number).
| bool empty | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
method has_columnconst
Check if the column number is specified.
| bool has_column | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method has_lineconst
Check if the line number is specified.
| bool has_line | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method line_indexconst
Get the 0-based line index of the position. If the line number is not specified, 0 is returned.
| size_t line_index | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
The 0-based line index of the position, or |
method operator boolconst
| operator bool | ( | ) const; |
method operator!=const
Check if two positions are not equal.
| bool operator!= | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator<const
Check if this position is before another position.
| bool operator< | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator<=const
Check if this position is before or equal to another position.
| bool operator<= | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator==const
Check if two positions are equal.
| bool operator== | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator>const
Check if this position is after another position.
| bool operator> | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator>=const
Check if this position is after or equal to another position.
| bool operator>= | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method to_stringconst
Convert the position to a string representation.
| std::string to_string | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::string |
The string representation of the position. |
member column
The column number, or 0 if the column number is not specified.
member line_number
The line number, or 0 if the line number is not specified.
constructor Location
Empty location.
| Location | ( | ); |
constructor Location
Create a location that covers the range from the start of one location to the end of another location. If the two locations are in different files, the second location will be ignored.
| Location | ( | const Location & a, | |
| const Location & b | ); |
| PARAMETER | DESCRIPTION |
|---|---|
a |
The first location. |
b |
The second location. |
constructor Location
Create a location.
| Location | ( | Symbol file, | |
| size_t line_number, | |||
| size_t start_column, | |||
| size_t end_column | ); |
| PARAMETER | DESCRIPTION |
|---|---|
file |
|
line_number |
The line number, or |
start_column |
The starting column number, or |
end_column |
The ending column number, or |
constructor Location
Create a location with a file name, line number, and column range.
| Location | ( | Symbol file, | |
| size_t start_line_number, | |||
| size_t start_column, | |||
| size_t end_line_number, | |||
| size_t end_column | ); |
| PARAMETER | DESCRIPTION |
|---|---|
file |
The file symbol. |
start_line_number |
The starting line number, or |
start_column |
The starting column number, or |
end_line_number |
The ending line number, or |
end_column |
The ending column number, or |
constructor Location
Create a location with only a file name.
| Location | ( | Symbol file_name | ); |
| PARAMETER | DESCRIPTION |
|---|---|
file_name |
The name of the file. |
method emptyconst
Check if the location is empty (i.e. has no file).
| bool empty | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method extend
Extend the location by a number of columns.
| void extend | ( | size_t amount | ); |
| PARAMETER | DESCRIPTION |
|---|---|
amount |
The number of columns to extend the location by. |
method extend
Extend the location to include another location. If the other location is not in the same file, it will be ignored.
| void extend | ( | const Location & other | ); |
| PARAMETER | DESCRIPTION |
|---|---|
other |
method is_one_lineconst
Check if the location is within a single line.
| bool is_one_line | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator!=const
Check if two locations are not equal.
| bool operator!= | ( | const Location & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
| RETURNS | DESCRIPTION |
|---|---|
bool |
method operator<const
Check if this location is before another location.
Locations are ordered first by line number, then by column number. Locations in different files are not comparable.
| bool operator< | ( | const Location & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The location to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator<=const
Check if this location is before or equal to another location.
| bool operator<= | ( | const Location & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The location to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator==const
Check if two locations are equal.
| bool operator== | ( | const Location & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The location to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator>const
Check if this location is after another location.
Locations are ordered first by line number, then by column number. Locations in different files are not comparable.
| bool operator> | ( | const Location & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The location to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator>=const
Check if this location is after or equal to another location.
| bool operator>= | ( | const Location & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The location to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method to_stringconst
Convert the location to a string representation of the start of the location.
| std::string to_string | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::string |
A string representation of the start of the location. |
method widthconst
Get the width of the location in columns.
If the location is not on a single line, or no start or end column is known, 0 is returned.
| size_t width | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
The width of the location in columns, or |
member end
The position where the location ends.
member file
The file.
member start
The position where the location starts.
class Position
A position within a file.
Line and column numbers are 1-based, and 0 indicates that it is not specified.
constructor Position
Create an empty position.
| Position | ( | ); |
constructor Position
Create a position.
| Position | ( | size_t line_number, | |
| size_t column | ); |
| PARAMETER | DESCRIPTION |
|---|---|
line_number |
The line number, or |
column |
The column number, or |
method column_indexconst
Get the 0-based column index of the position. If the column number is not specified, 0 is returned.
| size_t column_index | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
The 0-based column index of the position, or |
method emptyconst
Check if the position is empty (i.e. has no line number).
| bool empty | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
method has_columnconst
Check if the column number is specified.
| bool has_column | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method has_lineconst
Check if the line number is specified.
| bool has_line | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method line_indexconst
Get the 0-based line index of the position. If the line number is not specified, 0 is returned.
| size_t line_index | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
size_t |
The 0-based line index of the position, or |
method operator boolconst
| operator bool | ( | ) const; |
method operator!=const
Check if two positions are not equal.
| bool operator!= | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator<const
Check if this position is before another position.
| bool operator< | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator<=const
Check if this position is before or equal to another position.
| bool operator<= | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator==const
Check if two positions are equal.
| bool operator== | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator>const
Check if this position is after another position.
| bool operator> | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method operator>=const
Check if this position is after or equal to another position.
| bool operator>= | ( | const Position & other | ) const; |
| PARAMETER | DESCRIPTION |
|---|---|
other |
The position to compare with. |
| RETURNS | DESCRIPTION |
|---|---|
bool |
|
method to_stringconst
Convert the position to a string representation.
| std::string to_string | ( | ) const; |
| RETURNS | DESCRIPTION |
|---|---|
std::string |
The string representation of the position. |
member column
The column number, or 0 if the column number is not specified.
member line_number
The line number, or 0 if the line number is not specified.
function operator<<
Output location to a stream.
| std::ostream & operator<< | ( | std::ostream & os, | |
| const Location & location | ); |
| PARAMETER | DESCRIPTION |
|---|---|
os |
The stream to output to. |
location |
The location to output. |
| RETURNS | DESCRIPTION |
|---|---|
std::ostream & |
The stream after outputting the location. |