stringOps: Rationalisation of expansions
Specific names have been given for expand functions. Unused functions have been removed, and functions only used locally have been removed from the namespace. Documentation has been corrected. Default and alternative value handling has been removed from code template expansion.
This commit is contained in:
@ -51,7 +51,7 @@ int main(int argc, char *argv[])
|
||||
dict.add("aaOpenFOAMcc", 1);
|
||||
|
||||
string s("DDD${aa${WM_PROJECT}cc}EEE");
|
||||
stringOps::inplaceExpand(s, dict, true, false);
|
||||
stringOps::inplaceExpandEntry(s, dict, true, false);
|
||||
Info<< "variable expansion:" << s << endl;
|
||||
}
|
||||
|
||||
|
||||
@ -93,7 +93,7 @@ ${typeName}FixedValueFvPatch${FieldType}
|
||||
:
|
||||
fixedValueFvPatchField<${TemplateType}>(p, iF, dict)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum}"
|
||||
" from patch/dictionary\n";
|
||||
@ -112,7 +112,7 @@ ${typeName}FixedValueFvPatch${FieldType}
|
||||
:
|
||||
fixedValueFvPatchField<${TemplateType}>(ptf, p, iF, mapper)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum}"
|
||||
" from patch/DimensionedField/mapper\n";
|
||||
@ -129,7 +129,7 @@ ${typeName}FixedValueFvPatch${FieldType}
|
||||
:
|
||||
fixedValueFvPatchField<${TemplateType}>(ptf, iF)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum} "
|
||||
"as copy/DimensionedField\n";
|
||||
@ -142,7 +142,7 @@ ${typeName}FixedValueFvPatch${FieldType}
|
||||
${typeName}FixedValueFvPatch${FieldType}::
|
||||
~${typeName}FixedValueFvPatch${FieldType}()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -158,7 +158,7 @@ void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ ${typeName}FixedValuePointPatch${FieldType}
|
||||
:
|
||||
fixedValuePointPatchField<${TemplateType}>(p, iF, dict)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum}"
|
||||
" from patch/dictionary\n";
|
||||
@ -111,7 +111,7 @@ ${typeName}FixedValuePointPatch${FieldType}
|
||||
:
|
||||
fixedValuePointPatchField<${TemplateType}>(ptf, p, iF, mapper)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum}"
|
||||
" from patch/DimensionedField/mapper\n";
|
||||
@ -128,7 +128,7 @@ ${typeName}FixedValuePointPatch${FieldType}
|
||||
:
|
||||
fixedValuePointPatchField<${TemplateType}>(ptf, iF)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum} "
|
||||
"as copy/DimensionedField\n";
|
||||
@ -141,7 +141,7 @@ ${typeName}FixedValuePointPatch${FieldType}
|
||||
${typeName}FixedValuePointPatch${FieldType}::
|
||||
~${typeName}FixedValuePointPatch${FieldType}()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -157,7 +157,7 @@ void ${typeName}FixedValuePointPatch${FieldType}::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ ${typeName}Function1${TemplateType}
|
||||
entryName
|
||||
)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<< "Construct ${typeName} sha1: ${SHA1sum} from dictionary\n";
|
||||
}
|
||||
@ -94,7 +94,7 @@ ${typeName}Function1${TemplateType}
|
||||
f1
|
||||
)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<< "Construct ${typeName} sha1: ${SHA1sum} as copy\n";
|
||||
}
|
||||
@ -106,7 +106,7 @@ ${typeName}Function1${TemplateType}
|
||||
Foam::Function1s::${typeName}Function1${TemplateType}::
|
||||
~${typeName}Function1${TemplateType}()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<< "Destroy ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
|
||||
@ -76,7 +76,7 @@ ${typeName}Function2${TemplateType}
|
||||
entryName
|
||||
)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<< "Construct ${typeName} sha1: ${SHA1sum} from dictionary\n";
|
||||
}
|
||||
@ -94,7 +94,7 @@ ${typeName}Function2${TemplateType}
|
||||
f1
|
||||
)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<< "Construct ${typeName} sha1: ${SHA1sum} as copy\n";
|
||||
}
|
||||
@ -106,7 +106,7 @@ ${typeName}Function2${TemplateType}
|
||||
Foam::Function2s::${typeName}Function2${TemplateType}::
|
||||
~${typeName}Function2${TemplateType}()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<< "Destroy ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
|
||||
@ -108,7 +108,7 @@ ${typeName}FunctionObject::~${typeName}FunctionObject()
|
||||
|
||||
bool ${typeName}FunctionObject::read(const dictionary& dict)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"read ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -123,7 +123,7 @@ bool ${typeName}FunctionObject::read(const dictionary& dict)
|
||||
|
||||
Foam::wordList ${typeName}FunctionObject::fields() const
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"fields ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -139,7 +139,7 @@ Foam::wordList ${typeName}FunctionObject::fields() const
|
||||
|
||||
bool ${typeName}FunctionObject::execute()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"execute ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -154,7 +154,7 @@ bool ${typeName}FunctionObject::execute()
|
||||
|
||||
bool ${typeName}FunctionObject::write()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"write ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -169,7 +169,7 @@ bool ${typeName}FunctionObject::write()
|
||||
|
||||
bool ${typeName}FunctionObject::end()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"end ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
|
||||
@ -103,7 +103,7 @@ ${typeName}FvModel${SourceType}
|
||||
fvModel(name, modelType, mesh, dict),
|
||||
set_(mesh, coeffs())
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum}"
|
||||
" from components\n";
|
||||
@ -116,7 +116,7 @@ ${typeName}FvModel${SourceType}
|
||||
${typeName}FvModel${SourceType}::
|
||||
~${typeName}FvModel${SourceType}()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -131,7 +131,7 @@ void ${typeName}FvModel${SourceType}::addSup
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"${typeName}FvModel${SourceType}::addSup()\n";
|
||||
}
|
||||
@ -149,7 +149,7 @@ void ${typeName}FvModel${SourceType}::addSup
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"${typeName}FvModel${SourceType}::addSup()\n";
|
||||
}
|
||||
@ -168,7 +168,7 @@ void ${typeName}FvModel${SourceType}::addSup
|
||||
const word& fieldName
|
||||
) const
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"${typeName}FvModel${SourceType}::addSup()\n";
|
||||
}
|
||||
|
||||
@ -93,7 +93,7 @@ ${typeName}MixedValueFvPatch${FieldType}
|
||||
:
|
||||
mixedFvPatchField<${TemplateType}>(p, iF, dict)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum}"
|
||||
" from patch/dictionary\n";
|
||||
@ -112,7 +112,7 @@ ${typeName}MixedValueFvPatch${FieldType}
|
||||
:
|
||||
mixedFvPatchField<${TemplateType}>(ptf, p, iF, mapper)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum}"
|
||||
" from patch/DimensionedField/mapper\n";
|
||||
@ -129,7 +129,7 @@ ${typeName}MixedValueFvPatch${FieldType}
|
||||
:
|
||||
mixedFvPatchField<${TemplateType}>(ptf, iF)
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"construct ${typeName} sha1: ${SHA1sum} "
|
||||
"as copy/DimensionedField\n";
|
||||
@ -142,7 +142,7 @@ ${typeName}MixedValueFvPatch${FieldType}
|
||||
${typeName}MixedValueFvPatch${FieldType}::
|
||||
~${typeName}MixedValueFvPatch${FieldType}()
|
||||
{
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"destroy ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
@ -158,7 +158,7 @@ void ${typeName}MixedValueFvPatch${FieldType}::updateCoeffs()
|
||||
return;
|
||||
}
|
||||
|
||||
if (${verbose:-false})
|
||||
if (${verbose})
|
||||
{
|
||||
Info<<"updateCoeffs ${typeName} sha1: ${SHA1sum}\n";
|
||||
}
|
||||
|
||||
@ -359,7 +359,7 @@ Foam::fileName Foam::findConfigFile
|
||||
{
|
||||
const fileName dictFile
|
||||
(
|
||||
stringOps::expand("$FOAM_CASE")/"system"/region/configName
|
||||
stringOps::expandEnvVar("$FOAM_CASE")/"system"/region/configName
|
||||
);
|
||||
|
||||
if (isFile(dictFile))
|
||||
@ -374,7 +374,7 @@ Foam::fileName Foam::findConfigFile
|
||||
{
|
||||
const fileName dictFile
|
||||
(
|
||||
stringOps::expand("$FOAM_CASE")/"system"/configName
|
||||
stringOps::expandEnvVar("$FOAM_CASE")/"system"/configName
|
||||
);
|
||||
|
||||
if (isFile(dictFile))
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -192,7 +192,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
|
||||
// Substitute dictionary and environment variables. Do not allow
|
||||
// empty substitutions.
|
||||
stringOps::inplaceExpand(s, parentDict, true, false);
|
||||
stringOps::inplaceExpandEntry(s, parentDict, true, false);
|
||||
keyword.std::string::replace(1, keyword.size() - 1, s);
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2018-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2018-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -102,7 +102,7 @@ Foam::token Foam::functionEntries::ifeqEntry::expand
|
||||
{
|
||||
// String expansion. Allow unset variables
|
||||
string expanded(var);
|
||||
stringOps::inplaceExpand(expanded, dict, true, true);
|
||||
stringOps::inplaceExpandEntry(expanded, dict, true, true);
|
||||
|
||||
// Re-form as a string token so we can compare to string
|
||||
return token(expanded, t.lineNumber());
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2020 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -78,7 +78,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
|
||||
fileName fName(is);
|
||||
// Substitute dictionary and environment variables. Allow empty
|
||||
// substitutions.
|
||||
stringOps::inplaceExpand(fName, dict, true, true);
|
||||
stringOps::inplaceExpandEntry(fName, dict, true, true);
|
||||
|
||||
if (fName.empty() || fName.isAbsolute())
|
||||
{
|
||||
@ -102,7 +102,7 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
|
||||
fileName fName(f);
|
||||
// Substitute dictionary and environment variables. Allow empty
|
||||
// substitutions.
|
||||
stringOps::inplaceExpand(fName, dict, true, true);
|
||||
stringOps::inplaceExpandEntry(fName, dict, true, true);
|
||||
|
||||
if (fName.empty() || fName.isAbsolute())
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2015-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2015-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -78,7 +78,7 @@ Foam::fileName Foam::functionEntries::includeEtcEntry::includeEtcFileName
|
||||
|
||||
// Substitute dictionary and environment variables.
|
||||
// Allow empty substitutions.
|
||||
stringOps::inplaceExpand(fName, dict, true, true);
|
||||
stringOps::inplaceExpandEntry(fName, dict, true, true);
|
||||
|
||||
if (fName.empty() || fName.isAbsolute())
|
||||
{
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -52,7 +52,7 @@ bool Foam::primitiveEntry::expandVariable
|
||||
|
||||
// Substitute dictionary and environment variables. Do not allow
|
||||
// empty substitutions.
|
||||
stringOps::inplaceExpand(s, dict, true, false);
|
||||
stringOps::inplaceExpandEntry(s, dict, true, false);
|
||||
variable newW(w);
|
||||
newW.std::string::replace(1, newW.size() - 1, s);
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2021-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -128,12 +128,12 @@ void Foam::compileTemplate::prepare
|
||||
// Define Make/options
|
||||
dynCode.setMakeOptions(context.options() + "\n\n" + context.libs());
|
||||
|
||||
// Debugging: make verbose
|
||||
// Make verbose if debugging
|
||||
dynCode.setFilterVariable("verbose", Foam::name(bool(debug)));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
dynCode.setFilterVariable("verbose", "true");
|
||||
Info<<"compile " << codeName() << " sha1: "
|
||||
<< context.sha1() << endl;
|
||||
Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -132,7 +132,7 @@ void Foam::dynamicCode::copyAndFilter
|
||||
// Expand according to mapping.
|
||||
// Expanding according to env variables might cause too many
|
||||
// surprises
|
||||
stringOps::inplaceExpand(line, mapping);
|
||||
stringOps::inplaceExpandCodeTemplate(line, mapping);
|
||||
os.writeQuoted(line, false) << nl;
|
||||
}
|
||||
while (is.good());
|
||||
@ -322,8 +322,8 @@ bool Foam::dynamicCode::writeDigest(const std::string& sha1) const
|
||||
|
||||
Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName)
|
||||
:
|
||||
codeRoot_(stringOps::expand("$FOAM_CASE")/topDirName),
|
||||
libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")),
|
||||
codeRoot_(stringOps::expandEnvVar("$FOAM_CASE")/topDirName),
|
||||
libSubDir_(stringOps::expandEnvVar("platforms/$WM_OPTIONS/lib")),
|
||||
codeName_(codeName),
|
||||
codeDirName_(codeDirName)
|
||||
{
|
||||
@ -491,7 +491,7 @@ bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
|
||||
{
|
||||
const fileName dstFile
|
||||
(
|
||||
outputDir/stringOps::expand(createFiles_[fileI].first())
|
||||
outputDir/stringOps::expandEnvVar(createFiles_[fileI].first())
|
||||
);
|
||||
|
||||
mkDir(dstFile.path());
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2019 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -63,15 +63,9 @@ Foam::dynamicCodeContext::dynamicCodeContext
|
||||
codePtrs[i] = dict.lookupEntryPtr(key, false, false);
|
||||
if (codePtrs[i])
|
||||
{
|
||||
code_.insert
|
||||
(
|
||||
key,
|
||||
stringOps::expand
|
||||
(
|
||||
stringOps::trim(verbatimString(codePtrs[i]->stream())),
|
||||
dict
|
||||
)
|
||||
);
|
||||
string s(stringOps::trim(verbatimString(codePtrs[i]->stream())));
|
||||
stringOps::inplaceExpandCodeString(s, dict);
|
||||
code_.insert(key, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -83,24 +77,16 @@ Foam::dynamicCodeContext::dynamicCodeContext
|
||||
const entry* optionsPtr = dict.lookupEntryPtr("codeOptions", false, false);
|
||||
if (optionsPtr)
|
||||
{
|
||||
options_ =
|
||||
stringOps::expand
|
||||
(
|
||||
stringOps::trim(verbatimString(optionsPtr->stream())),
|
||||
dict
|
||||
);
|
||||
options_ = stringOps::trim(verbatimString(optionsPtr->stream()));
|
||||
stringOps::inplaceExpandCodeString(options_, dict);
|
||||
}
|
||||
|
||||
// Libs
|
||||
const entry* libsPtr = dict.lookupEntryPtr("codeLibs", false, false);
|
||||
if (libsPtr)
|
||||
{
|
||||
libs_ =
|
||||
stringOps::expand
|
||||
(
|
||||
stringOps::trim(verbatimString(libsPtr->stream())),
|
||||
dict
|
||||
);
|
||||
libs_ = stringOps::trim(verbatimString(libsPtr->stream()));
|
||||
stringOps::inplaceExpandCodeString(libs_, dict);
|
||||
}
|
||||
|
||||
// Calculate SHA1 digest from all entries
|
||||
|
||||
@ -71,13 +71,12 @@ void Foam::codedFixedValuePointPatchField<Type>::prepare
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile(codeTemplateH("codedFixedValuePointPatchField"));
|
||||
|
||||
// Debugging: make BC verbose
|
||||
// Make verbose if debugging
|
||||
dynCode.setFilterVariable("verbose", Foam::name(bool(debug)));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
// Debugging: make BC verbose
|
||||
dynCode.setFilterVariable("verbose", "true");
|
||||
Info<<"compile " << codeName() << " sha1: "
|
||||
<< context.sha1() << endl;
|
||||
Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl;
|
||||
}
|
||||
|
||||
// Define Make/options
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,12 +58,12 @@ void Foam::Function1s::Coded<Type>::prepare
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile(codeTemplateH("codedFunction1"));
|
||||
|
||||
// Debugging: make verbose
|
||||
// Make verbose if debugging
|
||||
dynCode.setFilterVariable("verbose", Foam::name(bool(debug)));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
dynCode.setFilterVariable("verbose", "true");
|
||||
Info<<"compile " << codeName() << " sha1: "
|
||||
<< context.sha1() << endl;
|
||||
Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl;
|
||||
}
|
||||
|
||||
// Define Make/options
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2020-2021 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2020-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -58,12 +58,12 @@ void Foam::Function2s::Coded<Type>::prepare
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile(codeTemplateH("codedFunction2"));
|
||||
|
||||
// Debugging: make verbose
|
||||
// Make verbose if debugging
|
||||
dynCode.setFilterVariable("verbose", Foam::name(bool(debug)));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
dynCode.setFilterVariable("verbose", "true");
|
||||
Info<<"compile " << codeName() << " sha1: "
|
||||
<< context.sha1() << endl;
|
||||
Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl;
|
||||
}
|
||||
|
||||
// Define Make/options
|
||||
|
||||
@ -124,7 +124,7 @@ Foam::string Foam::string::replaceAll
|
||||
|
||||
Foam::string& Foam::string::expand(const bool allowEmpty)
|
||||
{
|
||||
stringOps::inplaceExpand(*this, allowEmpty);
|
||||
stringOps::inplaceExpandEnvVar(*this, allowEmpty);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration | Website: https://openfoam.org
|
||||
\\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
|
||||
\\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
@ -32,6 +32,7 @@ SourceFiles
|
||||
stringOps.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef stringOps_H
|
||||
#define stringOps_H
|
||||
|
||||
@ -50,10 +51,16 @@ namespace Foam
|
||||
|
||||
namespace stringOps
|
||||
{
|
||||
//- Expand occurrences of variables according to the mapping
|
||||
//- Expand all occurrences of environment variables and paths
|
||||
// Expansion includes:
|
||||
// -# variables
|
||||
// -# environment variables
|
||||
// - "$VAR", "${VAR}"
|
||||
// -# current directory
|
||||
// - leading "./" : the current directory
|
||||
// -# tilde expansion
|
||||
// - leading "~/" : home directory
|
||||
// - leading "~user" : home directory for specified user
|
||||
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
|
||||
//
|
||||
// Supports default values as per the Bourne/Korn shell.
|
||||
// \code
|
||||
@ -69,105 +76,78 @@ namespace stringOps
|
||||
// If parameter is unset or null, nothing is substituted.
|
||||
// Otherwise the \c altValue is substituted.
|
||||
//
|
||||
// Any unknown entries are removed silently.
|
||||
// Any unknown entries are removed silently, if allowEmpty is true.
|
||||
//
|
||||
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
|
||||
// are left as is.
|
||||
//
|
||||
// \note the leading sigil can be changed to avoid conflicts with other
|
||||
// string expansions
|
||||
string expand
|
||||
// \sa
|
||||
// Foam::findEtcFile
|
||||
string expandEnvVar
|
||||
(
|
||||
const string&,
|
||||
const HashTable<string, word, string::hash>& mapping,
|
||||
const char sigil = '$'
|
||||
const bool allowEmpty = false
|
||||
);
|
||||
|
||||
//- Expand all occurrences of environment variables and paths
|
||||
// See expandEnvVar
|
||||
string& inplaceExpandEnvVar
|
||||
(
|
||||
string&,
|
||||
const bool allowEmpty = false
|
||||
);
|
||||
|
||||
//- Inplace expand occurrences of variables according to the dictionary
|
||||
// Expansion includes:
|
||||
// -# variables
|
||||
// - "$VAR", "${VAR}"
|
||||
//
|
||||
// Any unknown entries are left as-is
|
||||
//
|
||||
// \note the leading sigil can be changed to avoid conflicts with other
|
||||
// string expansions
|
||||
string& inplaceExpandCodeString
|
||||
(
|
||||
string&,
|
||||
const dictionary& dict,
|
||||
const char sigil = '$'
|
||||
);
|
||||
|
||||
//- Inplace expand occurrences of variables according to the mapping
|
||||
// Expansion includes:
|
||||
// -# variables
|
||||
// - "$VAR", "${VAR}"
|
||||
//
|
||||
// Supports default values as per the Bourne/Korn shell.
|
||||
// \code
|
||||
// "${parameter:-defValue}"
|
||||
// \endcode
|
||||
// If parameter is unset or null, the \c defValue is substituted.
|
||||
// Otherwise, the value of parameter is substituted.
|
||||
//
|
||||
// Supports alternative values as per the Bourne/Korn shell.
|
||||
// \code
|
||||
// "${parameter:+altValue}"
|
||||
// \endcode
|
||||
// If parameter is unset or null, nothing is substituted.
|
||||
// Otherwise the \c altValue is substituted.
|
||||
//
|
||||
// Any unknown entries are removed silently.
|
||||
//
|
||||
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
|
||||
// are left as is.
|
||||
//
|
||||
// \note the leading sigil can be changed to avoid conflicts with other
|
||||
// string expansions
|
||||
string& inplaceExpand
|
||||
string& inplaceExpandCodeTemplate
|
||||
(
|
||||
string&,
|
||||
const HashTable<string, word, string::hash>& mapping,
|
||||
const char sigil = '$'
|
||||
);
|
||||
|
||||
//- Expand occurrences of variables according to the dictionary
|
||||
// Expansion includes:
|
||||
// -# variables
|
||||
// - "$VAR", "${VAR}"
|
||||
//
|
||||
// Any unknown entries are left as-is
|
||||
//
|
||||
// \note the leading sigil can be changed to avoid conflicts with other
|
||||
// string expansions
|
||||
string expand
|
||||
(
|
||||
const string&,
|
||||
const dictionary& dict,
|
||||
const char sigil = '$'
|
||||
);
|
||||
|
||||
|
||||
//- Get dictionary or (optionally) environment variable
|
||||
string getVariable
|
||||
(
|
||||
const word& name,
|
||||
const dictionary& dict,
|
||||
const bool allowEnvVars,
|
||||
const bool allowEmpty
|
||||
);
|
||||
|
||||
|
||||
//- Recursively expands (dictionary or environment) variable
|
||||
// starting at index in string. Updates index.
|
||||
string expand
|
||||
(
|
||||
const string& s,
|
||||
string::size_type& index,
|
||||
const dictionary& dict,
|
||||
const bool allowEnvVars,
|
||||
const bool allowEmpty
|
||||
);
|
||||
|
||||
|
||||
//- Inplace expand occurrences of variables according to the dictionary
|
||||
// and optionally environment variables
|
||||
// Expansion includes:
|
||||
// -# variables
|
||||
// - "$VAR", "${VAR}"
|
||||
// -# current directory
|
||||
// - leading "./" : the current directory
|
||||
// -# tilde expansion
|
||||
// - leading "~/" : home directory
|
||||
// - leading "~user" : home directory for specified user
|
||||
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
|
||||
//
|
||||
// with the "${}" syntax doing a recursive substitution.
|
||||
//
|
||||
// Any unknown entries are left as-is
|
||||
//
|
||||
// \note the leading sigil can be changed to avoid conflicts with other
|
||||
// string expansions
|
||||
string& inplaceExpand
|
||||
string& inplaceExpandEntry
|
||||
(
|
||||
string& s,
|
||||
const dictionary& dict,
|
||||
@ -177,102 +157,6 @@ namespace stringOps
|
||||
);
|
||||
|
||||
|
||||
//- Inplace expand occurrences of variables according to the dictionary
|
||||
// Expansion includes:
|
||||
// -# variables
|
||||
// - "$VAR", "${VAR}"
|
||||
//
|
||||
// Any unknown entries are left as-is
|
||||
//
|
||||
// \note the leading sigil can be changed to avoid conflicts with other
|
||||
// string expansions
|
||||
string& inplaceExpand
|
||||
(
|
||||
string&,
|
||||
const dictionary& dict,
|
||||
const char sigil = '$'
|
||||
);
|
||||
|
||||
|
||||
//- Expand initial tildes and all occurrences of environment variables
|
||||
// Expansion includes:
|
||||
// -# environment variables
|
||||
// - "$VAR", "${VAR}"
|
||||
// -# current directory
|
||||
// - leading "./" : the current directory
|
||||
// -# tilde expansion
|
||||
// - leading "~/" : home directory
|
||||
// - leading "~user" : home directory for specified user
|
||||
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
|
||||
//
|
||||
// Supports default values as per the Bourne/Korn shell.
|
||||
// \code
|
||||
// "${parameter:-defValue}"
|
||||
// \endcode
|
||||
// If parameter is unset or null, the \c defValue is substituted.
|
||||
// Otherwise, the value of parameter is substituted.
|
||||
//
|
||||
// Supports alternative values as per the Bourne/Korn shell.
|
||||
// \code
|
||||
// "${parameter:+altValue}"
|
||||
// \endcode
|
||||
// If parameter is unset or null, nothing is substituted.
|
||||
// Otherwise the \c altValue is substituted.
|
||||
//
|
||||
// Any unknown entries are removed silently, if allowEmpty is true.
|
||||
//
|
||||
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
|
||||
// are left as is.
|
||||
//
|
||||
// \sa
|
||||
// Foam::findEtcFile
|
||||
string expand
|
||||
(
|
||||
const string&,
|
||||
const bool allowEmpty = false
|
||||
);
|
||||
|
||||
|
||||
//- Expand initial tildes and all occurrences of environment variables
|
||||
// Expansion includes:
|
||||
// -# environment variables
|
||||
// - "$VAR", "${VAR}"
|
||||
// -# current directory
|
||||
// - leading "./" : the current directory
|
||||
// -# tilde expansion
|
||||
// - leading "~/" : home directory
|
||||
// - leading "~user" : home directory for specified user
|
||||
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
|
||||
//
|
||||
// Supports default values as per the Bourne/Korn shell.
|
||||
// \code
|
||||
// "${parameter:-defValue}"
|
||||
// \endcode
|
||||
// If parameter is unset or null, the \c defValue is substituted.
|
||||
// Otherwise, the value of parameter is substituted.
|
||||
//
|
||||
// Supports alternative values as per the Bourne/Korn shell.
|
||||
// \code
|
||||
// "${parameter:+altValue}"
|
||||
// \endcode
|
||||
// If parameter is unset or null, nothing is substituted.
|
||||
// Otherwise the \c altValue is substituted.
|
||||
//
|
||||
// Any unknown entries are removed silently, if allowEmpty is true.
|
||||
//
|
||||
// Malformed entries (eg, brace mismatch, sigil followed by bad character)
|
||||
// are left as is.
|
||||
//
|
||||
// Any unknown entries are removed silently if allowEmpty is true.
|
||||
// \sa
|
||||
// Foam::findEtcFile
|
||||
string& inplaceExpand
|
||||
(
|
||||
string&,
|
||||
const bool allowEmpty = false
|
||||
);
|
||||
|
||||
|
||||
//- Return string trimmed of leading whitespace
|
||||
string trimLeft(const string&);
|
||||
|
||||
|
||||
@ -70,12 +70,12 @@ void Foam::codedFixedValueFvPatchField<Type>::prepare
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile(codeTemplateH("codedFixedValueFvPatchField"));
|
||||
|
||||
// Debugging: make BC verbose
|
||||
// Make verbose if debugging
|
||||
dynCode.setFilterVariable("verbose", Foam::name(bool(debug)));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
dynCode.setFilterVariable("verbose", "true");
|
||||
Info<<"compile " << codeName() << " sha1: "
|
||||
<< context.sha1() << endl;
|
||||
Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl;
|
||||
}
|
||||
|
||||
// Define Make/options
|
||||
|
||||
@ -70,12 +70,12 @@ void Foam::codedMixedFvPatchField<Type>::prepare
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile(codeTemplateH("codedMixedFvPatchField"));
|
||||
|
||||
// Debugging: make BC verbose
|
||||
// Make verbose if debugging
|
||||
dynCode.setFilterVariable("verbose", Foam::name(bool(debug)));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
dynCode.setFilterVariable("verbose", "true");
|
||||
Info<<"compile " << codeName() << " sha1: "
|
||||
<< context.sha1() << endl;
|
||||
Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl;
|
||||
}
|
||||
|
||||
// Define Make/options
|
||||
|
||||
@ -80,12 +80,12 @@ void Foam::codedFunctionObject::prepare
|
||||
// Copy filtered H template
|
||||
dynCode.addCopyFile(codeTemplateH("codedFunctionObject"));
|
||||
|
||||
// Debugging: make verbose
|
||||
// Make verbose if debugging
|
||||
dynCode.setFilterVariable("verbose", Foam::name(bool(debug)));
|
||||
|
||||
if (debug)
|
||||
{
|
||||
dynCode.setFilterVariable("verbose", "true");
|
||||
Info<<"compile " << codeName() << " sha1: "
|
||||
<< context.sha1() << endl;
|
||||
Info<<"compile " << codeName() << " sha1: " << context.sha1() << endl;
|
||||
}
|
||||
|
||||
// Define Make/options
|
||||
|
||||
Reference in New Issue
Block a user