FE 0.5.0
A header-only C++ library for writing frontends
Loading...
Searching...
No Matches
fe::Loc Struct Reference

Location in a File. More...

#include <fe/loc.h>

Public Member Functions

 Loc ()=default
 Creates an invalid Location.
 
 Loc (const std::filesystem::path *path, Pos begin, Pos finis)
 
 Loc (const std::filesystem::path *file, Pos pos)
 
 Loc (Pos begin, Pos finis)
 
 Loc (Pos pos)
 
Loc anew_begin () const
 
Loc anew_finis () const
 
Loc operator+ (Pos pos) const
 
Loc operator+ (Loc loc) const
 
 operator bool () const
 Is a valid Location?
 
bool operator== (Loc other) const
 
void dump () const
 

Public Attributes

const std::filesystem::path * path = {}
 
Pos begin = {}
 
Pos finis = {}
 It's called finis because it refers to the last character within this Location.
 

Friends

std::ostream & operator<< (std::ostream &os, Loc loc)
 Write your own implementation or include fe/loc.cpp.h somewhere for a default one.
 

Detailed Description

Location in a File.

It's only two machine words on a 64 bit arch, so pass around as value.

Warning
Loc::path is only a pointer and it is your job to guarantee that the underlying std::filesystem::path outlives this Location.

Definition at line 33 of file loc.h.

Constructor & Destructor Documentation

◆ Loc() [1/5]

fe::Loc::Loc ( )
default

Creates an invalid Location.

◆ Loc() [2/5]

fe::Loc::Loc ( const std::filesystem::path *  path,
Pos  begin,
Pos  finis 
)
inline

Definition at line 35 of file loc.h.

◆ Loc() [3/5]

fe::Loc::Loc ( const std::filesystem::path *  file,
Pos  pos 
)
inline

Definition at line 39 of file loc.h.

◆ Loc() [4/5]

fe::Loc::Loc ( Pos  begin,
Pos  finis 
)
inline

Definition at line 41 of file loc.h.

◆ Loc() [5/5]

fe::Loc::Loc ( Pos  pos)
inline

Definition at line 43 of file loc.h.

Member Function Documentation

◆ anew_begin()

Loc fe::Loc::anew_begin ( ) const
inline

Definition at line 46 of file loc.h.

References begin, and path.

◆ anew_finis()

Loc fe::Loc::anew_finis ( ) const
inline

Definition at line 47 of file loc.h.

References finis, and path.

◆ dump()

void fe::Loc::dump ( ) const

Definition at line 24 of file loc.cpp.h.

◆ operator bool()

fe::Loc::operator bool ( ) const
inlineexplicit

Is a valid Location?

Definition at line 50 of file loc.h.

References begin.

◆ operator+() [1/2]

Loc fe::Loc::operator+ ( Loc  loc) const
inline

Definition at line 49 of file loc.h.

References begin, finis, and path.

◆ operator+() [2/2]

Loc fe::Loc::operator+ ( Pos  pos) const
inline

Definition at line 48 of file loc.h.

References begin, and path.

◆ operator==()

bool fe::Loc::operator== ( Loc  other) const
inline
Note
Loc::path is only checked via pointer equality.

Definition at line 52 of file loc.h.

References begin, finis, and path.

Friends And Related Symbol Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
Loc  loc 
)
friend

Write your own implementation or include fe/loc.cpp.h somewhere for a default one.

Definition at line 14 of file loc.cpp.h.

Member Data Documentation

◆ begin

◆ finis

Pos fe::Loc::finis = {}

It's called finis because it refers to the last character within this Location.

In the STL the word end refers to the position of something that is one element past the end.

Definition at line 57 of file loc.h.

Referenced by anew_finis(), fe::Lexer< K, S >::next(), operator+(), and operator==().

◆ path

const std::filesystem::path* fe::Loc::path = {}

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