Add full_name() function
This commit is contained in:
parent
a2c54165bd
commit
0b88656cc2
5 changed files with 51 additions and 0 deletions
19
src/cpp_entity.cpp
Normal file
19
src/cpp_entity.cpp
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
// Copyright (C) 2017 Jonathan Müller <jonathanmueller.dev@gmail.com>
|
||||
// This file is subject to the license terms in the LICENSE file
|
||||
// found in the top-level directory of this distribution.
|
||||
|
||||
#include <cppast/cpp_entity.hpp>
|
||||
|
||||
using namespace cppast;
|
||||
|
||||
std::string cppast::full_name(const cpp_entity& e)
|
||||
{
|
||||
std::string scopes;
|
||||
|
||||
for (auto cur = e.parent(); cur; cur = cur.value().parent())
|
||||
// prepend each scope, if there is any
|
||||
type_safe::with(cur.value().scope_name(),
|
||||
[&](const std::string& cur_scope) { scopes = cur_scope + "::" + scopes; });
|
||||
|
||||
return scopes + e.name();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue