ENH: Enabled dictionaries to be expanded in lists

This commit is contained in:
andy
2013-12-06 10:24:23 +00:00
parent c0f93b84bf
commit 9e345e1780
3 changed files with 32 additions and 2 deletions

View File

@ -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,

View File

@ -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

View File

@ -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
{