8 #include <hilti/rt/filesystem.h>
10 #include <hilti/base/util.h>
29 Location(hilti::rt::filesystem::path file =
"",
int from_line = -1,
int to_line = -1,
int from_character = -1,
30 int to_character = -1)
31 : _file(std::move(file)),
32 _from_line(from_line),
34 _from_character(from_character),
35 _to_character(to_character) {}
43 auto file()
const {
return _file.generic_string(); }
44 auto from()
const {
return _from_line; }
45 auto to()
const {
return _to_line; }
58 std::string
dump(
bool no_path =
false)
const;
64 explicit operator bool()
const;
67 operator std::string()
const {
return dump(); }
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);
74 bool operator==(
const Location& other)
const {
75 return std::tie(_file, _from_line, _from_character, _to_line, _to_character) ==
76 std::tie(other._file, other._from_line, other._from_character, other._to_line, other._to_character);
80 hilti::rt::filesystem::path _file;
84 int _from_character = -1;
85 int _to_character = -1;
91 inline auto to_string(
const Location& l) {
return l.dump(); }
94 inline std::ostream& operator<<(std::ostream& out,
const Location& l) {
101 extern const Location None;
108 struct hash<hilti::Location> {
110 return hilti::rt::hashCombine(std::hash<std::string>()(x._file), x._from_line, x._to_line, x._from_character,
Definition: location.h:17
Location merge(const Location &loc) const
Definition: location.cc:15
std::string dump(bool no_path=false) const
Definition: location.cc:28
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:29