|
FE 0.13.1
Header-only C++ frontend library
|
The content of one source file together with the offsets its rows start at. More...
#include <fe/src.h>
Public Member Functions | |
| Src (std::filesystem::path path, std::string buf) | |
Getters | |
| const std::filesystem::path & | path () const |
| std::string_view | buf () const |
| uint32_t | num_rows () const |
| The number of rows the file actually has. | |
| Pos | begin () const |
| Pos | end () const |
| bool | contains (Pos pos) const |
Resolve a Pos | |
| std::pair< uint32_t, uint32_t > | rowcol (Pos pos) const |
| uint32_t | row (Pos pos) const |
| uint32_t | col (Pos pos) const |
| std::string_view | line (uint32_t row) const |
Text of the 1-based row without its line terminator - or a leading utf8::Bom; empty if row is out of range. | |
| Pos | prev (Pos pos) const |
Start of the last code point before pos - the character a half-open Loc::end points past. | |
The content of one source file together with the offsets its rows start at.
This is what turns a Pos back into the row/column a human wants to read.
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
Definition at line 63 of file src.h.
References fe::Pos::Pos().
Referenced by line(), fe::SrcMap::lookup(), and prev().
|
inline |
|
inline |
|
inline |
Start of the last code point before pos - the character a half-open Loc::end points past.
Definition at line 98 of file src.h.
References fe::utf8::decode(), end(), fe::utf8::is_valid234(), fe::Pos::off, and fe::Pos::Pos().
|
inline |
|
inline |
1-based row and column pos sits at, or {0, 0} if pos does not belong to this file. The column counts code points, not bytes, and a leading utf8::Bom occupies none.
Definition at line 72 of file src.h.
References begin(), contains(), line(), fe::utf8::num_code_points(), num_rows(), fe::Pos::off, and row().