68 std::string_view::const_iterator it = c.begin();
69 std::advance(it, label.size());
74 pos = std::distance(c.begin(), it);
77 auto d = c.substr(pos, c.find(
'[', pos) - pos);
80 d_str.erase(std::remove_if(d_str.begin(), d_str.end(),
81 static_cast<int (*)(
int)
>(std::isspace)),
86 std::advance(it, d.size());
92 pos = std::distance(c.begin(), it);
93 res.
param = c.substr(pos, c.find(
']', pos) - pos);
95 std::advance(it, res.
param.size() + 1);
97 else if (std::isspace(*it) != 0) {
101 pos = std::distance(c.begin(), it);
102 res.
text = c.substr(pos, c.find(
'}', pos) - pos);
111 auto res = std::make_shared<note>();
114 res->diagrams = toks.diagrams;
116 if (!toks.param.empty())
117 res->position = toks.param;
119 res->text = toks.text;
126 return std::make_shared<skip>();
132 return std::make_shared<skip_relationship>();
137 auto res = std::make_shared<style>();
140 res->diagrams = toks.diagrams;
141 res->spec = toks.param;
148 auto res = std::make_shared<aggregation>();
151 res->diagrams = toks.diagrams;
152 res->multiplicity = toks.param;
159 auto res = std::make_shared<composition>();
162 res->diagrams = toks.diagrams;
163 res->multiplicity = toks.param;
170 auto res = std::make_shared<association>();
173 res->diagrams = toks.diagrams;
174 res->multiplicity = toks.param;
181 auto res = std::make_shared<call>();
184 res->diagrams = toks.diagrams;
190std::pair<std::vector<std::shared_ptr<decorator>>, std::string>
parse(
191 std::string documentation_block,
const std::string &clanguml_tag)
193 std::vector<std::shared_ptr<decorator>> res;
194 std::string stripped_comment;
196 const std::string begin_tag{
"@" + clanguml_tag};
197 const auto begin_tag_size = begin_tag.size();
201 documentation_block,
"\\" + clanguml_tag,
"@" + clanguml_tag);
202 documentation_block =
util::trim(documentation_block);
204 const std::string_view block_view{documentation_block};
206 auto pos = block_view.find(
"@" + clanguml_tag +
"{");
208 if (pos == std::string::npos) {
213 size_t last_end_pos{0};
214 while (pos < documentation_block.size()) {
215 auto c_begin = pos + begin_tag_size;
216 auto c_end = block_view.find(
'}', c_begin);
218 if (c_end == std::string::npos) {
226 res.emplace_back(std::move(com));
228 const auto in_between_length = pos - last_end_pos;
229 stripped_comment += block_view.substr(last_end_pos, in_between_length);
231 last_end_pos = pos + (c_end - c_begin + begin_tag_size + 1);
233 pos = block_view.find(
"@" + clanguml_tag +
"{", c_end);