Add to_string() operation for cpp_entity_kind

This commit is contained in:
Jonathan Müller 2017-01-22 12:34:10 +01:00
commit c14e4dca40
2 changed files with 34 additions and 3 deletions

View file

@ -25,8 +25,11 @@ namespace cppast
count,
};
/// \returns A human readable string describing the entity kind.
const char* to_string(cpp_entity_kind kind) noexcept;
/// \returns Whether or not a given entity kind is a C++ type.
bool is_type(cpp_entity_kind type) noexcept;
bool is_type(cpp_entity_kind kind) noexcept;
} // namespace cppast
#endif // CPPAST_CPP_ENTITY_KIND_HPP_INCLUDED

View file

@ -6,9 +6,37 @@
using namespace cppast;
bool cppast::is_type(cpp_entity_kind type) noexcept
const char* cppast::to_string(cpp_entity_kind kind) noexcept
{
switch (type)
switch (kind)
{
case cpp_entity_kind::file_t:
return "file";
case cpp_entity_kind::namespace_t:
return "namespace";
case cpp_entity_kind::namespace_alias_t:
return "namespace alias";
case cpp_entity_kind::using_directive_t:
return "using directive";
case cpp_entity_kind::using_declaration_t:
return "using declaration";
case cpp_entity_kind::enum_t:
return "enum";
case cpp_entity_kind::enum_value_t:
return "enum value";
case cpp_entity_kind::count:
break;
}
return "invalid";
}
bool cppast::is_type(cpp_entity_kind kind) noexcept
{
switch (kind)
{
case cpp_entity_kind::enum_t:
return true;