Added namespace to common model instead of vector<string>
This commit is contained in:
@@ -114,8 +114,8 @@ std::string class_::full_name(bool relative) const
|
||||
using namespace clanguml::util;
|
||||
|
||||
std::ostringstream ostr;
|
||||
if (relative && starts_with(get_namespace(), using_namespaces()))
|
||||
ostr << ns_relative(using_namespaces(), name_and_ns());
|
||||
if (relative && starts_with(get_namespace(), using_namespace()))
|
||||
ostr << ns_relative(using_namespace(), name_and_ns());
|
||||
else
|
||||
ostr << name_and_ns();
|
||||
|
||||
@@ -134,11 +134,11 @@ std::ostringstream &class_::render_template_params(
|
||||
|
||||
if (!tmplt.type().empty())
|
||||
res.push_back(
|
||||
util::ns_relative(using_namespaces(), tmplt.type()));
|
||||
util::ns_relative(using_namespace(), tmplt.type()));
|
||||
|
||||
if (!tmplt.name().empty())
|
||||
res.push_back(
|
||||
util::ns_relative(using_namespaces(), tmplt.name()));
|
||||
util::ns_relative(using_namespace(), tmplt.name()));
|
||||
|
||||
if (!tmplt.default_value().empty()) {
|
||||
res.push_back("=");
|
||||
|
||||
@@ -40,7 +40,7 @@ std::string enum_::full_name(bool relative) const
|
||||
|
||||
std::ostringstream ostr;
|
||||
if (relative)
|
||||
ostr << ns_relative(using_namespaces(), name());
|
||||
ostr << ns_relative(using_namespace(), name());
|
||||
else
|
||||
ostr << name();
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ namespace clanguml::common::model {
|
||||
std::atomic_uint64_t element::m_nextId = 1;
|
||||
|
||||
element::element(const std::vector<std::string> &using_namespaces)
|
||||
: using_namespaces_{using_namespaces}
|
||||
: using_namespace_{using_namespaces}
|
||||
, m_id{m_nextId++}
|
||||
{
|
||||
for (const auto &n : using_namespaces_)
|
||||
for (const auto &n : using_namespace_)
|
||||
assert(!util::contains(n, "::"));
|
||||
}
|
||||
|
||||
@@ -64,12 +64,12 @@ void element::set_using_namespaces(const std::vector<std::string> &un)
|
||||
for (const auto &n : un)
|
||||
assert(!util::contains(n, "::"));
|
||||
|
||||
using_namespaces_ = un;
|
||||
using_namespace_ = un;
|
||||
}
|
||||
|
||||
const std::vector<std::string> &element::using_namespaces() const
|
||||
const std::vector<std::string> &element::using_namespace() const
|
||||
{
|
||||
return using_namespaces_;
|
||||
return using_namespace_;
|
||||
}
|
||||
|
||||
std::vector<relationship> &element::relationships() { return relationships_; }
|
||||
|
||||
@@ -54,7 +54,7 @@ public:
|
||||
std::vector<std::string> get_relative_namespace() const
|
||||
{
|
||||
auto relative_ns = namespace_;
|
||||
util::remove_prefix(relative_ns, using_namespaces_);
|
||||
util::remove_prefix(relative_ns, using_namespace_);
|
||||
return relative_ns;
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ public:
|
||||
|
||||
void set_using_namespaces(const std::vector<std::string> &un);
|
||||
|
||||
const std::vector<std::string> &using_namespaces() const;
|
||||
const std::vector<std::string> &using_namespace() const;
|
||||
|
||||
std::vector<relationship> &relationships();
|
||||
|
||||
@@ -82,7 +82,7 @@ protected:
|
||||
private:
|
||||
std::string name_;
|
||||
std::vector<std::string> namespace_;
|
||||
std::vector<std::string> using_namespaces_;
|
||||
std::vector<std::string> using_namespace_;
|
||||
std::vector<relationship> relationships_;
|
||||
|
||||
static std::atomic_uint64_t m_nextId;
|
||||
|
||||
@@ -31,7 +31,7 @@ package::package(const std::vector<std::string> &using_namespaces)
|
||||
std::string package::full_name(bool relative) const
|
||||
{
|
||||
auto fn = get_namespace();
|
||||
auto ns = using_namespaces();
|
||||
auto ns = using_namespace();
|
||||
|
||||
if (relative && (fn.size() >= ns.size())) {
|
||||
if (util::starts_with(fn, ns))
|
||||
|
||||
@@ -16,6 +16,14 @@ set(CLANG_UML_TEST_UTIL_HEADER
|
||||
catch.h
|
||||
)
|
||||
|
||||
set(CLANG_UML_TEST_MODEL_SRC
|
||||
test_model.cc
|
||||
${TEST_MODEL_SOURCES}
|
||||
)
|
||||
set(CLANG_UML_TEST_MODEL_HEADER
|
||||
catch.h
|
||||
)
|
||||
|
||||
set(CLANG_UML_TEST_CASES_SRC
|
||||
test_cases.cc
|
||||
${TEST_CASE_SOURCES}
|
||||
@@ -50,6 +58,16 @@ target_link_libraries(test_util
|
||||
${YAML_CPP_LIBRARIES}
|
||||
spdlog::spdlog clang-umllib cppast)
|
||||
|
||||
add_executable(test_model
|
||||
${CLANG_UML_TEST_MODEL_SRC}
|
||||
${CLANG_UML_TEST_MODEL_HEADER})
|
||||
|
||||
target_link_libraries(test_model
|
||||
PRIVATE
|
||||
${LIBCLANG_LIBRARIES}
|
||||
${YAML_CPP_LIBRARIES}
|
||||
spdlog::spdlog clang-umllib cppast)
|
||||
|
||||
add_executable(test_decorator_parser
|
||||
${CLANG_UML_TEST_DECORATOR_PARSER_SRC}
|
||||
${CLANG_UML_TEST_DECORATOR_PARSER_HEADER})
|
||||
|
||||
Reference in New Issue
Block a user