Spicy
Public Member Functions | Friends | List of all members
hilti::Location Class Reference

#include <location.h>

Public Member Functions

 Location (hilti::rt::filesystem::path file="", int from_line=-1, int to_line=-1, int from_character=-1, int to_character=-1)
 
 Location (const Location &)=default
 
 Location (Location &&)=default
 
Locationoperator= (const Location &)=default
 
Locationoperator= (Location &&)=default
 
auto file () const
 
auto from () const
 
auto to () const
 
std::string render (bool no_path=false) const
 
 operator bool () const
 
 operator std::string () const
 
bool operator< (const Location &other) const
 
bool operator== (const Location &other) const
 

Friends

struct std::hash< Location >
 

Detailed Description

Source code locations associated with AST nodes.

Constructor & Destructor Documentation

◆ Location()

hilti::Location::Location ( hilti::rt::filesystem::path  file = "",
int  from_line = -1,
int  to_line = -1,
int  from_character = -1,
int  to_character = -1 
)
inline

Constructor. If all arguments are left at their default, the instance will match location::None.

Parameters
filefile name/path associated with the location; empty if unknown.
from_linefirst line number of the described range; -1 if not available.
to_linelast line number of the described range; -1 if not available.
from_characterfirst character number of the described range; -1 if not available.
to_characterfirst character number of the described range; -1 if not available.

Member Function Documentation

◆ operator bool()

Location::operator bool ( ) const
explicit

Returns true if the location is set. A location is unset if it equals location::None (which a default constructed location will)..

◆ operator std::string()

hilti::Location::operator std::string ( ) const
inline

Forwards to render().

◆ render()

std::string Location::render ( bool  no_path = false) const

Returns a string representation of the location.

Parameters
no_pathif true, do not include the file

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