Added alias resolution for PlantUML annotations

This commit is contained in:
Bartek Kryza
2021-05-27 00:31:44 +02:00
parent eec8057fc0
commit ce02432178
6 changed files with 77 additions and 4 deletions

View File

@@ -19,6 +19,8 @@
#include <spdlog/spdlog.h>
#include <regex>
namespace clanguml {
namespace util {
@@ -101,5 +103,28 @@ std::string unqualify(const std::string &s)
return fmt::format("{}", fmt::join(toks, " "));
}
bool find_element_alias(
const std::string &input, std::tuple<std::string, size_t, size_t> &result)
{
std::regex alias_regex("(@A\\([^\\).]+\\))");
auto alias_it =
std::sregex_iterator(input.begin(), input.end(), alias_regex);
auto end_it = std::sregex_iterator();
if (alias_it == end_it)
return false;
std::smatch match = *alias_it;
std::string alias = match.str().substr(3, match.str().size() - 4);
std::get<0>(result) = alias;
std::get<1>(result) = match.position();
std::get<2>(result) = match.length();
return true;
}
}
}