8 #include <hilti/rt/filesystem.h>
10 #include <hilti/base/util.h>
32 int from_character = -1,
33 int to_character = -1)
34 : _file(std::move(file)),
35 _from_line(from_line),
37 _from_character(from_character),
38 _to_character(to_character) {}
46 const auto& file()
const {
return _file; }
47 auto from()
const {
return _from_line; }
48 auto to()
const {
return _to_line; }
61 std::string
dump(
bool no_path =
false)
const;
67 explicit operator bool()
const;
70 operator std::string()
const {
return dump(); }
72 bool operator<(
const Location& other)
const {
73 return std::tie(_file, _from_line, _from_character, _to_line, _to_character) <
74 std::tie(other._file, other._from_line, other._from_character, other._to_line, other._to_character);
77 bool operator==(
const Location& other)
const {
78 return std::tie(_file, _from_line, _from_character, _to_line, _to_character) ==
79 std::tie(other._file, other._from_line, other._from_character, other._to_line, other._to_character);
87 int _from_character = -1;
88 int _to_character = -1;
94 inline auto to_string(
const Location& l) {
return l.dump(); }
97 inline std::ostream& operator<<(std::ostream& out,
const Location& l) {
107 static inline const Location None;
114 struct hash<hilti::Location> {
116 return hilti::rt::hashCombine(std::hash<std::string>()(x._file),
Definition: location.h:17
constexpr Location(std::string file="", int from_line=-1, int to_line=-1, int from_character=-1, int to_character=-1)
Definition: location.h:29
Location merge(const Location &loc) const
Definition: location.cc:13
std::string dump(bool no_path=false) const
Definition: location.cc:26