This commit is contained in:
Bartek Kryza
2022-08-12 00:57:12 +02:00
parent e4289c4cab
commit 0cd6a9d36e
4 changed files with 145 additions and 65 deletions

View File

@@ -20,9 +20,34 @@
namespace clanguml::common {
template <> id_t to_id(const std::string &full_name)
{
return std::hash<std::string>{}(full_name) >> 3;
}
template <> id_t to_id(const clang::NamespaceDecl &declaration)
{
return std::hash<std::string>{}(get_qualified_name(declaration)) >> 3;
return to_id(get_qualified_name(declaration));
}
template <> id_t to_id(const clang::RecordDecl &declaration)
{
return to_id(get_qualified_name(declaration));
}
template <> id_t to_id(const clang::EnumDecl &declaration)
{
return to_id(get_qualified_name(declaration));
}
template <> id_t to_id(const clang::TagDecl &declaration)
{
return to_id(get_qualified_name(declaration));
}
template <> id_t to_id(const clang::CXXRecordDecl &declaration)
{
return to_id(get_qualified_name(declaration));
}
template <> id_t to_id(const clang::EnumType &t) { return to_id(*t.getDecl()); }
@@ -34,7 +59,7 @@ template <> id_t to_id(const clang::TemplateSpecializationType &t)
template <> id_t to_id(const std::filesystem::path &file)
{
return std::hash<std::string>{}(file.lexically_normal()) >> 3;
return to_id(file.lexically_normal());
}
}

View File

@@ -39,13 +39,18 @@ template <typename T> std::string get_qualified_name(const T &declaration)
return qualified_name;
}
template <typename T> id_t to_id(const T &declaration)
{
return declaration.getID();
}
template <typename T> id_t to_id(const T &declaration);
template <> id_t to_id(const std::string &full_name);
template <> id_t to_id(const clang::NamespaceDecl &declaration);
template <> id_t to_id(const clang::CXXRecordDecl &declaration);
template <> id_t to_id(const clang::EnumDecl &declaration);
template <> id_t to_id(const clang::TagDecl &declaration);
template <> id_t to_id(const clang::EnumType &type);
template <> id_t to_id(const clang::TemplateSpecializationType &type);