You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
982 B

11 years ago
#ifndef SOURCELOCATION_H_
#define SOURCELOCATION_H_
#include <clang-c/Index.h>
#include <string>
11 years ago
namespace clang {
class Offset {
public:
Offset() {}
Offset(unsigned line, unsigned index): line(line), index(index) {}
bool operator==(const clang::Offset &o) {return (line==o.line && index==o.index);}
bool operator!=(const clang::Offset &o) {return !(*this==o);}
unsigned line;
unsigned index; //byte index in line (not char number)
};
11 years ago
class SourceLocation {
11 years ago
friend class TranslationUnit;
SourceLocation(CXTranslationUnit &tu, const std::string &filepath, unsigned offset);
11 years ago
public:
SourceLocation(const CXSourceLocation& cx_location) : cx_location(cx_location) {}
11 years ago
11 years ago
public:
std::string get_path();
clang::Offset get_offset();
11 years ago
CXSourceLocation cx_location;
11 years ago
private:
void get_data(std::string *path, unsigned *line, unsigned *column, unsigned *offset);
11 years ago
};
} // namespace clang
#endif // SOURCELOCATION_H_