From dced4a082a691479f3f0de58479e531edd19e240 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 12 Oct 2012 12:23:34 +0100 Subject: [PATCH] ENH: #include: allow dictionary variables in include paths --- .../functionEntries/includeEntry/includeEntry.C | 10 ++++++---- .../functionEntries/includeEntry/includeEntry.H | 4 ++-- .../includeIfPresentEntry/includeIfPresentEntry.C | 6 +++--- src/OpenFOAM/primitives/strings/stringOps/stringOps.C | 9 +++++++-- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index eb8fd09280..c07038366e 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -27,6 +27,7 @@ License #include "dictionary.H" #include "IFstream.H" #include "addToMemberFunctionSelectionTable.H" +#include "stringOps.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -68,11 +69,12 @@ namespace functionEntries Foam::fileName Foam::functionEntries::includeEntry::includeFileName ( - Istream& is + Istream& is, + const dictionary& dict ) { fileName fName(is); - fName.expand(); + stringOps::inplaceExpand(fName, dict); if (fName.empty() || fName.isAbsolute()) { @@ -94,7 +96,7 @@ bool Foam::functionEntries::includeEntry::execute Istream& is ) { - const fileName fName(includeFileName(is)); + const fileName fName(includeFileName(is, parentDict)); IFstream ifs(fName); if (ifs) @@ -129,7 +131,7 @@ bool Foam::functionEntries::includeEntry::execute Istream& is ) { - const fileName fName(includeFileName(is)); + const fileName fName(includeFileName(is, parentDict)); IFstream ifs(fName); if (ifs) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H index c1c847a0c3..87b45c4516 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,7 +77,7 @@ protected: // Protected Member Functions //- Read the include fileName from Istream, expand and return - static fileName includeFileName(Istream&); + static fileName includeFileName(Istream&, const dictionary&); public: diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C index 0807bbd0b8..2c0ccc9893 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeIfPresentEntry/includeIfPresentEntry.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -69,7 +69,7 @@ bool Foam::functionEntries::includeIfPresentEntry::execute Istream& is ) { - const fileName fName(includeFileName(is)); + const fileName fName(includeFileName(is, parentDict)); IFstream ifs(fName); if (ifs) @@ -92,7 +92,7 @@ bool Foam::functionEntries::includeIfPresentEntry::execute Istream& is ) { - const fileName fName(includeFileName(is)); + const fileName fName(includeFileName(is, parentDict)); IFstream ifs(fName); if (ifs) diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C index e7493b78e9..194309cd3c 100644 --- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C +++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -322,7 +322,12 @@ Foam::string& Foam::stringOps::inplaceExpand // lookup in the dictionary - const entry* ePtr = dict.lookupEntryPtr(varName, true, true); + const entry* ePtr = dict.lookupScopedEntryPtr + ( + varName, + true, + false // wildcards disabled. See primitiveEntry + ); // if defined - copy its entries if (ePtr)