Added handling of method parameters default values

This commit is contained in:
Bartek Kryza
2021-03-18 20:33:46 +01:00
parent fcafef4b85
commit 3c0e9d51d2
7 changed files with 46 additions and 12 deletions

View File

@@ -82,12 +82,15 @@ struct method_parameter {
std::string name;
std::string default_value;
std::string to_string() const
std::string to_string(
const std::vector<std::string> &using_namespaces) const
{
using namespace clanguml::util;
auto t = ns_relative(using_namespaces, type);
if (default_value.empty())
return fmt::format("{} {}", type, name);
return fmt::format("{} {}", t, name);
return fmt::format("{} {} = {}", type, name, default_value);
return fmt::format("{} {} = {}", t, name, default_value);
}
};

View File

@@ -223,6 +223,7 @@ static enum CXChildVisitResult method_parameter_visitor(
method_parameter mp;
mp.name = cursor.spelling();
mp.type = cursor.type().spelling();
mp.default_value = cursor.default_value();
ctx->element.parameters.emplace_back(std::move(mp));