Removed cppast dependency

This commit is contained in:
Bartek Kryza
2022-08-03 22:12:08 +02:00
parent 5917d341e2
commit 487e5d435b
46 changed files with 167 additions and 1230 deletions

View File

@@ -39,13 +39,11 @@ public:
virtual diagram_t type() const = 0;
virtual std::optional<
std::reference_wrapper<clanguml::common::model::diagram_element>>
get(const std::string &full_name) const = 0;
virtual common::optional_ref<clanguml::common::model::diagram_element> get(
const std::string &full_name) const = 0;
virtual std::optional<
std::reference_wrapper<clanguml::common::model::diagram_element>>
get(const diagram_element::id_t id) const = 0;
virtual common::optional_ref<clanguml::common::model::diagram_element> get(
const diagram_element::id_t id) const = 0;
diagram(const diagram &) = delete;
diagram(diagram &&);

View File

@@ -295,25 +295,25 @@ tvl::value_t context_filter::match(const diagram &d, const element &e) const
if (context_root.has_value()) {
// This is a direct match to the context root
if (context_root.value().get().id() == e.id())
if (context_root.value().id() == e.id())
return true;
// Return a positive match if the element e is in a direct
// relationship with any of the context_root's
for (const relationship &rel :
context_root.value().get().relationships()) {
context_root.value().relationships()) {
if (rel.destination() == e.id())
return true;
}
for (const relationship &rel : e.relationships()) {
if (rel.destination() == context_root.value().get().id())
if (rel.destination() == context_root.value().id())
return true;
}
// Return a positive match if the context_root is a parent
// of the element
for (const class_diagram::model::class_parent &p :
context_root.value().get().parents()) {
context_root.value().parents()) {
if (p.name() == e.full_name(false))
return true;
}
@@ -322,8 +322,7 @@ tvl::value_t context_filter::match(const diagram &d, const element &e) const
for (const class_diagram::model::class_parent &p :
static_cast<const class_diagram::model::class_ &>(e)
.parents()) {
if (p.name() ==
context_root.value().get().full_name(false))
if (p.name() == context_root.value().full_name(false))
return true;
}
}

View File

@@ -221,7 +221,7 @@ private:
while (parent.has_value()) {
parents.emplace(std::ref(parent.value()));
parent = detail::get<ElementT, DiagramT>(
cd, parent.value().get().path().to_string());
cd, parent.value().path().to_string());
}
});

View File

@@ -19,8 +19,8 @@
#include "path.h"
#include <optional>
#include <string>
#include <type_safe/optional.hpp>
#include <vector>
namespace clanguml::common::model {

View File

@@ -19,9 +19,8 @@
#include "util/util.h"
#include <type_safe/optional_ref.hpp>
#include <iostream>
#include <optional>
#include <string>
#include <vector>
@@ -84,7 +83,7 @@ public:
if (path.is_empty() || !has_element(path[0])) {
LOG_DBG("Nested element {} not found in element", path.to_string());
return type_safe::optional_ref<V>{};
return optional_ref<V>{};
}
if (path.size() == 1) {
@@ -94,13 +93,13 @@ public:
auto p = get_element<T>(path[0]);
if (!p)
return type_safe::optional_ref<V>{};
return optional_ref<V>{};
if (dynamic_cast<nested_trait<T, Path> *>(&p.value()))
return dynamic_cast<nested_trait<T, Path> &>(p.value())
.get_element<V>(Path{path.begin() + 1, path.end()});
return type_safe::optional_ref<V>{};
return optional_ref<V>{};
}
template <typename V = T> auto get_element_parent(const T &element) const
@@ -109,10 +108,10 @@ public:
auto parent = get_element(path);
if (parent.has_value())
return type_safe::optional_ref<V>{
type_safe::ref<V>(dynamic_cast<V &>(parent.value()))};
return optional_ref<V>{
std::ref<V>(dynamic_cast<V &>(parent.value()))};
return type_safe::optional_ref<V>{};
return optional_ref<V>{};
}
template <typename V = T> auto get_element(const std::string &name) const
@@ -123,15 +122,14 @@ public:
[&](const auto &p) { return name == p->name(); });
if (it == elements_.end())
return type_safe::optional_ref<V>{type_safe::nullopt};
return optional_ref<V>{};
assert(it->get() != nullptr);
if (dynamic_cast<V *>(it->get()))
return type_safe::optional_ref<V>{
type_safe::ref<V>(dynamic_cast<V &>(*it->get()))};
return optional_ref<V>{std::ref<V>(dynamic_cast<V &>(*it->get()))};
return type_safe::optional_ref<V>{type_safe::nullopt};
return optional_ref<V>{};
}
bool has_element(const std::string &name) const

View File

@@ -24,7 +24,6 @@
#include "util/util.h"
#include <spdlog/spdlog.h>
#include <type_safe/optional_ref.hpp>
#include <set>
#include <string>

View File

@@ -19,8 +19,8 @@
#include "util/util.h"
#include <optional>
#include <string>
#include <type_safe/optional.hpp>
#include <vector>
namespace clanguml::common::model {
@@ -130,7 +130,7 @@ public:
void pop_back() { path_.pop_back(); }
type_safe::optional<path> parent() const
std::optional<path> parent() const
{
if (size() <= 1) {
return {};

View File

@@ -27,7 +27,6 @@
#include "util/util.h"
#include <spdlog/spdlog.h>
#include <type_safe/optional_ref.hpp>
#include <set>
#include <string>