Added PlantUML links generation in class diagrams
This commit is contained in:
@@ -73,6 +73,15 @@ const std::vector<relationship> &element::relationships() const
|
||||
|
||||
void element::append(const element &e) { decorated_element::append(e); }
|
||||
|
||||
inja::json element::context() const {
|
||||
inja::json ctx;
|
||||
ctx["name"] = name();
|
||||
ctx["alias"] = alias();
|
||||
ctx["full_name"] = full_name(false);
|
||||
ctx["namespace"] = get_namespace().to_string();
|
||||
return ctx;
|
||||
}
|
||||
|
||||
bool operator==(const element &l, const element &r)
|
||||
{
|
||||
return l.full_name(false) == r.full_name(false);
|
||||
|
||||
@@ -20,8 +20,11 @@
|
||||
#include "decorated_element.h"
|
||||
#include "namespace.h"
|
||||
#include "relationship.h"
|
||||
#include "source_location.h"
|
||||
#include "util/util.h"
|
||||
|
||||
#include <inja/inja.hpp>
|
||||
|
||||
#include <atomic>
|
||||
#include <exception>
|
||||
#include <string>
|
||||
@@ -29,7 +32,7 @@
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
class element : public decorated_element {
|
||||
class element : public decorated_element, public source_location {
|
||||
public:
|
||||
element(const namespace_ &using_namespace);
|
||||
|
||||
@@ -74,6 +77,8 @@ public:
|
||||
|
||||
friend std::ostream &operator<<(std::ostream &out, const element &rhs);
|
||||
|
||||
virtual inja::json context() const;
|
||||
|
||||
protected:
|
||||
const uint64_t m_id{0};
|
||||
|
||||
@@ -82,6 +87,7 @@ private:
|
||||
namespace_ ns_;
|
||||
namespace_ using_namespace_;
|
||||
std::vector<relationship> relationships_;
|
||||
type_safe::optional<source_location> location_;
|
||||
|
||||
static std::atomic_uint64_t m_nextId;
|
||||
};
|
||||
|
||||
19
src/common/model/source_location.cc
Normal file
19
src/common/model/source_location.cc
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* src/common/model/source_location.cc
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "source_location.h"
|
||||
46
src/common/model/source_location.h
Normal file
46
src/common/model/source_location.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* src/common/model/source_location.h
|
||||
*
|
||||
* Copyright (c) 2021-2022 Bartek Kryza <bkryza@gmail.com>
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
namespace clanguml::common::model {
|
||||
|
||||
class source_location {
|
||||
public:
|
||||
source_location() = default;
|
||||
|
||||
source_location(const std::string &f, unsigned int l)
|
||||
: file_{f}
|
||||
, line_{l}
|
||||
{
|
||||
}
|
||||
|
||||
const std::string &file() const { return file_; }
|
||||
|
||||
void set_file(const std::string &file) { file_ = file; }
|
||||
|
||||
unsigned int line() const { return line_; }
|
||||
|
||||
void set_line(const unsigned line) { line_ = line; }
|
||||
|
||||
private:
|
||||
std::string file_;
|
||||
unsigned int line_{0};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user