diff --git a/include/cppast/cpp_entity_kind.hpp b/include/cppast/cpp_entity_kind.hpp index e5359d4..9033a61 100644 --- a/include/cppast/cpp_entity_kind.hpp +++ b/include/cppast/cpp_entity_kind.hpp @@ -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 diff --git a/src/cpp_entity_kind.cpp b/src/cpp_entity_kind.cpp index 23e9bff..feed0e1 100644 --- a/src/cpp_entity_kind.cpp +++ b/src/cpp_entity_kind.cpp @@ -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;