9 #include <hilti/rt/filesystem.h> 11 #include <hilti/base/util.h> 30 Location(hilti::rt::filesystem::path file =
"",
int from_line = -1,
int to_line = -1,
int from_character = -1,
31 int to_character = -1)
32 : _file(
std::move(file)),
33 _from_line(from_line),
35 _from_character(from_character),
36 _to_character(to_character) {}
44 auto file()
const {
return _file.generic_string(); }
45 auto from()
const {
return _from_line; }
46 auto to()
const {
return _to_line; }
53 std::string
render(
bool no_path =
false)
const;
59 explicit operator bool()
const;
62 operator std::string()
const {
return render(); }
64 bool operator<(
const Location& other)
const {
65 return std::tie(_file, _from_line, _from_character, _to_line, _to_character) <
66 std::tie(other._file, other._from_line, other._from_character, other._to_line, other._to_character);
69 bool operator==(
const Location& other)
const {
70 return std::tie(_file, _from_line, _from_character, _to_line, _to_character) ==
71 std::tie(other._file, other._from_line, other._from_character, other._to_line, other._to_character);
75 hilti::rt::filesystem::path _file;
79 int _from_character = -1;
80 int _to_character = -1;
82 friend struct std::hash<Location>;
86 inline auto to_string(
const Location& l) {
return l.
render(); }
89 inline std::ostream& operator<<(std::ostream& out,
const Location& l) {
96 extern const Location None;
105 return hilti::rt::hashCombine(std::hash<std::string>()(x._file), x._from_line, x._to_line, x._from_character,
Definition: optional.h:79
Location(hilti::rt::filesystem::path file="", int from_line=-1, int to_line=-1, int from_character=-1, int to_character=-1)
Definition: location.h:30
std::string render(bool no_path=false) const
Definition: location.cc:12
Definition: location.h:18
Definition: location.h:94