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:
@ -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);
|
||||
|
||||
@ -165,9 +165,27 @@ public:
|
||||
//- Avoid masking the normal std::string replace
|
||||
using std::string::replace;
|
||||
|
||||
//- In this string replace first occurrence of sub-string oldStr
|
||||
// with newStr starting at start
|
||||
string& replace
|
||||
(
|
||||
const string& oldStr,
|
||||
const string& newStr,
|
||||
size_type start = 0
|
||||
);
|
||||
|
||||
//- Replace first occurrence of sub-string oldStr with newStr
|
||||
// starting at start
|
||||
string& replace
|
||||
string replace
|
||||
(
|
||||
const string& oldStr,
|
||||
const string& newStr,
|
||||
size_type start = 0
|
||||
) const;
|
||||
|
||||
//- In this string replace all occurrences of sub-string oldStr
|
||||
// with newStr starting at start
|
||||
string& replaceAll
|
||||
(
|
||||
const string& oldStr,
|
||||
const string& newStr,
|
||||
@ -176,12 +194,12 @@ public:
|
||||
|
||||
//- Replace all occurrences of sub-string oldStr with newStr
|
||||
// starting at start
|
||||
string& replaceAll
|
||||
string replaceAll
|
||||
(
|
||||
const string& oldStr,
|
||||
const string& newStr,
|
||||
size_type start = 0
|
||||
);
|
||||
) const;
|
||||
|
||||
//- Expand initial tildes and all occurrences of environment variables
|
||||
// Expansion includes:
|
||||
|
||||
Reference in New Issue
Block a user