00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef COMMA_BASIC_LOCATION_HDR_GUARD
00010 #define COMMA_BASIC_LOCATION_HDR_GUARD
00011
00012 #include <string>
00013
00014 namespace comma {
00015
00016 class TextProvider;
00017
00034 class Location {
00035
00036 public:
00038 Location() : offset(0) { }
00039
00041 Location(unsigned offset) : offset(offset) { }
00042
00047 bool isInvalid() const { return offset == 0; }
00048
00050 bool isValid() const { return !isInvalid(); }
00051
00053 unsigned getOffset() const { return offset; }
00054
00056 operator unsigned() const { return offset; }
00057
00058 private:
00059 unsigned offset;
00060 };
00061
00073 class SourceLocation {
00074
00075 public:
00083 SourceLocation(unsigned line, unsigned column, const TextProvider *provider)
00084 : line(line), column(column), provider(provider) { }
00085
00087 SourceLocation() : line(0), column(0), provider(0) { }
00088
00090 unsigned getLine() const { return line; }
00091
00093 unsigned getColumn() const { return column; }
00094
00096 const TextProvider *getTextProvider() const { return provider; }
00097
00098 private:
00099 unsigned line;
00100 unsigned column;
00101 const TextProvider *provider;
00102 };
00103
00104 }
00105
00106 #endif