Added option --print-start-from to list all possible 'start_from' values (fixes #94)

This commit is contained in:
Bartek Kryza
2023-07-05 21:56:01 +02:00
parent e6202d4e5a
commit 51e31b4bf7
8 changed files with 119 additions and 42 deletions

View File

@@ -179,15 +179,15 @@ void generator::generate_activity(const activity &a, std::ostream &ostr,
else if (m.type() == message_t::kIf) {
print_debug(m, ostr);
ostr << "alt";
if (m.condition_text())
ostr << " " << m.condition_text().value();
if (const auto &text = m.condition_text(); text.has_value())
ostr << " " << text.value();
ostr << '\n';
}
else if (m.type() == message_t::kElseIf) {
print_debug(m, ostr);
ostr << "else";
if (m.condition_text())
ostr << " " << m.condition_text().value();
if (const auto &text = m.condition_text(); text.has_value())
ostr << " " << text.value();
ostr << '\n';
}
else if (m.type() == message_t::kElse) {
@@ -200,8 +200,8 @@ void generator::generate_activity(const activity &a, std::ostream &ostr,
else if (m.type() == message_t::kWhile) {
print_debug(m, ostr);
ostr << "loop";
if (m.condition_text())
ostr << " " << m.condition_text().value();
if (const auto &text = m.condition_text(); text.has_value())
ostr << " " << text.value();
ostr << '\n';
}
else if (m.type() == message_t::kWhileEnd) {
@@ -210,8 +210,8 @@ void generator::generate_activity(const activity &a, std::ostream &ostr,
else if (m.type() == message_t::kFor) {
print_debug(m, ostr);
ostr << "loop";
if (m.condition_text())
ostr << " " << m.condition_text().value();
if (const auto &text = m.condition_text(); text.has_value())
ostr << " " << text.value();
ostr << '\n';
}
else if (m.type() == message_t::kForEnd) {
@@ -220,8 +220,8 @@ void generator::generate_activity(const activity &a, std::ostream &ostr,
else if (m.type() == message_t::kDo) {
print_debug(m, ostr);
ostr << "loop";
if (m.condition_text())
ostr << " " << m.condition_text().value();
if (const auto &text = m.condition_text(); text.has_value())
ostr << " " << text.value();
ostr << '\n';
}
else if (m.type() == message_t::kDoEnd) {
@@ -253,8 +253,8 @@ void generator::generate_activity(const activity &a, std::ostream &ostr,
else if (m.type() == message_t::kConditional) {
print_debug(m, ostr);
ostr << "alt";
if (m.condition_text())
ostr << " " << m.condition_text().value();
if (const auto &text = m.condition_text(); text.has_value())
ostr << " " << text.value();
ostr << '\n';
}
else if (m.type() == message_t::kConditionalElse) {

View File

@@ -181,6 +181,22 @@ bool diagram::should_include(
dynamic_cast<const common::model::source_location &>(p));
}
std::vector<std::string> diagram::list_start_from_values() const
{
std::vector<std::string> result;
for (const auto &[from_id, act] : sequences_) {
const auto &from_activity = *(participants_.at(from_id));
result.push_back(from_activity.full_name(false));
}
std::sort(result.begin(), result.end());
return result;
}
void diagram::print() const
{
LOG_TRACE(" --- Participants ---");

View File

@@ -212,6 +212,13 @@ public:
*/
bool should_include(const sequence_diagram::model::participant &p) const;
/**
* @brief Get list of all possible 'start_from' values in the model
*
* @return List of all possible 'start_from' values
*/
std::vector<std::string> list_start_from_values() const;
/**
* @brief Once the diagram is complete, run any final processing.
*