mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
moved SuffixHelper to StringUtils
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -39,6 +39,12 @@ size_t stringDistance(std::string const& _str1, std::string const& _str2);
|
||||
// Return a string having elements of suggestions as quoted, alternative suggestions. e.g. "a", "b" or "c"
|
||||
std::string quotedAlternativesList(std::vector<std::string> const& suggestions);
|
||||
|
||||
/// @returns a string containing a comma-separated list of variable names consisting of @a _baseName suffixed
|
||||
/// with increasing integers in the range [@a _startSuffix, @a _endSuffix), if @a _startSuffix < @a _endSuffix,
|
||||
/// and with decreasing integers in the range [@a _endSuffix, @a _startSuffix), if @a _endSuffix < @a _startSuffix.
|
||||
/// If @a _startSuffix == @a _endSuffix, the empty string is returned.
|
||||
std::string suffixedVariableNameList(std::string const& _baseName, size_t _startSuffix, size_t _endSuffix);
|
||||
|
||||
/// Joins collection of strings into one string with separators between, last separator can be different.
|
||||
/// @param _list collection of strings to join
|
||||
/// @param _separator defaults to ", "
|
||||
|
||||
Reference in New Issue
Block a user