FE 0.13.1
Header-only C++ frontend library
Loading...
Searching...
No Matches

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

#include <fe/loc.h>

Public Member Functions

constexpr Pos ()=default
 Creates an invalid Position.
constexpr Pos (uint32_t off)
constexpr operator bool () const
 Is a valid Position?
constexpr auto operator<=> (const Pos &) const =default
constexpr Pos operator+ (uint32_t n) const
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)
 fe/loc.h only declares the stream output and dump helpers.

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 18 of file loc.h.

Constructor & Destructor Documentation

◆ Pos() [1/2]

fe::Pos::Pos ( )
constexprdefault

Creates an invalid Position.

Referenced by fe::Src::begin(), fe::Src::end(), operator+(), operator<<, operator<=>(), and fe::Src::prev().

◆ Pos() [2/2]

fe::Pos::Pos ( uint32_t off)
inlineexplicitconstexpr

Definition at line 22 of file loc.h.

References off.

Member Function Documentation

◆ dump()

void fe::Pos::dump ( ) const

◆ operator bool()

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

Is a valid Position?

Definition at line 25 of file loc.h.

References Invalid, and off.

◆ operator+()

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

Definition at line 27 of file loc.h.

References Invalid, off, and Pos().

◆ operator<=>()

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

References Pos().

◆ operator<<

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

fe/loc.h only declares the stream output and dump helpers.

Link fe-lib for the default implementation, or provide your own.

References Pos().

Member Data Documentation

◆ Invalid

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

Definition at line 19 of file loc.h.

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

◆ off

uint32_t fe::Pos::off = Invalid

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