19 result.reserve(camelCase.size() * 2 + 2);
23 result +=
static_cast<char>(std::tolower(camelCase[0]));
25 for (
auto it = camelCase.begin() + 1; it != camelCase.end(); ++it) {
26 if (std::isupper(*it) && *(it - 1) !=
'-') {
29 result +=
static_cast<char>(std::tolower(*it));
35 std::string_view replacement;
37 {
"-h-m-p-i-d",
"-hmpid"},
38 {
"-e-m-c-a-l",
"-emcal"},
50 std::string consolidated;
51 consolidated.reserve(
result.size());
53 for (
int i =
result.size() - 1;
i >= 0;) {
56 for (
const auto& abbr : abbreviations) {
57 int startPos =
i - abbr.pattern.size() + 1;
58 if (startPos >= 0 &&
result.compare(startPos, abbr.pattern.size(), abbr.pattern.data()) == 0) {
59 consolidated.insert(0, abbr.replacement);
67 consolidated.insert(0, 1,
result[
i]);
71 if (consolidated[0] ==
'-') {
72 return std::string(consolidated.data() + 1);