Add full_name() function

This commit is contained in:
Jonathan Müller 2017-01-21 22:59:38 +01:00
commit 0b88656cc2
5 changed files with 51 additions and 0 deletions

View file

@ -35,6 +35,13 @@ namespace cppast
return name_;
}
/// \returns The name of the new scope created by the entity,
/// if there is any.
type_safe::optional<std::string> scope_name() const
{
return do_get_scope_name();
}
/// \returns A [ts::optional_ref]() to the parent entity in the AST.
type_safe::optional_ref<const cpp_entity> parent() const noexcept
{
@ -51,6 +58,13 @@ namespace cppast
/// \returns The type of the entity.
virtual cpp_entity_type do_get_entity_type() const noexcept = 0;
/// \returns The name of the new scope created by the entity, if any.
/// By default, there is no scope created.
virtual type_safe::optional<std::string> do_get_scope_name() const
{
return type_safe::nullopt;
}
void on_insert(const cpp_entity& parent) noexcept
{
parent_ = parent;
@ -63,6 +77,9 @@ namespace cppast
friend struct detail::intrusive_list_access;
friend detail::intrusive_list_node<cpp_entity>;
};
/// \returns The full name of the [cppast::cpp_entity](), with all scopes.
std::string full_name(const cpp_entity& e);
} // namespace cppast
#endif // CPPAST_CPP_ENTITY_HPP_INCLUDED

View file

@ -106,6 +106,10 @@ namespace cppast
cpp_entity_type do_get_entity_type() const noexcept override;
/// \returns If the enum is scoped, the name of the enum,
/// otherwise [ts::nullopt]().
type_safe::optional<std::string> do_get_scope_name() const override;
std::unique_ptr<cpp_type> type_;
bool scoped_;
};

View file

@ -61,6 +61,12 @@ namespace cppast
cpp_entity_type do_get_entity_type() const noexcept override;
/// \returns The name of the namespace.
type_safe::optional<std::string> do_get_scope_name() const override
{
return name();
}
bool inline_;
};