Refactored generator function to common namespace
This commit is contained in:
@@ -107,35 +107,4 @@ void generator::generate(std::ostream &ostr) const
|
||||
ostr << "@enduml" << std::endl;
|
||||
}
|
||||
|
||||
clanguml::sequence_diagram::model::diagram generate(
|
||||
cppast::libclang_compilation_database &db, const std::string &name,
|
||||
clanguml::config::sequence_diagram &diagram)
|
||||
{
|
||||
spdlog::info("Generating diagram {}.puml", name);
|
||||
clanguml::sequence_diagram::model::diagram d;
|
||||
d.name = name;
|
||||
|
||||
cppast::cpp_entity_index idx;
|
||||
cppast::simple_file_parser<cppast::libclang_parser> parser{
|
||||
type_safe::ref(idx)};
|
||||
|
||||
clanguml::sequence_diagram::visitor::translation_unit_visitor visitor(
|
||||
idx, d, diagram);
|
||||
|
||||
// Get all translation units matching the glob from diagram
|
||||
// configuration
|
||||
std::vector<std::string> translation_units{};
|
||||
for (const auto &g : diagram.glob()) {
|
||||
spdlog::debug("Processing glob: {}", g);
|
||||
const auto matches = glob::rglob(g);
|
||||
std::copy(matches.begin(), matches.end(),
|
||||
std::back_inserter(translation_units));
|
||||
}
|
||||
cppast::parse_files(parser, translation_units, db);
|
||||
|
||||
for (auto &file : parser.files())
|
||||
visitor(file);
|
||||
|
||||
return d;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,10 +60,6 @@ public:
|
||||
void generate(std::ostream &ostr) const;
|
||||
};
|
||||
|
||||
clanguml::sequence_diagram::model::diagram generate(
|
||||
cppast::libclang_compilation_database &db, const std::string &name,
|
||||
clanguml::config::sequence_diagram &diagram);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,6 +29,10 @@
|
||||
|
||||
namespace clanguml::sequence_diagram::model {
|
||||
|
||||
std::string diagram::name() const { return name_; }
|
||||
|
||||
void diagram::set_name(const std::string &name) { name_ = name; }
|
||||
|
||||
std::string diagram::to_alias(const std::string &full_name) const
|
||||
{
|
||||
return full_name;
|
||||
|
||||
@@ -25,12 +25,18 @@
|
||||
namespace clanguml::sequence_diagram::model {
|
||||
|
||||
struct diagram {
|
||||
std::string name() const;
|
||||
|
||||
void set_name(const std::string &name);
|
||||
|
||||
std::string to_alias(const std::string &full_name) const;
|
||||
|
||||
bool started{false};
|
||||
std::string name;
|
||||
|
||||
std::map<std::uint_least64_t, activity> sequences;
|
||||
|
||||
private:
|
||||
std::string name_;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user