ENH: codeStream: function in dictionary context

This commit is contained in:
mattijs
2013-08-17 05:28:31 +01:00
parent 0b7e7d870d
commit 0d8fff3a5f
2 changed files with 45 additions and 1 deletions

View File

@ -39,6 +39,14 @@ namespace functionEntries
{
defineTypeNameAndDebug(codeStream, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
codeStream,
execute,
dictionaryIstream
);
addToMemberFunctionSelectionTable
(
functionEntry,
@ -364,6 +372,38 @@ bool Foam::functionEntries::codeStream::execute
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);
return true;
}
bool Foam::functionEntries::codeStream::execute
(
dictionary& parentDict,
Istream& is
)
{
Info<< "Using #codeStream at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::codeStream::execute(..)",
parentDict
);
// get code dictionary
// must reference parent for stringOps::expand to work nicely
dictionary codeDict("#codeStream", parentDict, is);
streamingFunctionType function = getFunction(parentDict, codeDict);
// use function to write stream
OStringStream os(is.format());
(*function)(os, parentDict);
// get the entry from this stream
IStringStream resultStream(os.str());
parentDict.read(resultStream);
return true;
}

View File

@ -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-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -160,6 +160,10 @@ public:
// Member Functions
//- Execute the functionEntry in a sub-dict context
static bool execute(dictionary& parentDict, Istream&);
//- Execute the functionEntry in a primitiveEntry context
static bool execute
(
const dictionary& parentDict,