Add to_string() operation for cpp_entity_kind
This commit is contained in:
parent
87aba96c5b
commit
c14e4dca40
2 changed files with 34 additions and 3 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue