Add cpp_using_declaration

This commit is contained in:
Jonathan Müller 2017-01-21 13:44:35 +01:00
commit 9d60bd2992
3 changed files with 38 additions and 1 deletions

View file

@ -17,6 +17,7 @@ namespace cppast
namespace_t,
namespace_alias_t,
using_directive_t,
using_declaration_t,
count,
};

View file

@ -117,7 +117,7 @@ namespace cppast
return std::unique_ptr<cpp_using_directive>(new cpp_using_directive(target));
}
/// \returns The [cppast::cpp_namespace_ref]() that is exposed.
/// \returns The [cppast::cpp_namespace_ref]() that is being used.
/// \notes The name of the reference is the same as the name of this entity.
cpp_namespace_ref target() const
{
@ -137,6 +137,41 @@ namespace cppast
cpp_entity_id target_;
};
/// A [cppast::cpp_entity]() modelling a using declaration.
///
/// A using declaration is `using std::vector`, for example.
class cpp_using_declaration final : public cpp_entity
{
public:
/// \returns A newly created using declaration.
/// \notes It is not meant to be registered at the [cppast::cpp_entity_index](),
/// as nothing can refer to it.
static std::unique_ptr<cpp_using_declaration> build(const cpp_entity_ref& target)
{
return std::unique_ptr<cpp_using_declaration>(new cpp_using_declaration(target));
}
/// \returns The [cppast::cpp_entity_ref]() that is being used.
/// \notes The name of the reference is the same as the name of this entity.
cpp_entity_ref target() const
{
return {target_, name()};
}
private:
cpp_using_declaration(const cpp_entity_ref& target)
: cpp_entity(target.name()), target_(target.id())
{
}
cpp_entity_type do_get_entity_type() const noexcept override
{
return cpp_entity_type::using_declaration_t;
}
cpp_entity_id target_;
};
} // namespace cppast
#endif // CPPAST_CPP_NAMESPACE_HPP_INCLUDED

View file

@ -16,6 +16,7 @@ bool cppast::is_scope(cpp_entity_type type) noexcept
case cpp_entity_type::file_t:
case cpp_entity_type::namespace_alias_t:
case cpp_entity_type::using_directive_t:
case cpp_entity_type::using_declaration_t:
case cpp_entity_type::count:
break;
}