Renamed common::id_t to eid_t to avoid conflicts with system id_t

This commit is contained in:
Bartek Kryza
2024-06-05 21:19:46 +02:00
parent 2cf9d2f22a
commit 420475ab64
57 changed files with 370 additions and 356 deletions

View File

@@ -24,6 +24,7 @@
namespace clanguml::class_diagram::generators::mermaid {
using clanguml::common::eid_t;
using clanguml::common::generators::mermaid::indent;
using clanguml::common::generators::mermaid::render_name;
@@ -405,7 +406,7 @@ void generator::generate_relationships(
LOG_DBG("== Processing relationship {}", to_string(r.type()));
std::stringstream relstr;
clanguml::common::id_t destination{};
eid_t destination{};
try {
destination = r.destination();
@@ -513,7 +514,7 @@ void generator::generate_relationships(
LOG_DBG("== Processing relationship {}", to_string(r.type()));
std::stringstream relstr;
clanguml::common::id_t destination{};
eid_t destination{};
try {
destination = r.destination();
@@ -584,7 +585,7 @@ void generator::generate_relationships(const enum_ &e, std::ostream &ostr) const
if (!model().should_include(r.type()))
continue;
clanguml::common::id_t destination{};
eid_t destination{};
std::stringstream relstr;
try {
destination = r.destination();

View File

@@ -488,7 +488,7 @@ void generator::generate_relationships(
plantuml_common::to_plantuml(r, config()));
std::stringstream relstr;
clanguml::common::id_t destination{};
eid_t destination{};
try {
destination = r.destination();
@@ -583,7 +583,7 @@ void generator::generate_relationships(
LOG_DBG("== Processing relationship {}", to_string(r.type()));
std::stringstream relstr;
clanguml::common::id_t destination{};
eid_t destination{};
try {
destination = r.destination();
@@ -664,7 +664,7 @@ void generator::generate_relationships(const enum_ &e, std::ostream &ostr) const
if (!model().should_include(r.type()))
continue;
clanguml::common::id_t destination{};
eid_t destination{};
std::stringstream relstr;
try {
destination = r.destination();

View File

@@ -52,6 +52,7 @@ using clanguml::class_diagram::model::class_member;
using clanguml::class_diagram::model::class_method;
using clanguml::class_diagram::model::concept_;
using clanguml::class_diagram::model::enum_;
using clanguml::common::eid_t;
using clanguml::common::model::access_t;
using clanguml::common::model::package;
using clanguml::common::model::relationship;

View File

@@ -185,8 +185,6 @@ struct hash<std::reference_wrapper<clanguml::class_diagram::model::class_>> {
const std::reference_wrapper<clanguml::class_diagram::model::class_>
&key) const
{
using clanguml::common::id_t;
return std::hash<uint64_t>{}(key.get().id().value());
}
};

View File

@@ -24,9 +24,9 @@ void class_parent::set_name(const std::string &name) { name_ = name; }
std::string class_parent::name() const { return name_; }
void class_parent::set_id(clanguml::common::id_t id) { id_ = id; }
void class_parent::set_id(eid_t id) { id_ = id; }
clanguml::common::id_t class_parent::id() const noexcept { return id_; }
eid_t class_parent::id() const noexcept { return id_; }
void class_parent::is_virtual(bool is_virtual) { is_virtual_ = is_virtual; }

View File

@@ -25,6 +25,8 @@
namespace clanguml::class_diagram::model {
using clanguml::common::eid_t;
/**
* @brief Class parent relationship model.
*
@@ -59,14 +61,14 @@ public:
*
* @param id Id of the parent class.
*/
void set_id(clanguml::common::id_t id);
void set_id(eid_t id);
/**
* @brief Get the id of class parent.
*
* @return Id of the parent class.
*/
clanguml::common::id_t id() const noexcept;
eid_t id() const noexcept;
/**
* @brief Set whether the parent is virtual.
@@ -97,7 +99,7 @@ public:
common::model::access_t access() const;
private:
clanguml::common::id_t id_{};
eid_t id_{};
std::string name_;
bool is_virtual_{false};
common::model::access_t access_{common::model::access_t::kPublic};

View File

@@ -74,7 +74,7 @@ common::optional_ref<clanguml::common::model::diagram_element> diagram::get(
}
common::optional_ref<clanguml::common::model::diagram_element> diagram::get(
const clanguml::common::id_t id) const
const eid_t id) const
{
common::optional_ref<clanguml::common::model::diagram_element> res;
@@ -153,7 +153,7 @@ void diagram::get_parents(
}
}
bool diagram::has_element(clanguml::common::id_t id) const
bool diagram::has_element(eid_t id) const
{
const auto has_class = std::any_of(classes().begin(), classes().end(),
[id](const auto &c) { return c.get().id() == id; });
@@ -171,7 +171,7 @@ bool diagram::has_element(clanguml::common::id_t id) const
[id](const auto &c) { return c.get().id() == id; });
}
std::string diagram::to_alias(clanguml::common::id_t id) const
std::string diagram::to_alias(eid_t id) const
{
LOG_DBG("Looking for alias for {}", id);
@@ -224,12 +224,12 @@ inja::json diagram::context() const
void diagram::remove_redundant_dependencies()
{
using common::id_t;
using common::eid_t;
using common::model::relationship;
using common::model::relationship_t;
for (auto &c : element_view<class_>::view()) {
std::set<id_t> dependency_relationships_to_remove;
std::set<eid_t> dependency_relationships_to_remove;
for (auto &r : c.get().relationships()) {
if (r.type() != relationship_t::kDependency)

View File

@@ -103,7 +103,7 @@ public:
* @param id Element id.
* @return Optional reference to a diagram element.
*/
opt_ref<diagram_element> get(common::id_t id) const override;
opt_ref<diagram_element> get(eid_t id) const override;
/**
* @brief Get list of references to classes in the diagram model.
@@ -172,7 +172,7 @@ public:
* @param id Id of the element
* @return Optional reference to a diagram element
*/
template <typename ElementT> opt_ref<ElementT> find(common::id_t id) const;
template <typename ElementT> opt_ref<ElementT> find(eid_t id) const;
/**
* @brief Get reference to vector of elements of specific type
@@ -218,7 +218,7 @@ public:
* @param id Id of the diagram element.
* @return PlantUML alias.
*/
std::string to_alias(common::id_t id) const;
std::string to_alias(eid_t id) const;
/**
* @brief Given an initial set of classes, add all their parents to the
@@ -235,7 +235,7 @@ public:
* @param id Id of the element.
* @return True, if diagram contains an element with a specific id.
*/
bool has_element(common::id_t id) const override;
bool has_element(eid_t id) const override;
/**
* @brief Remove redundant dependency relationships
@@ -431,8 +431,7 @@ std::vector<opt_ref<ElementT>> diagram::find(
return result;
}
template <typename ElementT>
opt_ref<ElementT> diagram::find(common::id_t id) const
template <typename ElementT> opt_ref<ElementT> diagram::find(eid_t id) const
{
for (const auto &element : element_view<ElementT>::view()) {
if (element.get().id() == id) {

View File

@@ -123,14 +123,14 @@ bool translation_unit_visitor::VisitEnumDecl(clang::EnumDecl *enm)
const auto *parent = enm->getParent();
// Id of parent class or struct in which this enum is potentially nested
std::optional<common::id_t> parent_id_opt;
std::optional<eid_t> parent_id_opt;
if (parent != nullptr) {
const auto *parent_record_decl =
clang::dyn_cast<clang::RecordDecl>(parent);
if (parent_record_decl != nullptr) {
common::id_t local_id{parent_record_decl->getID()};
eid_t local_id{parent_record_decl->getID()};
// First check if the parent has been added to the diagram as
// regular class
@@ -222,7 +222,7 @@ bool translation_unit_visitor::VisitClassTemplateSpecializationDecl(
if (!template_specialization.template_specialization_found()) {
// Only do this if we haven't found a better specialization during
// construction of the template specialization
const common::id_t ast_id{cls->getSpecializedTemplate()->getID()};
const eid_t ast_id{cls->getSpecializedTemplate()->getID()};
const auto maybe_id = id_mapper().get_global_id(ast_id);
if (maybe_id.has_value())
template_specialization.add_relationship(
@@ -621,7 +621,7 @@ void translation_unit_visitor::process_concept_specialization_relationships(
should_include(cpt)) {
const auto cpt_name = cpt->getNameAsString();
const common::id_t ast_id{cpt->getID()};
const eid_t ast_id{cpt->getID()};
const auto maybe_id = id_mapper().get_global_id(ast_id);
if (!maybe_id)
return;
@@ -707,7 +707,7 @@ bool translation_unit_visitor::VisitCXXRecordDecl(clang::CXXRecordDecl *cls)
if (cls->isTemplated() && (cls->getDescribedTemplate() != nullptr)) {
// If the described templated of this class is already in the model
// skip it:
const common::id_t ast_id{cls->getDescribedTemplate()->getID()};
const eid_t ast_id{cls->getDescribedTemplate()->getID()};
if (id_mapper().get_global_id(ast_id))
return true;
}
@@ -869,7 +869,7 @@ void translation_unit_visitor::process_record_parent(
{
const auto *parent = cls->getParent();
std::optional<common::id_t> id_opt;
std::optional<eid_t> id_opt;
auto parent_ns = ns;
if (parent != nullptr) {
@@ -879,7 +879,7 @@ void translation_unit_visitor::process_record_parent(
if (parent_record_decl != nullptr) {
parent_ns = common::get_tag_namespace(*parent_record_decl);
common::id_t ast_id{parent_record_decl->getID()};
eid_t ast_id{parent_record_decl->getID()};
// First check if the parent has been added to the diagram as
// regular class
@@ -2176,7 +2176,7 @@ void translation_unit_visitor::add_concept(std::unique_ptr<concept_> &&c)
void translation_unit_visitor::find_instantiation_relationships(
common::model::template_element &template_instantiation_base,
const std::string &full_name, common::id_t templated_decl_id)
const std::string &full_name, eid_t templated_decl_id)
{
auto &template_instantiation = dynamic_cast<class_diagram::model::class_ &>(
template_instantiation_base);
@@ -2187,7 +2187,7 @@ void translation_unit_visitor::find_instantiation_relationships(
std::string best_match_full_name{};
auto full_template_name = template_instantiation.full_name(false);
int best_match{};
common::id_t best_match_id{};
eid_t best_match_id{};
for (const auto templ : diagram().classes()) {
if (templ.get() == template_instantiation)
@@ -2206,7 +2206,7 @@ void translation_unit_visitor::find_instantiation_relationships(
}
auto templated_decl_global_id =
id_mapper().get_global_id(templated_decl_id).value_or(common::id_t{});
id_mapper().get_global_id(templated_decl_id).value_or(eid_t{});
if (best_match_id.value() > 0) {
destination = best_match_full_name;

View File

@@ -45,6 +45,7 @@ using clanguml::class_diagram::model::concept_;
using clanguml::class_diagram::model::diagram;
using clanguml::class_diagram::model::enum_;
using clanguml::class_diagram::model::method_parameter;
using clanguml::common::eid_t;
using clanguml::common::model::access_t;
using clanguml::common::model::namespace_;
using clanguml::common::model::relationship;
@@ -149,7 +150,7 @@ public:
void find_instantiation_relationships(
common::model::template_element &template_instantiation_base,
const std::string &full_name, common::id_t templated_decl_id);
const std::string &full_name, eid_t templated_decl_id);
private:
/**
@@ -432,8 +433,7 @@ private:
template_builder_t template_builder_;
std::map<common::id_t,
std::unique_ptr<clanguml::class_diagram::model::class_>>
std::map<eid_t, std::unique_ptr<clanguml::class_diagram::model::class_>>
forward_declarations_;
std::map<int64_t /* local anonymous struct id */,