#ifndef TOOLS_GN_LOCATION_H_
#define TOOLS_GN_LOCATION_H_
#include <string>
class InputFile;
class Location {
public:
Location();
Location(const InputFile* file, int line_number, int column_number);
const InputFile* file() const { return file_; }
int line_number() const { return line_number_; }
int column_number() const { return column_number_; }
bool is_null() const { return *this == Location(); }
bool operator==(const Location& other) const;
bool operator!=(const Location& other) const;
bool operator<(const Location& other) const;
bool operator<=(const Location& other) const;
bool operator>(const Location& other) const { return !(*this <= other); }
bool operator>=(const Location& other) const { return !(*this < other); }
std::string Describe(bool include_column_number) const;
private:
const InputFile* file_ = nullptr;
int line_number_ = -1;
int column_number_ = -1;
};
class LocationRange {
public:
LocationRange();
LocationRange(const Location& begin, const Location& end);
const Location& begin() const { return begin_; }
const Location& end() const { return end_; }
bool is_null() const {
return begin_.is_null();
}
LocationRange Union(const LocationRange& other) const;
private:
Location begin_;
Location end_;
};
#endif