SciLex
A header-only C++20 lexer built on REAL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
scilex::detail::indent_meter Class Reference

Measures the bytes of a source between the start of the line holding an offset and it, over offsets that mostly increase: each byte is read once from the last offset measured, so a pass over a long line stays linear (measured from its line's start at every token, 40 000 entries on one line took 2.5 s). More...

#include <layout.hpp>

Public Member Functions

 indent_meter (std::string_view source) noexcept
 A meter over source, at its start.
 
indent_measure operator() (std::size_t offset)
 The indentation of the bytes before offset on its line.
 

Detailed Description

Measures the bytes of a source between the start of the line holding an offset and it, over offsets that mostly increase: each byte is read once from the last offset measured, so a pass over a long line stays linear (measured from its line's start at every token, 40 000 entries on one line took 2.5 s).

Constructor & Destructor Documentation

◆ indent_meter()

scilex::detail::indent_meter::indent_meter ( std::string_view  source)
inlineexplicitnoexcept

A meter over source, at its start.

Member Function Documentation

◆ operator()()

indent_measure scilex::detail::indent_meter::operator() ( std::size_t  offset)
inline

The indentation of the bytes before offset on its line.

Exceptions
std::invalid_argumentWhen offset lies beyond the source.

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