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:
@ -28,9 +28,9 @@ License
|
||||
#include "dynamicCode.H"
|
||||
#include "dynamicCodeContext.H"
|
||||
#include "dlLibraryTable.H"
|
||||
#include "regIOobject.H"
|
||||
#include "PstreamReduceOps.H"
|
||||
#include "OSspecific.H"
|
||||
#include "regIOobject.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
@ -367,7 +367,7 @@ Foam::codedBase::codedBase()
|
||||
|
||||
Foam::codedBase::codedBase(const word& name, const dictionary& dict)
|
||||
:
|
||||
codeName_(word(name).replaceAll("-", "_")),
|
||||
codeName_(name.replaceAll("-", "_")),
|
||||
dict_(dict)
|
||||
{}
|
||||
|
||||
|
||||
@ -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