Lot of code for generating code. Working on unit tests.
This commit is contained in:
parent
da45929b12
commit
8f4845d4d2
42 changed files with 1089 additions and 267 deletions
32
pglablib/codebuilder/NameManglingRules.cpp
Normal file
32
pglablib/codebuilder/NameManglingRules.cpp
Normal 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;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue