string: Added const replace and replaceAll

which return the replaced string rather than modify the string the function is
called for.
This commit is contained in:
Henry Weller
2021-10-25 10:15:44 +01:00
parent ad28cb49b5
commit cd80831261
3 changed files with 45 additions and 5 deletions

View File

@ -78,6 +78,17 @@ Foam::string& Foam::string::replace
}
Foam::string Foam::string::replace
(
const string& oldStr,
const string& newStr,
size_type start
) const
{
return string(*this).replace(oldStr, newStr, start);
}
Foam::string& Foam::string::replaceAll
(
const string& oldStr,
@ -100,6 +111,17 @@ Foam::string& Foam::string::replaceAll
}
Foam::string Foam::string::replaceAll
(
const string& oldStr,
const string& newStr,
size_type start
) const
{
return string(*this).replaceAll(oldStr, newStr, start);
}
Foam::string& Foam::string::expand(const bool allowEmpty)
{
stringOps::inplaceExpand(*this, allowEmpty);