FE 0.15.0
A C++23 toolkit for writing compiler/interpreter frontends.
Loading...
Searching...
No Matches

Byte offset into a Src; pass around as value. More...

#include <fe/loc.h>

Public Member Functions

constexpr Pos () noexcept=default
 Creates an invalid Position.
constexpr Pos (uint32_t off) noexcept
constexpr operator bool () const noexcept
 Is a valid Position?
constexpr auto operator<=> (const Pos &) const noexcept=default
constexpr Pos operator+ (uint32_t n) const noexcept
void dump () const

Public Attributes

uint32_t off = Invalid

Static Public Attributes

static constexpr uint32_t Invalid = uint32_t(-1)

Friends

std::ostream & operator<< (std::ostream &os, Pos pos)

Detailed Description

Byte offset into a Src; pass around as value.

A Position is just an index - fe::Src turns it back into the row/column a human wants to read.

Warning
Files beyond 4GiB wrap around, and the largest offset doubles as the "invalid" sentinel.

Definition at line 16 of file loc.h.

Constructor & Destructor Documentation

◆ Pos() [1/2]

fe::Pos::Pos ( )
constexprdefaultnoexcept

◆ Pos() [2/2]

fe::Pos::Pos ( uint32_t off)
inlineexplicitconstexprnoexcept

Definition at line 20 of file loc.h.

References off, and Pos().

Member Function Documentation

◆ dump()

void fe::Pos::dump ( ) const

◆ operator bool()

fe::Pos::operator bool ( ) const
inlineexplicitconstexprnoexcept

Is a valid Position?

Definition at line 23 of file loc.h.

References Invalid, and off.

◆ operator+()

Pos fe::Pos::operator+ ( uint32_t n) const
inlineconstexprnoexcept

Definition at line 25 of file loc.h.

References Invalid, off, and Pos().

◆ operator<=>()

auto fe::Pos::operator<=> ( const Pos & ) const
constexprdefaultnoexcept

References Pos().

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
Pos pos )
friend

References Pos().

Member Data Documentation

◆ Invalid

uint32_t fe::Pos::Invalid = uint32_t(-1)
staticconstexpr

Definition at line 17 of file loc.h.

Referenced by operator bool(), and operator+().

◆ off


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