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
00032 class Location {
00033
00034 public:
00036 Location() : offset(0) { }
00037
00039 Location(unsigned offset) : offset(offset) { }
00040
00045 bool isInvalid() const { return offset == 0; }
00046
00048 bool isValid() const { return !isInvalid(); }
00049
00051 unsigned getOffset() const { return offset; }
00052
00054 operator unsigned() const { return offset; }
00055
00056 private:
00057 unsigned offset;
00058 };
00059
00073 class SourceLocation {
00074
00075 public:
00084 SourceLocation(unsigned line, unsigned column, const std::string &identity)
00085 : line(line), column(column), identity(identity) { }
00086
00088 unsigned getLine() const { return line; }
00089
00091 unsigned getColumn() const { return column; }
00092
00094 const std::string &getIdentity() const { return identity; }
00095
00096 private:
00097 unsigned line;
00098 unsigned column;
00099 std::string identity;
00100 };
00101
00102 }
00103
00104 #endif