moved SuffixHelper to StringUtils

This commit is contained in:
djudjuu committed 2019-07-09 13:50:07 +02:00
1 parent 019ec63f63
commit cafa01cbf6
8 files changed
+47 -46

No files matched your search

+17
View File
@@ -96,3 +96,20 @@ string dev::quotedAlternativesList(vector<string> const& suggestions)
return joinHumanReadable(quotedSuggestions, ", ", " or ");
}
string dev::suffixedVariableNameList(string const& _baseName, size_t _startSuffix, size_t _endSuffix)
{
string result;
if (_startSuffix < _endSuffix)
{
result = _baseName + to_string(_startSuffix++);
while (_startSuffix < _endSuffix)
result += ", " + _baseName + to_string(_startSuffix++);
}
else if (_endSuffix < _startSuffix)
{
result = _baseName + to_string(_endSuffix++);
while (_endSuffix < _startSuffix)
result = _baseName + to_string(_endSuffix++) + ", " + result;
}
return result;
}