Commit 9e345e17 authored by andy's avatar andy
Browse files

ENH: Enabled dictionaries to be expanded in lists

parent c0f93b84
......@@ -28,6 +28,7 @@ License
#include "dictionaryEntry.H"
#include "regExp.H"
#include "OSHA1stream.H"
#include "DynamicList.H"
/* * * * * * * * * * * * * * * Static Member Data * * * * * * * * * * * * * */
......@@ -277,6 +278,25 @@ Foam::SHA1Digest Foam::dictionary::digest() const
}
Foam::tokenList Foam::dictionary::tokens() const
{
// linearise dictionary into a string
OStringStream os;
write(os, false);
IStringStream is(os.str());
// parse string as tokens
DynamicList<token> tokens;
token t;
while (is.read(t))
{
tokens.append(t);
}
return tokenList(tokens.xfer());
}
bool Foam::dictionary::found
(
const word& keyword,
......
......@@ -262,6 +262,9 @@ public:
//- Return the SHA1 digest of the dictionary contents
SHA1Digest digest() const;
//- Return the dictionary as a list of tokens
tokenList tokens() const;
// Search and lookup
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -72,7 +72,14 @@ bool Foam::primitiveEntry::expandVariable
// ...if defined append its tokens into this
if (ePtr)
{
append(ePtr->stream());
if (ePtr->isDict())
{
append(ePtr->dict().tokens());
}
else
{
append(ePtr->stream());
}
}
else
{
......
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