Lot of code for generating code. Working on unit tests.

This commit is contained in:
eelke 2018-09-09 18:52:32 +02:00
parent da45929b12
commit 8f4845d4d2
42 changed files with 1089 additions and 267 deletions

View file

@ -0,0 +1,32 @@
#include "NameManglingRules.h"
void NameManglingRules::apply(const ReplaceRule &rule, QString &in) const
{
int from = 0;
int pos;
QRegularExpressionMatch match;
while ((pos = in.indexOf(rule.pattern, from, &match)) >= 0) {
int len = match.capturedLength();
in.replace(pos, len, rule.replace);
from = pos + rule.replace.size();
if (rule.nextToUpper)
in[from] = in[from].toUpper();
}
}
QString NameManglingRules::transform(const QString &input) const
{
QString result;
if (caseConversion == CaseConversion::Lower)
result = input.toLower();
else if (caseConversion == CaseConversion::Upper)
result = input.toUpper();
else
result = input;
for (auto rule : replaceRules) {
apply(rule, result);
}
return result;
}