Refactored namespace_relative to ns_relative

This commit is contained in:
Bartek Kryza
2021-02-26 21:41:36 +01:00
parent 0abc6296b3
commit 474f38c349
3 changed files with 11 additions and 12 deletions

View File

@@ -99,7 +99,7 @@ public:
else
ostr << "class ";
ostr << namespace_relative(m_config.using_namespace, c.name) << " {"
ostr << ns_relative(m_config.using_namespace, c.name) << " {"
<< std::endl;
//
@@ -149,9 +149,9 @@ public:
}
for (const auto &r : c.relationships) {
ostr << namespace_relative(m_config.using_namespace, c.name) << " "
ostr << ns_relative(m_config.using_namespace, c.name) << " "
<< to_string(r.type) << " "
<< namespace_relative(m_config.using_namespace, r.destination);
<< ns_relative(m_config.using_namespace, r.destination);
if (!r.label.empty())
ostr << " : " << r.label;
@@ -161,8 +161,8 @@ public:
void generate(const enum_ &e, std::ostream &ostr) const
{
ostr << "Enum " << namespace_relative(m_config.using_namespace, e.name)
<< " {" << std::endl;
ostr << "Enum " << ns_relative(m_config.using_namespace, e.name) << " {"
<< std::endl;
for (const auto &enum_constant : e.constants) {
ostr << enum_constant << std::endl;

View File

@@ -65,8 +65,8 @@ public:
void generate_call(const message &m, std::ostream &ostr) const
{
const auto from = namespace_relative(m_config.using_namespace, m.from);
const auto to = namespace_relative(m_config.using_namespace, m.to);
const auto from = ns_relative(m_config.using_namespace, m.from);
const auto to = ns_relative(m_config.using_namespace, m.to);
ostr << '"' << from << "\" "
<< "->"
@@ -76,9 +76,8 @@ public:
void generate_return(const message &m, std::ostream &ostr) const
{
if ((m.from != m.to) && (m.return_type != "void")) {
const auto from =
namespace_relative(m_config.using_namespace, m.from);
const auto to = namespace_relative(m_config.using_namespace, m.to);
const auto from = ns_relative(m_config.using_namespace, m.from);
const auto to = ns_relative(m_config.using_namespace, m.to);
ostr << '"' << to << "\" "
<< "-->"
@@ -89,7 +88,7 @@ public:
void generate_activity(const activity &a, std::ostream &ostr) const
{
for (const auto &m : a.messages) {
const auto to = namespace_relative(m_config.using_namespace, m.to);
const auto to = ns_relative(m_config.using_namespace, m.to);
generate_call(m, ostr);
ostr << "activate " << '"' << to << '"' << std::endl;
if (m_model.sequences.find(m.to_usr) != m_model.sequences.end())

View File

@@ -47,7 +47,7 @@ std::vector<std::string> split(std::string str, std::string delimiter)
return result;
}
std::string namespace_relative(
std::string ns_relative(
const std::vector<std::string> &namespaces, const std::string &n)
{
for (const auto &ns : namespaces) {