Commit f9d4a778 authored by mattijs's avatar mattijs
Browse files

ENH: #calc: allow in primitiveEntry

parent d6ae8d56
......@@ -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
......@@ -37,6 +37,14 @@ namespace functionEntries
{
defineTypeNameAndDebug(calcEntry, 0);
addToMemberFunctionSelectionTable
(
functionEntry,
calcEntry,
execute,
dictionaryIstream
);
addToMemberFunctionSelectionTable
(
functionEntry,
......@@ -96,4 +104,48 @@ bool Foam::functionEntries::calcEntry::execute
}
bool Foam::functionEntries::calcEntry::execute
(
dictionary& parentDict,
Istream& is
)
{
Info<< "Using #calcEntry at line " << is.lineNumber()
<< " in file " << parentDict.name() << endl;
dynamicCode::checkSecurity
(
"functionEntries::calcEntry::execute(..)",
parentDict
);
// Read string
string s(is);
// Make sure we stop this entry
//is.putBack(token(token::END_STATEMENT, is.lineNumber()));
// Construct codeDict for codeStream
// must reference parent for stringOps::expand to work nicely.
dictionary codeSubDict;
codeSubDict.add("code", "os << (" + s + ");");
dictionary codeDict(parentDict, codeSubDict);
codeStream::streamingFunctionType function = codeStream::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
......@@ -89,6 +89,9 @@ 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,
......
Supports Markdown
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