mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: string: allow empty string substitution in expand
This commit is contained in:
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd.
|
\\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd.
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -94,7 +94,7 @@ Foam::string& Foam::string::replaceAll
|
|||||||
|
|
||||||
|
|
||||||
// Expand all occurences of environment variables and initial tilde sequences
|
// Expand all occurences of environment variables and initial tilde sequences
|
||||||
Foam::string& Foam::string::expand(const bool recurse)
|
Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
|
||||||
{
|
{
|
||||||
size_type startEnvar = 0;
|
size_type startEnvar = 0;
|
||||||
|
|
||||||
@ -152,11 +152,13 @@ Foam::string& Foam::string::expand(const bool recurse)
|
|||||||
);
|
);
|
||||||
startEnvar += enVarString.size();
|
startEnvar += enVarString.size();
|
||||||
}
|
}
|
||||||
|
else if (allowEmptyVar)
|
||||||
|
{
|
||||||
|
startEnvar = endEnvar;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//startEnvar = endEnvar;
|
FatalErrorIn("string::expand(const bool, const bool)")
|
||||||
|
|
||||||
FatalErrorIn("string::expand()")
|
|
||||||
<< "Unknown variable name " << enVar << '.'
|
<< "Unknown variable name " << enVar << '.'
|
||||||
<< exit(FatalError);
|
<< exit(FatalError);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -182,7 +182,11 @@ public:
|
|||||||
//
|
//
|
||||||
// \sa
|
// \sa
|
||||||
// Foam::findEtcFile
|
// Foam::findEtcFile
|
||||||
string& expand(const bool recurse=false);
|
string& expand
|
||||||
|
(
|
||||||
|
const bool recurse=false,
|
||||||
|
const bool allowEmptyVar = false
|
||||||
|
);
|
||||||
|
|
||||||
//- Remove repeated characters returning true if string changed
|
//- Remove repeated characters returning true if string changed
|
||||||
bool removeRepeated(const char);
|
bool removeRepeated(const char);
|
||||||
|
|||||||
Reference in New Issue
Block a user