diff --git a/src/Cursor.h b/src/Cursor.h index 647007e..82ab0c0 100644 --- a/src/Cursor.h +++ b/src/Cursor.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace clangmm { class Cursor { @@ -212,6 +213,15 @@ namespace clangmm { std::string get_type_description() const; std::string get_brief_comments() const; + friend std::ostream &operator<<(std::ostream &os, const Cursor &cursor) { + auto offsets=cursor.get_source_range().get_offsets(); + os << cursor.get_source_location().get_path() << ":" + << offsets.first.line << ":" << offsets.first.index << "-" + << offsets.second.line << ":" << offsets.second.index << " " + << cursor.get_spelling(); + return os; + } + CXCursor cx_cursor; }; } // namespace clangmm diff --git a/src/Token.h b/src/Token.h index ce5105c..89b5bbd 100644 --- a/src/Token.h +++ b/src/Token.h @@ -5,6 +5,7 @@ #include "SourceRange.h" #include "Cursor.h" #include +#include namespace clangmm { class Token { @@ -28,6 +29,15 @@ namespace clangmm { clangmm::Cursor get_cursor() const {return clangmm::Cursor(cx_cursor);} bool is_identifier() const; + + friend std::ostream &operator<<(std::ostream &os, const Token &token) { + auto offsets=token.get_source_range().get_offsets(); + os << token.get_source_location().get_path() << ":" + << offsets.first.line << ":" << offsets.first.index << "-" + << offsets.second.line << ":" << offsets.second.index << " " + << token.get_spelling(); + return os; + } CXTranslationUnit &cx_tu; CXToken& cx_token;