104 const word& patchName = iter().keyword();
116 if (fndGroup == groupToPatch.
end())
122 fndGroup().append(patchName);
145 const entry& mergeEntry,
146 const bool literalRE,
150 bool changed =
false;
160 const_cast<dictionary&>(thisEntry.
dict()),
173 thisDict.
add(mergeEntry.
clone(thisDict).ptr(),
true);
199 else if (shortcuts.
size())
205 const word&
name = shortcutNames[indices[i]];
230 const bool literalRE,
236 bool changed =
false;
244 thisKeysSet.
insert(keys[i]);
252 const keyType& key = mergeIter().keyword();
256 word eraseKey = key(1, key.size()-1);
257 if (thisDict.
remove(eraseKey))
261 thisKeysSet.
erase(eraseKey);
298 thisDict.
add(mergeIter().
clone(thisDict).ptr());
307 if (!literalRE && thisKeysSet.
size() > 0)
314 const keyType& key = mergeIter().keyword();
318 word eraseKey = key(1, key.size()-1);
335 const word& thisKey = thisKeys[matches[i]];
336 thisKeysSet.
erase(thisKey);
357 const word& thisKey = thisKeys[matches[i]];
389 int main(
int argc,
char *argv[])
396 "specify the subDict name of the replacements dictionary" 402 "override instance setting (default is the time name)" 411 "treat regular expressions literally (i.e., as a keyword)" 415 "enableFunctionEntries",
416 "enable expansion of dictionary directives - #include, #codeStream etc" 420 "disablePatchGroups",
421 "disable matching keys to patch groups" 430 <<
"changeDictionary has been superseded by foamDictionary" 431 " and is now deprecated." 438 if (times.
size() < 1)
448 if (times.
size() > 1)
451 <<
"Multiple times selected with 'instance' option" 468 Info<<
"Not interpreting any regular expressions (RE)" 469 <<
" in the changeDictionaryDict." << endl
470 <<
"Instead they are handled as any other entry, i.e. added if" 471 <<
" not present." <<
endl;
477 Info<<
"Allowing dictionary preprocessing " 478 "('#include', '#codeStream')." 490 const bool disablePatchGroups =
args.
optionFound(
"disablePatchGroups");
491 if (disablePatchGroups)
493 Info<<
"Not interpreting any keys in the changeDictionary" 522 const dictionary& replaceDicts = *replaceDictsPtr;
525 <<
" with replacements for dictionaries " 533 Info<<
"Reading polyMesh/boundary file to extract patch names" 560 const_cast<word&
>(dictList.type()) = dictList.headerClassName();
566 fieldDict.
add(dictList[i].keyword(), dictList[i].
dict());
571 Info<<
"Loaded dictionary " << dictList.name()
572 <<
" with entries " << fieldDict.
toc() <<
endl;
578 if (!disablePatchGroups)
580 patchGroups = extractPatchGroups(fieldDict);
581 if (patchGroups.
size())
583 Info<<
"Extracted patch groups:" <<
endl;
587 Info<<
" group " << groups[i] <<
" with patches " 588 << patchGroups[groups[i]] <<
endl;
598 const word& fieldName = fieldIter().keyword();
599 Info<<
"Replacing entries in dictionary " << fieldName <<
endl;
604 if (fieldName ==
"boundary")
606 Info<<
"Special handling of " << fieldName
607 <<
" as polyMesh/boundary file." <<
endl;
610 const dictionary& replaceDict = fieldIter().dict();
611 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
614 merge(fieldDict, replaceDict, literalRE, patchGroups);
616 Info<<
"fieldDict:" << fieldDict <<
endl;
621 label nEntries = fieldDict.size();
625 doneKeys[i] = dictList[i].keyword();
636 fieldDict.
remove(doneKeys[i]);
640 label sz = dictList.size();
641 dictList.setSize(nEntries);
644 dictList.set(sz++, iter().
clone());
647 Info<<
"Writing modified " << fieldName <<
endl;
660 Info<<
"Loading dictionary " << fieldName <<
endl;
661 const word oldTypeName = IOdictionary::typeName;
677 const_cast<word&
>(IOdictionary::typeName) = oldTypeName;
680 const_cast<word&
>(fieldDict.type()) =
681 fieldDict.headerClassName();
683 Info<<
"Loaded dictionary " << fieldName
684 <<
" with entries " << fieldDict.
toc() <<
endl;
687 const dictionary& replaceDict = fieldIter().dict();
688 Info<<
"Merging entries from " << replaceDict.
toc() <<
endl;
691 merge(fieldDict, replaceDict, literalRE, patchGroups);
693 Info<<
"Writing modified fieldDict " << fieldName <<
endl;
694 fieldDict.regIOobject::write();
Template class for intrusive linked lists.
A class for handling keywords in dictionaries.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
A HashTable with keys but without contents.
#define forAll(list, i)
Loop across all elements in list.
bool remove(const word &)
Remove an entry specified by keyword.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
const keyType & keyword() const
Return keyword.
errorManipArg< error, int > exit(error &err, const int errNo=1)
static iteratorEnd end()
iteratorEnd set to beyond the end of any HashTable
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
static word meshSubDir
Return the mesh sub-directory name (usually "polyMesh")
void size(const label)
Override size to be inconsistent with allocated storage.
static word defaultRegion
Return the default region name.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
word findInstance(const fileName &dir, const word &name=word::null, const IOobject::readOption rOpt=IOobject::MUST_READ, const word &stopInstance=word::null) const
Return the location of "dir" containing the file "name".
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
static word timeName(const scalar, const int precision=precision_)
Return time name of given scalar time.
Operations on lists of strings.
bool insert(const Key &key)
Insert a new entry.
IOdictionary systemDict(const word &dictName, const argList &args, const objectRegistry &ob, const word ®ionName=polyMesh::defaultRegion)
label size() const
Return number of elements in table.
wordList toc() const
Return the table of contents.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
bool erase(const iterator &)
Erase a hashedEntry specified by given iterator.
IOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO functionalit...
bool findStrings(const wordReListMatcher &matcher, const std::string &str)
Return true if string matches one of the regular expressions.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool insert(const Key &, const T &newElmt)
Insert a new hashedEntry.
iterator find(const Key &)
Find and return an iterator set at the hashedEntry.
An STL-conforming iterator.
static int disableFunctionEntries
const fileName & name() const
Return the dictionary name.
bool found(const Key &) const
Return true if hashedEntry is found in table.
A class for handling words, derived from string.
void append(const T &)
Append an element at the end of the list.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
static const word null
An empty word.
static instantList selectIfPresent(Time &runTime, const argList &args)
If any time option provided return the set of times (as select0)
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
An STL-conforming hash table.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
defineTemplateTypeNameAndDebug(IOPtrList< ensightPart >, 0)
virtual bool isDict() const
Return true if this entry is a dictionary.
IOstream::streamFormat writeFormat() const
Default write format.
static fileCheckTypes fileModificationChecking
Type of file modification checking.
label findIndex(const ListType &, typename ListType::const_reference, const label start=0)
Find first occurrence of given element and return index,.
word name(const complex &)
Return a string representation of a complex.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
List< word > wordList
A List of words.
A PtrList of objects of type <T> with automated input and output.
List< Key > sortedToc() const
Return the table of contents as a sorted list.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
List< Key > toc() const
Return the table of contents.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static void addOptions(const bool constant=true, const bool withZero=false)
Add the options handled by timeSelector to argList::validOptions.
A keyword and a list of tokens is an 'entry'.
bool isPattern() const
Should be treated as a match rather than a literal string.
IStringStream optionLookup(const word &opt) const
Return an IStringStream from the named option.