Skip to content
Snippets Groups Projects
Commit 0d8fff3a authored by mattijs's avatar mattijs
Browse files

ENH: codeStream: function in dictionary context

parent 0b7e7d87
No related merge requests found
......@@ -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;
}
......
......@@ -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,
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment