diff --git a/applications/test/dictionary/calcEntry/calcEntry.C b/applications/test/dictionary/calcEntry/calcEntry.C index 6fb009456bf4b2b79299cc69f9153e83c458b182..d148f5d829efb5c3ed144fc91284d159258d8fb2 100644 --- a/applications/test/dictionary/calcEntry/calcEntry.C +++ b/applications/test/dictionary/calcEntry/calcEntry.C @@ -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; -} - - // ************************************************************************* // diff --git a/applications/test/dictionary/calcEntry/calcEntry.H b/applications/test/dictionary/calcEntry/calcEntry.H index c4c725dfb0ad8380a0fd1b0aced3e4d8b1e30418..157bdc6d02abe8019f77182698e1c597383b4e76 100644 --- a/applications/test/dictionary/calcEntry/calcEntry.H +++ b/applications/test/dictionary/calcEntry/calcEntry.H @@ -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 - ); }; diff --git a/applications/test/dictionary/testDict b/applications/test/dictionary/testDict index 70f6885e7ef345028a910a08c2691d2e7d6a6a82..9bd58c58ae9faf9d61118341ce0d13c85c049946 100644 --- a/applications/test/dictionary/testDict +++ b/applications/test/dictionary/testDict @@ -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 ) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/dictionary/testDict2 b/applications/test/dictionary/testDict2 new file mode 100644 index 0000000000000000000000000000000000000000..6c55ab384c22c0ce1c1e324306a68594e2afca1e --- /dev/null +++ b/applications/test/dictionary/testDict2 @@ -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 +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/test/dictionary/value b/applications/test/dictionary/value index 196f9d3d0a639b5120ba76846b0612094b137245..6a860dc353314050925f870b0548c7fc7e3924e0 100644 --- a/applications/test/dictionary/value +++ b/applications/test/dictionary/value @@ -1 +1,2 @@ -uniform 2 +// the trailing ';' shouldn't actually be there, but shouldn't cause problems +uniform 2; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index c9be7642ba5b3d6dbcd6e20226138f256cd8fabc..7b137dedc036386457c906dff90927cfa2bcf610 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -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 diff --git a/src/OpenFOAM/db/dictionary/entry/entryIO.C b/src/OpenFOAM/db/dictionary/entry/entryIO.C index 1b2b2016c92cf7e4c606fbc864206545328953bd..84efb2bfc2a6ae443a7d6d3e6432114c9c9ea479 100644 --- a/src/OpenFOAM/db/dictionary/entry/entryIO.C +++ b/src/OpenFOAM/db/dictionary/entry/entryIO.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()) { diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C index 7e53591c64243029bc414605b66d581231faf074..3d4b037dfc8aad6541fe734101695b141af37aff 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.C @@ -33,110 +33,109 @@ 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, - const dictionary& parentDict, - primitiveEntry& entry, + dictionary& parentDict, Istream& is ) { is.fatalCheck ( - "functionEntry::insert" - "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry& entry, Istream& is)" + "functionEntry::execute" + "(const word& functionName, dictionary& parentDict, Istream& is)" ); - if (!insertprimitiveEntryIstreamMemberFunctionTablePtr_) + if (!executedictionaryIstreamMemberFunctionTablePtr_) { - cerr<<"functionEntry::insert" - << "(const word&, dictionary&, primitiveEntry&, Istream&)" + cerr<<"functionEntry::execute" + << "(const word&, dictionary&, Istream&)" << " not yet initialized, function = " << functionName.c_str() << std::endl; - // return true to keep reading anyhow + // Return true to keep reading return true; } - insertprimitiveEntryIstreamMemberFunctionTable::iterator mfIter = - insertprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName); + executedictionaryIstreamMemberFunctionTable::iterator mfIter = + executedictionaryIstreamMemberFunctionTablePtr_->find(functionName); - if (mfIter == insertprimitiveEntryIstreamMemberFunctionTablePtr_->end()) + if (mfIter == executedictionaryIstreamMemberFunctionTablePtr_->end()) { FatalErrorIn ( - "functionEntry::insert" - "(const word& functionName, const dictionary& parentDict, " - "primitiveEntry& entry, Istream& is)" + "functionEntry::execute" + "(const word& functionName, dictionary& parentDict, Istream&)" ) << "Unknown functionEntry " << functionName << endl << endl << "Valid functionEntries are :" << endl - << insertprimitiveEntryIstreamMemberFunctionTablePtr_->toc() + << executedictionaryIstreamMemberFunctionTablePtr_->toc() << exit(FatalError); } - return mfIter()(parentDict, entry, is); + return mfIter()(parentDict, is); } -bool Foam::functionEntry::insert +bool Foam::functionEntry::execute ( const word& functionName, - dictionary& parentDict, + const dictionary& parentDict, + primitiveEntry& entry, Istream& is ) { is.fatalCheck ( - "functionEntry::insert" - "(const word& functionName, dictionary& parentDict, Istream& is)" + "functionEntry::execute" + "(const word& functionName, const dictionary& parentDict, " + "primitiveEntry&, Istream&)" ); - if (!insertdictionaryIstreamMemberFunctionTablePtr_) + if (!executeprimitiveEntryIstreamMemberFunctionTablePtr_) { - cerr<<"functionEntry::insert" - << "(const word&, dictionary&, Istream&)" + cerr<<"functionEntry::execute" + << "(const word&, dictionary&, primitiveEntry&, Istream&)" << " not yet initialized, function = " << functionName.c_str() << std::endl; - // Return true to keep reading + // return true to keep reading anyhow return true; } - insertdictionaryIstreamMemberFunctionTable::iterator mfIter = - insertdictionaryIstreamMemberFunctionTablePtr_->find(functionName); + executeprimitiveEntryIstreamMemberFunctionTable::iterator mfIter = + executeprimitiveEntryIstreamMemberFunctionTablePtr_->find(functionName); - if (mfIter == insertdictionaryIstreamMemberFunctionTablePtr_->end()) + if (mfIter == executeprimitiveEntryIstreamMemberFunctionTablePtr_->end()) { FatalErrorIn ( - "functionEntry::insert" - "(const word& functionName, dictionary& parentDict, Istream& is)" + "functionEntry::execute" + "(const word& functionName, const dictionary& parentDict, " + "primitiveEntry&, Istream&)" ) << "Unknown functionEntry " << functionName << endl << endl << "Valid functionEntries are :" << endl - << insertdictionaryIstreamMemberFunctionTablePtr_->toc() + << executeprimitiveEntryIstreamMemberFunctionTablePtr_->toc() << exit(FatalError); } - return mfIter()(parentDict, is); + return mfIter()(parentDict, entry, is); } - // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H index aa579420d2435c35b2c7c5e309bbf659362d6da4..20f1d9b2479d22a73819956f9e3acd7096cd37dd 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/functionEntry/functionEntry.H @@ -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,44 +81,47 @@ public: ( bool, functionEntry, - insert, - primitiveEntryIstream, + execute, + dictionaryIstream, ( - const dictionary& parentDict, - primitiveEntry& entry, + dictionary& parentDict, Istream& is ), - (parentDict, entry, is) + (parentDict, is) ); - static bool insert + //- Execute the functionEntry in a sub-dict context + static bool execute ( const word& functionName, - const dictionary& parentDict, - primitiveEntry& entry, + dictionary& parentDict, Istream& is ); - declareMemberFunctionSelectionTable ( bool, functionEntry, - insert, - dictionaryIstream, + execute, + primitiveEntryIstream, ( - dictionary& parentDict, + const dictionary& parentDict, + primitiveEntry& entry, Istream& is ), - (parentDict, is) + (parentDict, entry, is) ); - static bool insert + //- Execute the functionEntry in a primitiveEntry context + static bool execute ( const word& functionName, - dictionary& parentDict, + const dictionary& parentDict, + primitiveEntry& entry, Istream& is ); + + }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C index 81a8c0b23f4b2c1d65a74f3c022958cc67e09045..60af24c58948f25437e05a8025faf05086906c30 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.C @@ -48,16 +48,16 @@ namespace functionEntries ( functionEntry, includeEntry, - insert, - primitiveEntryIstream + execute, + dictionaryIstream ); addToMemberFunctionSelectionTable ( functionEntry, includeEntry, - insert, - dictionaryIstream + execute, + primitiveEntryIstream ); } } @@ -82,10 +82,9 @@ Foam::fileName Foam::functionEntries::includeEntry::includeFileName } -bool Foam::functionEntries::includeEntry::insert +bool Foam::functionEntries::includeEntry::execute ( - const dictionary& parentDict, - primitiveEntry& entry, + dictionary& parentDict, Istream& is ) { @@ -93,7 +92,7 @@ bool Foam::functionEntries::includeEntry::insert if (fileStream) { - entry.read(parentDict, fileStream); + parentDict.read(fileStream); return true; } else @@ -101,7 +100,7 @@ bool Foam::functionEntries::includeEntry::insert FatalIOErrorIn ( "functionEntries::includeEntry::includeEntry" - "(dictionary& parentDict, primitiveEntry& entry, Istream& is)", + "(dictionary& parentDict,Istream& is)", is ) << "Cannot open include file " << fileStream.name() << " while reading dictionary " << parentDict.name() @@ -111,10 +110,10 @@ bool Foam::functionEntries::includeEntry::insert } } - -bool Foam::functionEntries::includeEntry::insert +bool Foam::functionEntries::includeEntry::execute ( - dictionary& parentDict, + const dictionary& parentDict, + primitiveEntry& entry, Istream& is ) { @@ -122,7 +121,7 @@ bool Foam::functionEntries::includeEntry::insert if (fileStream) { - parentDict.read(fileStream); + entry.read(parentDict, fileStream); return true; } else @@ -130,7 +129,7 @@ bool Foam::functionEntries::includeEntry::insert FatalIOErrorIn ( "functionEntries::includeEntry::includeEntry" - "(dictionary& parentDict,Istream& is)", + "(dictionary& parentDict, primitiveEntry& entry, Istream& is)", is ) << "Cannot open include file " << fileStream.name() << " while reading dictionary " << parentDict.name() @@ -140,5 +139,4 @@ bool Foam::functionEntries::includeEntry::insert } } - // ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H index dfd6de82d70c729dc51081bd63703e5337cc3c51..00e04d60ca8a612b258c668b586e871a34c1d34c 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/includeEntry/includeEntry.H @@ -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 ( - const dictionary& parentDict, - primitiveEntry& entry, + dictionary& parentDict, Istream& is ); - static bool insert + //- Execute the functionEntry in a primitiveEntry context + static bool execute ( - dictionary& parentDict, + const dictionary& parentDict, + primitiveEntry& entry, Istream& is ); + }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C index 27b1e78f5eb9137e8497288a273dfe7c1482bcff..4360ee9ec2d2a4271fa55e2d55c4dc2b0037ca95 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.C @@ -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; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H index 10a3761655690bad6d5e25588454dc11dd761938..072465341d3633b1a5c520e05e85e8eff851f85b 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/inputModeEntry/inputModeEntry.H @@ -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(); }; diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C new file mode 100644 index 0000000000000000000000000000000000000000..f6b1becdca4b10b69272a4d73ade00b76c685fd5 --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.C @@ -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; +} + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H new file mode 100644 index 0000000000000000000000000000000000000000..06c409d299bab03307286666eaa726fc1a5c906b --- /dev/null +++ b/src/OpenFOAM/db/dictionary/functionEntries/removeEntry/removeEntry.H @@ -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 + +// ************************************************************************* // diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C index 8c5d0dd9c70a6b4ae9a05a55e48092d34e208f4e..511b53117b4a7120051edc428630c680ccce12d2 100644 --- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C +++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C @@ -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); }