Parse a documentation block and extract all clang-uml decorators.
192{
193 std::vector<std::shared_ptr<decorator>> res;
194 std::string stripped_comment;
195
196 const std::string begin_tag{"@" + clanguml_tag};
197 const auto begin_tag_size = begin_tag.size();
198
199
200 util::replace_all(
201 documentation_block, "\\" + clanguml_tag, "@" + clanguml_tag);
202 documentation_block = util::trim(documentation_block);
203
204 const std::string_view block_view{documentation_block};
205
206 auto pos = block_view.find("@" + clanguml_tag + "{");
207
208 if (pos == std::string::npos) {
209
210 return {{}, util::trim(documentation_block)};
211 }
212
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);
217
218 if (c_end == std::string::npos) {
219 return {res, util::trim(stripped_comment)};
220 }
221
222 auto com =
223 decorator::from_string(block_view.substr(c_begin + 1, c_end - 2));
224
225 if (com)
226 res.emplace_back(std::move(com));
227
228 const auto in_between_length = pos - last_end_pos;
229 stripped_comment += block_view.substr(last_end_pos, in_between_length);
230
231 last_end_pos = pos + (c_end - c_begin + begin_tag_size + 1);
232
233 pos = block_view.find("@" + clanguml_tag + "{", c_end);
234 }
235
236 return {res, util::trim(stripped_comment)};
237};