A11 (C++ runtime)
Native C++ implementation of the A11 streaming action runtime
Loading...
Searching...
No Matches
a11::flow::LineIndex Class Reference

Line and column lookup over one source text. More...

#include <cpp/a11/flow/diagnostic.h>

Public Member Functions

 LineIndex (std::string_view source)
 
Position At (size_t offset) const
 The position at a byte offset, clamped to the end of the source.
 
Range Between (size_t start, size_t end) const
 A range from two byte offsets.
 
size_t LineCount () const
 How many lines the source has, counting a trailing partial line.
 
size_t LineStart (int line) const
 The byte offset the 1-based line starts at, clamped to the source.
 

Detailed Description

Line and column lookup over one source text.

Built once per file and shared by everything that reports a position, so a diagnostic never costs a scan of the source to locate. Borrows the text, which must outlive it.

Constructor & Destructor Documentation

◆ LineIndex()

a11::flow::LineIndex::LineIndex ( std::string_view  source)
explicit

Member Function Documentation

◆ At()

Position a11::flow::LineIndex::At ( size_t  offset) const

The position at a byte offset, clamped to the end of the source.

◆ Between()

Range a11::flow::LineIndex::Between ( size_t  start,
size_t  end 
) const

A range from two byte offsets.

◆ LineCount()

size_t a11::flow::LineIndex::LineCount ( ) const
inline

How many lines the source has, counting a trailing partial line.

◆ LineStart()

size_t a11::flow::LineIndex::LineStart ( int  line) const

The byte offset the 1-based line starts at, clamped to the source.


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