0.5.4
C++ to UML diagram generator based on Clang
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
clanguml::decorators::decorator Struct Reference

Base class for clang-uml comment tags. More...

Detailed Description

Base class for clang-uml comment tags.

This class provides basic interface for clang-uml comment tags, called decorators. All decorators are added to the code using uml Doxygen-style tag.

Definition at line 43 of file decorators.h.

#include <decorators.h>

Public Member Functions

virtual ~decorator ()=default
 
bool applies_to_diagram (const std::string &name)
 Check if decorator applies to a specific diagram.
 

Static Public Member Functions

static std::shared_ptr< decoratorfrom_string (std::string_view c)
 Create decorator of specific type based on it's string representation.
 

Public Attributes

std::vector< std::string > diagrams
 

Protected Member Functions

decorator_toks tokenize (const std::string &label, std::string_view c)
 

Constructor & Destructor Documentation

◆ ~decorator()

virtual clanguml::decorators::decorator::~decorator ( )
virtualdefault

Member Function Documentation

◆ applies_to_diagram()

bool clanguml::decorators::decorator::applies_to_diagram ( const std::string &  name)

Check if decorator applies to a specific diagram.

Parameters
nameName of the diagram
Returns
True, if this decorator applies to diagram name

Definition at line 57 of file decorators.cc.

58{
59 return diagrams.empty() ||
60 (std::find(diagrams.begin(), diagrams.end(), name) != diagrams.end());
61}

◆ from_string()

std::shared_ptr< decorator > clanguml::decorators::decorator::from_string ( std::string_view  c)
static

Create decorator of specific type based on it's string representation.

Parameters
cDecorator string representation extracted from the comment
Returns
Decorator instance

Definition at line 27 of file decorators.cc.

28{
29 if (c.find(note::label) == 0) {
30 return note::from_string(c);
31 }
32 if (c.find(skip_relationship::label) == 0) {
34 }
35 if (c.find(skip::label) == 0) {
36 return skip::from_string(c);
37 }
38 if (c.find(style::label) == 0) {
39 return style::from_string(c);
40 }
41 if (c.find(aggregation::label) == 0) {
43 }
44 if (c.find(composition::label) == 0) {
46 }
47 if (c.find(association::label) == 0) {
49 }
50 if (c.find(call::label) == 0) {
51 return call::from_string(c);
52 }
53
54 return {};
55}

◆ tokenize()

decorator_toks clanguml::decorators::decorator::tokenize ( const std::string &  label,
std::string_view  c 
)
protected

Definition at line 63 of file decorators.cc.

64{
65 decorator_toks res;
66 res.label = label;
67 size_t pos{};
68 std::string_view::const_iterator it = c.begin();
69 std::advance(it, label.size());
70
71 if (*it == ':') {
72 std::advance(it, 1);
73
74 pos = std::distance(c.begin(), it);
75 // If the diagram list is provided after ':', [] is mandatory
76 // even if empty
77 auto d = c.substr(pos, c.find('[', pos) - pos);
78 if (!d.empty()) {
79 std::string d_str{d};
80 d_str.erase(std::remove_if(d_str.begin(), d_str.end(),
81 static_cast<int (*)(int)>(std::isspace)),
82 d_str.end());
83 res.diagrams = util::split(d_str, ",");
84 }
85
86 std::advance(it, d.size());
87 }
88
89 if (*it == '[') {
90 std::advance(it, 1);
91
92 pos = std::distance(c.begin(), it);
93 res.param = c.substr(pos, c.find(']', pos) - pos);
94
95 std::advance(it, res.param.size() + 1);
96 }
97 else if (std::isspace(*it) != 0) {
98 std::advance(it, 1);
99 }
100
101 pos = std::distance(c.begin(), it);
102 res.text = c.substr(pos, c.find('}', pos) - pos);
103 res.text = util::trim(res.text);
104 res.param = util::trim(res.param);
105
106 return res;
107}

Member Data Documentation

◆ diagrams

std::vector<std::string> clanguml::decorators::decorator::diagrams

List of diagram names to which a given decorator applies

Definition at line 45 of file decorators.h.


The documentation for this struct was generated from the following files: