Represents a contiguous region within a Source
More...
#include <span.hpp>
|
| | Span (const std::shared_ptr< Source > &source, const Location &start, const Location &end) |
| | Constructs a span from explicit start and end locations within the same source. More...
|
| |
| | Span (const std::shared_ptr< Source > &source, size_t start_row, size_t start_column, size_t end_row, size_t end_column) |
| | Constructs a span from row/column coordinates. More...
|
| |
| | Span (const std::shared_ptr< Source > &source, size_t start_index, size_t end_index) |
| | Constructs a span from 0-based character indices into the source content. More...
|
| |
| Span | join (const Span &other) const |
| | Combines this span with another span into a single continuous span. More...
|
| |
| bool | intersects (const Span &other) const |
| | Returns true if this span intersects the other span. More...
|
| |
| std::string | substr () const |
| | Extracts the substring of the source covered by this span. More...
|
| |
| size_t | width () const |
| | Returns the number of characters covered by this span. More...
|
| |
| size_t | line () const |
| | Returns the 1-based line number of the span's start. More...
|
| |
| const std::shared_ptr< Source > & | source () const |
| | Returns the backing source of this span. More...
|
| |
| Location | start () const |
| | Returns the starting location of the span. More...
|
| |
| Location | end () const |
| | Returns the end location of the span. More...
|
| |
Represents a contiguous region within a Source
A span is defined by start and end Locations and can be constructed from coordinates or linear indices. Spans are comparable by their start location
◆ Span() [1/3]
| pretty_diagnostics::Span::Span |
( |
const std::shared_ptr< Source > & |
source, |
|
|
const Location & |
start, |
|
|
const Location & |
end |
|
) |
| |
Constructs a span from explicit start and end locations within the same source.
- Parameters
-
| source | Backing source shared pointer |
| start | Start location (inclusive) |
| end | End location (exclusive) |
◆ Span() [2/3]
| pretty_diagnostics::Span::Span |
( |
const std::shared_ptr< Source > & |
source, |
|
|
size_t |
start_row, |
|
|
size_t |
start_column, |
|
|
size_t |
end_row, |
|
|
size_t |
end_column |
|
) |
| |
Constructs a span from row/column coordinates.
- Parameters
-
| source | Backing source shared pointer |
| start_row | 0-based start line number |
| start_column | 0-based start column number |
| end_row | 0-based end line number |
| end_column | 0-based end column number |
◆ Span() [3/3]
| pretty_diagnostics::Span::Span |
( |
const std::shared_ptr< Source > & |
source, |
|
|
size_t |
start_index, |
|
|
size_t |
end_index |
|
) |
| |
Constructs a span from 0-based character indices into the source content.
- Parameters
-
| source | Backing source shared pointer |
| start_index | 0-based start index (inclusive) |
| end_index | 0-based end index (exclusive) |
◆ end()
| Location pretty_diagnostics::Span::end |
( |
| ) |
const |
|
inline |
Returns the end location of the span.
- Returns
- End location (exclusive)
◆ intersects()
| bool pretty_diagnostics::Span::intersects |
( |
const Span & |
other | ) |
const |
Returns true if this span intersects the other span.
- Parameters
-
| other | Other span to test against |
- Returns
- True if the spans overlap; otherwise false
◆ join()
| Span pretty_diagnostics::Span::join |
( |
const Span & |
other | ) |
const |
Combines this span with another span into a single continuous span.
The resulting span starts at the earliest start location of the two spans and ends at the latest end location of the two spans.
- Parameters
-
| other | The span to combine with |
- Returns
- A new span that encompasses both spans
◆ line()
| size_t pretty_diagnostics::Span::line |
( |
| ) |
const |
Returns the 1-based line number of the span's start.
- Returns
- 1-based start line number
◆ source()
| const std::shared_ptr< Source > & pretty_diagnostics::Span::source |
( |
| ) |
const |
|
inline |
Returns the backing source of this span.
- Returns
- Shared pointer to the backing source
◆ start()
| Location pretty_diagnostics::Span::start |
( |
| ) |
const |
|
inline |
Returns the starting location of the span.
- Returns
- Start location (inclusive)
◆ substr()
| std::string pretty_diagnostics::Span::substr |
( |
| ) |
const |
Extracts the substring of the source covered by this span.
- Returns
- The substring of the backing source covered by this span
◆ width()
| size_t pretty_diagnostics::Span::width |
( |
| ) |
const |
Returns the number of characters covered by this span.
- Returns
- Span width in characters
◆ operator!=
| bool operator!= |
( |
const Span & |
lhs, |
|
|
const Span & |
rhs |
|
) |
| |
|
friend |
Inequality based on ==
- Parameters
-
| lhs | Left-hand span |
| rhs | Right-hand span |
- Returns
- True if the spans differ
◆ operator<
| bool operator< |
( |
const Span & |
lhs, |
|
|
const Span & |
rhs |
|
) |
| |
|
friend |
Orders spans by their start location.
- Parameters
-
| lhs | Left-hand span |
| rhs | Right-hand span |
- Returns
- True if
lhs starts before rhs
◆ operator<=
| bool operator<= |
( |
const Span & |
lhs, |
|
|
const Span & |
rhs |
|
) |
| |
|
friend |
Less-than-or-equal comparison derived from >=
- Parameters
-
| lhs | Left-hand span |
| rhs | Right-hand span |
- Returns
- True if
lhs is not greater than rhs
◆ operator==
| bool operator== |
( |
const Span & |
lhs, |
|
|
const Span & |
rhs |
|
) |
| |
|
friend |
Equality compares source, start and end.
- Parameters
-
| lhs | Left-hand span |
| rhs | Right-hand span |
- Returns
- True if both spans refer to the same source and coordinates
◆ operator>
| bool operator> |
( |
const Span & |
lhs, |
|
|
const Span & |
rhs |
|
) |
| |
|
friend |
Greater-than comparison derived from <
- Parameters
-
| lhs | Left-hand span |
| rhs | Right-hand span |
- Returns
- True if
lhs starts after rhs
◆ operator>=
| bool operator>= |
( |
const Span & |
lhs, |
|
|
const Span & |
rhs |
|
) |
| |
|
friend |
Greater-than-or-equal comparison derived from <
- Parameters
-
| lhs | Left-hand span |
| rhs | Right-hand span |
- Returns
- True if
lhs is not less than rhs
The documentation for this class was generated from the following file: