mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
dictionary functionEntries cleanup
* added '#remove' function * changed insert() method name to more general execute() * using #inputMode or #remove within a primitiveEntry now provokes an error * adjusted the dictionaryTest accordingly
This commit is contained in:
@ -42,24 +42,17 @@ namespace functionEntries
|
||||
(
|
||||
functionEntry,
|
||||
calcEntry,
|
||||
insert,
|
||||
execute,
|
||||
primitiveEntryIstream
|
||||
);
|
||||
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
calcEntry,
|
||||
insert,
|
||||
dictionaryIstream
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionEntries::calcEntry::insert
|
||||
bool Foam::functionEntries::calcEntry::execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
@ -75,14 +68,4 @@ bool Foam::functionEntries::calcEntry::insert
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntries::calcEntry::insert
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -69,18 +69,13 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
static bool insert
|
||||
static bool execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
Istream& is
|
||||
);
|
||||
|
||||
static bool insert
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -1,17 +1,19 @@
|
||||
/*-------------------------------*- C++ -*---------------------------------*\
|
||||
| ========= |
|
||||
| \\ / OpenFOAM |
|
||||
| \\ / |
|
||||
| \\ / The Open Source CFD Toolbox |
|
||||
| \\/ http://www.OpenFOAM.org |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
|
||||
root "";
|
||||
case "";
|
||||
instance "";
|
||||
local "";
|
||||
|
||||
class dictionary;
|
||||
object testDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
#inputMode merge
|
||||
|
||||
dimensions [ 0 2 -2 0 0 0 0 ];
|
||||
internalField uniform 1;
|
||||
@ -29,7 +31,6 @@ inactive
|
||||
type zeroGradient;
|
||||
}
|
||||
|
||||
|
||||
boundaryField
|
||||
{
|
||||
Default_Boundary_Region
|
||||
@ -40,6 +41,12 @@ boundaryField
|
||||
inlet_1 { $active }
|
||||
inlet_2 { $inactive }
|
||||
inlet_3 { $inactive }
|
||||
inlet_4 { $inactive }
|
||||
inlet_5 "a primitiveEntry is squashed by a directory entry";
|
||||
inlet_5 { $inactive }
|
||||
inlet_6 { $inactive }
|
||||
inlet_7 { $inactive }
|
||||
inlet_8 { $inactive }
|
||||
|
||||
#include "testDictInc"
|
||||
|
||||
@ -48,8 +55,44 @@ boundaryField
|
||||
type inletOutlet;
|
||||
inletValue $internalField;
|
||||
value #include "value";
|
||||
// error #remove self;
|
||||
x 5;
|
||||
y 6;
|
||||
another #calc{x $x; y $y;};
|
||||
}
|
||||
|
||||
// this should have no effect
|
||||
#remove inactive
|
||||
|
||||
inlet_7 { $active }
|
||||
#inputMode overwrite
|
||||
inlet_8 { $active }
|
||||
}
|
||||
|
||||
// NB: the inputMode has a global scope
|
||||
#inputMode merge
|
||||
#include "testDict2"
|
||||
|
||||
foo
|
||||
{
|
||||
$active
|
||||
}
|
||||
|
||||
bar
|
||||
{
|
||||
$active
|
||||
}
|
||||
|
||||
baz
|
||||
{
|
||||
$active
|
||||
}
|
||||
|
||||
|
||||
// this should work
|
||||
#remove active
|
||||
|
||||
// this should work too
|
||||
#remove ( bar baz )
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
30
applications/test/dictionary/testDict2
Normal file
30
applications/test/dictionary/testDict2
Normal file
@ -0,0 +1,30 @@
|
||||
/*-------------------------------*- C++ -*---------------------------------*\
|
||||
| ========= |
|
||||
| \\ / OpenFOAM |
|
||||
| \\ / |
|
||||
| \\ / The Open Source CFD Toolbox |
|
||||
| \\/ http://www.OpenFOAM.org |
|
||||
\*-------------------------------------------------------------------------*/
|
||||
FoamFile
|
||||
{
|
||||
version 2.0;
|
||||
format ascii;
|
||||
class dictionary;
|
||||
object testDict;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
boundaryField
|
||||
{
|
||||
Default_Boundary_Region
|
||||
{
|
||||
value $internalField;
|
||||
note "actually a noslip wall";
|
||||
}
|
||||
|
||||
inlet_3 "a primitiveEntry squashes directory entry";
|
||||
}
|
||||
|
||||
#inputMode overwrite
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -1 +1,2 @@
|
||||
uniform 2
|
||||
// the trailing ';' shouldn't actually be there, but shouldn't cause problems
|
||||
uniform 2;
|
||||
|
||||
@ -122,6 +122,7 @@ functionEntries = $(dictionary)/functionEntries
|
||||
$(functionEntries)/functionEntry/functionEntry.C
|
||||
$(functionEntries)/includeEntry/includeEntry.C
|
||||
$(functionEntries)/inputModeEntry/inputModeEntry.C
|
||||
$(functionEntries)/removeEntry/removeEntry.C
|
||||
|
||||
IOdictionary = db/IOobjects/IOdictionary
|
||||
$(IOdictionary)/IOdictionary.C
|
||||
|
||||
@ -96,7 +96,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
if (keyword[0] == '#') // ... Function entry
|
||||
{
|
||||
word functionName = keyword(1, keyword.size()-1);
|
||||
return functionEntry::insert(functionName, parentDict, is);
|
||||
return functionEntry::execute(functionName, parentDict, is);
|
||||
}
|
||||
else if (keyword[0] == '$') // ... Substitution entry
|
||||
{
|
||||
@ -105,7 +105,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
}
|
||||
else if (keyword == "include") // ... For backward compatibility
|
||||
{
|
||||
return functionEntries::includeEntry::insert(parentDict, is);
|
||||
return functionEntries::includeEntry::execute(parentDict, is);
|
||||
}
|
||||
else // ... Data entries
|
||||
{
|
||||
@ -114,12 +114,18 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
|
||||
// Deal with duplicate entries
|
||||
bool mergeEntry = false;
|
||||
if (parentDict.found(keyword))
|
||||
|
||||
entry* existingPtr = parentDict.lookupEntryPtr(keyword);
|
||||
if (existingPtr)
|
||||
{
|
||||
if (functionEntries::inputModeEntry::overwrite())
|
||||
{
|
||||
// silently drop previous entries
|
||||
parentDict.remove(keyword);
|
||||
// clear dictionary so merge acts like overwrite
|
||||
if (existingPtr->isDict())
|
||||
{
|
||||
existingPtr->dict().clear();
|
||||
}
|
||||
mergeEntry = true;
|
||||
}
|
||||
else if (functionEntries::inputModeEntry::merge())
|
||||
{
|
||||
|
||||
@ -33,22 +33,66 @@ namespace Foam
|
||||
defineMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
insert,
|
||||
primitiveEntryIstream
|
||||
execute,
|
||||
dictionaryIstream
|
||||
);
|
||||
|
||||
defineMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
insert,
|
||||
dictionaryIstream
|
||||
execute,
|
||||
primitiveEntryIstream
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * Member Function Selectors * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionEntry::insert
|
||||
bool Foam::functionEntry::execute
|
||||
(
|
||||
const word& functionName,
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
is.fatalCheck
|
||||
(
|
||||
"functionEntry::execute"
|
||||
"(const word& functionName, dictionary& parentDict, Istream& is)"
|
||||
);
|
||||
|
||||
if (!executedictionaryIstreamMemberFunctionTablePtr_)
|
||||
{
|
||||
cerr<<"functionEntry::execute"
|
||||
<< "(const word&, dictionary&, Istream&)"
|
||||
<< " not yet initialized, function = "
|
||||
<< functionName.c_str() << std::endl;
|
||||
|
||||
// Return true to keep reading
|
||||
return true;
|
||||
}
|
||||
|
||||
executedictionaryIstreamMemberFunctionTable::iterator mfIter =
|
||||
executedictionaryIstreamMemberFunctionTablePtr_->find(functionName);
|
||||
|
||||
if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"functionEntry::execute"
|
||||
"(const word& functionName, dictionary& parentDict, Istream&)"
|
||||
) << "Unknown functionEntry " << functionName
|
||||
<< endl << endl
|
||||
<< "Valid functionEntries are :" << endl
|
||||
<< executedictionaryIstreamMemberFunctionTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return mfIter()(parentDict, is);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntry::execute
|
||||
(
|
||||
const word& functionName,
|
||||
const dictionary& parentDict,
|
||||
@ -58,14 +102,14 @@ bool Foam::functionEntry::insert
|
||||
{
|
||||
is.fatalCheck
|
||||
(
|
||||
"functionEntry::insert"
|
||||
"functionEntry::execute"
|
||||
"(const word& functionName, const dictionary& parentDict, "
|
||||
"primitiveEntry& entry, Istream& is)"
|
||||
"primitiveEntry&, Istream&)"
|
||||
);
|
||||
|
||||
if (!insertprimitiveEntryIstreamMemberFunctionTablePtr_)
|
||||
if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_)
|
||||
{
|
||||
cerr<<"functionEntry::insert"
|
||||
cerr<<"functionEntry::execute"
|
||||
<< "(const word&, dictionary&, primitiveEntry&, Istream&)"
|
||||
<< " not yet initialized, function = "
|
||||
<< functionName.c_str() << std::endl;
|
||||
@ -74,69 +118,24 @@ bool Foam::functionEntry::insert
|
||||
return true;
|
||||
}
|
||||
|
||||
insertprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
|
||||
insertprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
|
||||
executeprimitiveEntryIstreamMemberFunctionTable::iterator mfIter =
|
||||
executeprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName);
|
||||
|
||||
if (mfIter == insertprimitiveEntryIstreamMemberFunctionTablePtr_->end())
|
||||
if (mfIter == executeprimitiveEntryIstreamMemberFunctionTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"functionEntry::insert"
|
||||
"functionEntry::execute"
|
||||
"(const word& functionName, const dictionary& parentDict, "
|
||||
"primitiveEntry& entry, Istream& is)"
|
||||
"primitiveEntry&, Istream&)"
|
||||
) << "Unknown functionEntry " << functionName
|
||||
<< endl << endl
|
||||
<< "Valid functionEntries are :" << endl
|
||||
<< insertprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
|
||||
<< executeprimitiveEntryIstreamMemberFunctionTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return mfIter()(parentDict, entry, is);
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntry::insert
|
||||
(
|
||||
const word& functionName,
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
is.fatalCheck
|
||||
(
|
||||
"functionEntry::insert"
|
||||
"(const word& functionName, dictionary& parentDict, Istream& is)"
|
||||
);
|
||||
|
||||
if (!insertdictionaryIstreamMemberFunctionTablePtr_)
|
||||
{
|
||||
cerr<<"functionEntry::insert"
|
||||
<< "(const word&, dictionary&, Istream&)"
|
||||
<< " not yet initialized, function = "
|
||||
<< functionName.c_str() << std::endl;
|
||||
|
||||
// Return true to keep reading
|
||||
return true;
|
||||
}
|
||||
|
||||
insertdictionaryIstreamMemberFunctionTable::iterator mfIter =
|
||||
insertdictionaryIstreamMemberFunctionTablePtr_->find(functionName);
|
||||
|
||||
if (mfIter == insertdictionaryIstreamMemberFunctionTablePtr_->end())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"functionEntry::insert"
|
||||
"(const word& functionName, dictionary& parentDict, Istream& is)"
|
||||
) << "Unknown functionEntry " << functionName
|
||||
<< endl << endl
|
||||
<< "Valid functionEntries are :" << endl
|
||||
<< insertdictionaryIstreamMemberFunctionTablePtr_->toc()
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
return mfIter()(parentDict, is);
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -33,13 +33,10 @@ Class
|
||||
Foam::functionEntry
|
||||
|
||||
Description
|
||||
A function entry causes entries to be added/manipulated on the specified
|
||||
A functionEntry causes entries to be added/manipulated on the specified
|
||||
dictionary given an input stream.
|
||||
|
||||
In dictionaries, a @c \# sigil is typically used for a functionEntry.
|
||||
|
||||
See Also
|
||||
functionEntries::includeEntry and functionEntries::inputModeEntry
|
||||
In dictionaries, a @c '\#' sigil is typically used for a functionEntry.
|
||||
|
||||
SourceFiles
|
||||
functionEntry.C
|
||||
@ -84,7 +81,28 @@ public:
|
||||
(
|
||||
bool,
|
||||
functionEntry,
|
||||
insert,
|
||||
execute,
|
||||
dictionaryIstream,
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
),
|
||||
(parentDict, is)
|
||||
);
|
||||
|
||||
//- Execute the functionEntry in a sub-dict context
|
||||
static bool execute
|
||||
(
|
||||
const word& functionName,
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
);
|
||||
|
||||
declareMemberFunctionSelectionTable
|
||||
(
|
||||
bool,
|
||||
functionEntry,
|
||||
execute,
|
||||
primitiveEntryIstream,
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
@ -94,7 +112,8 @@ public:
|
||||
(parentDict, entry, is)
|
||||
);
|
||||
|
||||
static bool insert
|
||||
//- Execute the functionEntry in a primitiveEntry context
|
||||
static bool execute
|
||||
(
|
||||
const word& functionName,
|
||||
const dictionary& parentDict,
|
||||
@ -103,25 +122,6 @@ public:
|
||||
);
|
||||
|
||||
|
||||
declareMemberFunctionSelectionTable
|
||||
(
|
||||
bool,
|
||||
functionEntry,
|
||||
insert,
|
||||
dictionaryIstream,
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
),
|
||||
(parentDict, is)
|
||||
);
|
||||
|
||||
static bool insert
|
||||
(
|
||||
const word& functionName,
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -48,16 +48,16 @@ namespace functionEntries
|
||||
(
|
||||
functionEntry,
|
||||
includeEntry,
|
||||
insert,
|
||||
primitiveEntryIstream
|
||||
execute,
|
||||
dictionaryIstream
|
||||
);
|
||||
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
includeEntry,
|
||||
insert,
|
||||
dictionaryIstream
|
||||
execute,
|
||||
primitiveEntryIstream
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,35 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntries::includeEntry::insert
|
||||
bool Foam::functionEntries::includeEntry::execute
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
IFstream fileStream(includeFileName(is));
|
||||
|
||||
if (fileStream)
|
||||
{
|
||||
parentDict.read(fileStream);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::includeEntry::includeEntry"
|
||||
"(dictionary& parentDict,Istream& is)",
|
||||
is
|
||||
) << "Cannot open include file " << fileStream.name()
|
||||
<< " while reading dictionary " << parentDict.name()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
bool Foam::functionEntries::includeEntry::execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
@ -111,34 +139,4 @@ bool Foam::functionEntries::includeEntry::insert
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntries::includeEntry::insert
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
IFstream fileStream(includeFileName(is));
|
||||
|
||||
if (fileStream)
|
||||
{
|
||||
parentDict.read(fileStream);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"functionEntries::includeEntry::includeEntry"
|
||||
"(dictionary& parentDict,Istream& is)",
|
||||
is
|
||||
) << "Cannot open include file " << fileStream.name()
|
||||
<< " while reading dictionary " << parentDict.name()
|
||||
<< exit(FatalIOError);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -29,9 +29,9 @@ Description
|
||||
Specify an include file when reading dictionaries, expects a
|
||||
single string to follow.
|
||||
|
||||
An example of @c \#include directive:
|
||||
An example of the @c \#include directive:
|
||||
@verbatim
|
||||
\#include "includefile"
|
||||
#include "includeFile"
|
||||
@endverbatim
|
||||
|
||||
The usual expansion of environment variables and other constructs (eg,
|
||||
@ -85,18 +85,21 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
static bool insert
|
||||
//- Execute the functionEntry in a sub-dict context
|
||||
static bool execute
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
);
|
||||
|
||||
//- Execute the functionEntry in a primitiveEntry context
|
||||
static bool execute
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
Istream& is
|
||||
);
|
||||
|
||||
static bool insert
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -47,15 +47,7 @@ namespace functionEntries
|
||||
(
|
||||
functionEntry,
|
||||
inputModeEntry,
|
||||
insert,
|
||||
primitiveEntryIstream
|
||||
);
|
||||
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
inputModeEntry,
|
||||
insert,
|
||||
execute,
|
||||
dictionaryIstream
|
||||
);
|
||||
}
|
||||
@ -63,7 +55,7 @@ namespace functionEntries
|
||||
|
||||
// * * * * * * * * * * * * * * * * Private Data * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::label Foam::functionEntries::inputModeEntry::inputMode_ = imError;
|
||||
Foam::label Foam::functionEntries::inputModeEntry::mode_ = imError;
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
@ -74,15 +66,15 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
|
||||
word mode(is);
|
||||
if (mode == "merge")
|
||||
{
|
||||
inputMode_ = imMerge;
|
||||
mode_ = imMerge;
|
||||
}
|
||||
else if (mode == "overwrite")
|
||||
{
|
||||
inputMode_ = imOverwrite;
|
||||
mode_ = imOverwrite;
|
||||
}
|
||||
else if (mode == "error" || mode == "default")
|
||||
{
|
||||
inputMode_ = imError;
|
||||
mode_ = imError;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -95,19 +87,7 @@ void Foam::functionEntries::inputModeEntry::setMode(Istream& is)
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionEntries::inputModeEntry::insert
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry& entry,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
setMode(is);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntries::inputModeEntry::insert
|
||||
bool Foam::functionEntries::inputModeEntry::execute
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
@ -120,13 +100,13 @@ bool Foam::functionEntries::inputModeEntry::insert
|
||||
|
||||
void Foam::functionEntries::inputModeEntry::clear()
|
||||
{
|
||||
inputMode_ = imError;
|
||||
mode_ = imError;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionEntries::inputModeEntry::merge()
|
||||
{
|
||||
if (inputMode_ & imMerge)
|
||||
if (mode_ & imMerge)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@ -139,7 +119,7 @@ bool Foam::functionEntries::inputModeEntry::merge()
|
||||
|
||||
bool Foam::functionEntries::inputModeEntry::overwrite()
|
||||
{
|
||||
if (inputMode_ & imOverwrite)
|
||||
if (mode_ & imOverwrite)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -74,11 +74,12 @@ class inputModeEntry
|
||||
};
|
||||
|
||||
//- current input mode
|
||||
static label inputMode_;
|
||||
static label mode_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Read the mode as a word and set enum appropriately
|
||||
static void setMode(Istream&);
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
@ -96,23 +97,20 @@ public:
|
||||
|
||||
// Member Functions
|
||||
|
||||
static bool insert
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
primitiveEntry&,
|
||||
Istream&
|
||||
);
|
||||
|
||||
static bool insert
|
||||
//- Execute the functionEntry in a sub-dict context
|
||||
static bool execute
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream&
|
||||
);
|
||||
|
||||
//- Reset the inputMode to 'default'
|
||||
static void clear();
|
||||
|
||||
//- Return true if the inputMode is 'merge'
|
||||
static bool merge();
|
||||
|
||||
//- Return true if the inputMode is 'overwrite'
|
||||
static bool overwrite();
|
||||
|
||||
};
|
||||
|
||||
@ -0,0 +1,88 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "removeEntry.H"
|
||||
#include "dictionary.H"
|
||||
#include "IStringStream.H"
|
||||
#include "OStringStream.H"
|
||||
#include "addToMemberFunctionSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
const Foam::word Foam::functionEntries::removeEntry::typeName
|
||||
(
|
||||
Foam::functionEntries::removeEntry::typeName_()
|
||||
);
|
||||
|
||||
// Don't lookup the debug switch here as the debug switch dictionary
|
||||
// might include removeEntry
|
||||
int Foam::functionEntries::removeEntry::debug(0);
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionEntries
|
||||
{
|
||||
addToMemberFunctionSelectionTable
|
||||
(
|
||||
functionEntry,
|
||||
removeEntry,
|
||||
execute,
|
||||
dictionaryIstream
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionEntries::removeEntry::execute
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
{
|
||||
token currToken(is);
|
||||
is.putBack(currToken);
|
||||
|
||||
if (currToken == token::BEGIN_LIST)
|
||||
{
|
||||
wordList keys(is);
|
||||
|
||||
forAll(keys, keyI)
|
||||
{
|
||||
parentDict.remove(keys[keyI]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
word key(is);
|
||||
parentDict.remove(key);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,100 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 1991-2007 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software; you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by the
|
||||
Free Software Foundation; either version 2 of the License, or (at your
|
||||
option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Class
|
||||
Foam::functionEntries::removeEntry
|
||||
|
||||
Description
|
||||
Remove a dictionary entry.
|
||||
|
||||
The @c \#remove directive takes a word or a list of words. For example,
|
||||
@verbatim
|
||||
#remove entry0
|
||||
#remove ( entry1 entry2 entry3 )
|
||||
@endverbatim
|
||||
|
||||
The removable only occurs in the current context.
|
||||
Removing sub-entries or parent entries is not supported.
|
||||
|
||||
SourceFiles
|
||||
removeEntry.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef removeEntry_H
|
||||
#define removeEntry_H
|
||||
|
||||
#include "functionEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionEntries
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class removeEntry Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class removeEntry
|
||||
:
|
||||
public functionEntry
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
removeEntry(const removeEntry&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const removeEntry&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("remove");
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Execute the functionEntry in a sub-dict context
|
||||
static bool execute
|
||||
(
|
||||
dictionary& parentDict,
|
||||
Istream& is
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionEntries
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -115,7 +115,7 @@ bool Foam::primitiveEntry::expandFunction
|
||||
)
|
||||
{
|
||||
word functionName = keyword(1, keyword.size()-1);
|
||||
return functionEntry::insert(functionName, parentDict, *this, is);
|
||||
return functionEntry::execute(functionName, parentDict, *this, is);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user