ENH:dictionary: allow scoped variable lookup (using '.')

This commit is contained in:
mattijs
2012-09-12 09:14:43 +01:00
parent c76acdd6ff
commit 87bab77daf
7 changed files with 179 additions and 34 deletions

View File

@ -51,7 +51,7 @@ boundaryField
inlet_4 { $inactive }
inlet_5 "a primitiveEntry is squashed by a directory entry";
inlet_5 { $inactive }
inlet_6 { $inactive }
inlet_6 { $.inactive } // Test scoping
inlet_7 { $inactive }
inlet_8 { $inactive }

View File

@ -24,7 +24,7 @@ keyY parentValue5;
"(.*)Dict"
{
foo subdictValue0;
bar $f.*; // should this really match 'foo'?
//bar $f.*; // should this really match 'foo'?
// result is dependent on insert order!
"a.*c" subdictValue3;

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-2012 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -94,41 +94,59 @@ int main(int argc, char *argv[])
if (args.optionFound("entry"))
{
wordList entryNames
(
fileName(args.option("entry")).components(':')
);
fileName entryName(args.option("entry"));
if (dict.found(entryNames[0]))
const entry* entPtr = NULL;
if (entryName.find('.') != string::npos)
{
const entry* entPtr = &dict.lookupEntry
// New syntax
entPtr = dict.lookupScopedEntryPtr
(
entryNames[0],
entryName,
false,
true // wildcards
);
for (int i=1; i<entryNames.size(); ++i)
}
else
{
// Old syntax
wordList entryNames(entryName.components(':'));
if (dict.found(entryNames[0]))
{
if (entPtr->dict().found(entryNames[i]))
entPtr = &dict.lookupEntry
(
entryNames[0],
false,
true // wildcards
);
for (int i=1; i<entryNames.size(); ++i)
{
entPtr = &entPtr->dict().lookupEntry
(
entryNames[i],
false,
true // wildcards
);
}
else
{
FatalErrorIn(args.executable())
<< "Cannot find sub-entry " << entryNames[i]
<< " in entry " << args["entry"]
<< " in dictionary " << dictFileName;
FatalError.exit(3);
if (entPtr->dict().found(entryNames[i]))
{
entPtr = &entPtr->dict().lookupEntry
(
entryNames[i],
false,
true // wildcards
);
}
else
{
FatalErrorIn(args.executable())
<< "Cannot find sub-entry " << entryNames[i]
<< " in entry " << args["entry"]
<< " in dictionary " << dictFileName;
FatalError.exit(3);
}
}
}
}
if (entPtr)
{
if (args.optionFound("keywords"))
{
/*
@ -158,7 +176,7 @@ int main(int argc, char *argv[])
{
FatalErrorIn(args.executable())
<< "Cannot find entry "
<< entryNames[0]
<< entryName
<< " in dictionary " << dictFileName;
FatalError.exit(2);
}