176 using namespace Foam;
189 if (!dictFile().good())
192 <<
"Cannot open file " << dictFileName
199 dictFile.read(firstToken);
202 dictFile.putBack(firstToken);
217 firstEntry->dict().lookup(
"format")
223 IFstream dictFile(dictFileName, dictFormat);
250 remove(entPtr->
dict(), iter().
dict());
253 if (!entPtr->
dict().size())
259 else if (!iter().isDict())
261 if (*entPtr == iter())
281 subDict.changeKeyword(dAk.second(),
word(namedArgs[i].
second()));
309 dAk.second() +
' ' + namedArgs[i].second() +
';'
316 int main(
int argc,
char *argv[])
335 "Rename entry or list of entries"
341 "Set entry value, add new entry or apply list of substitutions"
358 "Set, add or merge entry from a dictionary."
369 "Write differences with respect to the specified dictionary"
374 "List the #include/#includeIfPresent files to standard output"
379 "Read the specified dictionary file and expand the macros etc."
385 "Write with the specified precision"
391 "Path name of the output dictionary"
396 "Operate without outputting to the terminal or raising errors"
447 const wordList dictPathComponents(dictPath.components());
449 if (dictPathComponents.size() == 1)
452 <<
"File name " << dictPath
453 <<
" does not contain an instance path needed in parallel"
457 const word instance = dictPathComponents[0];
460 SubList<word>(dictPathComponents, dictPathComponents.size() - 1, 1)
489 dictPath.isAbsolute()
497 bool changed =
false;
508 <<
"//\n// " << dictPath <<
"\n//\n";
521 dict.dictionary::write(
Info,
false);
536 const word scopedName(entryName);
547 subDict.changeKeyword(dAk.second(),
word(newValue));
566 entry* ePtr =
nullptr;
570 const fileName fromDictFileName(newValue);
572 readDict(fromDict, fromDictFileName);
587 <<
"Cannot find entry " << entryName
588 <<
" in file " << fromDictFileName
592 ePtr = fePtr->
clone().ptr();
596 IStringStream str(
string(dAk.second()) +
' ' + newValue +
';');
602 Info <<
"New entry " << *ePtr <<
endl;
607 subDict.add(ePtr, merge);
617 subDict.remove(dAk.second());
625 readDict(diffDict, diffFileName);
633 subDict.lookupEntryPtr(dAk.second(),
false,
true);
635 subDict2.lookupEntryPtr(dAk.second(),
false,
true);
641 subDict.remove(dAk.second());
645 remove(ePtr->
dict(), e2Ptr->
dict());
677 if (i < tokens.size() - 1)
684 else if (entPtr->
isDict())
698 <<
"Cannot find entry " << entryName
706 rename(
dict, newNames);
712 substitute(
dict, substitutions);
721 readDict(fromDict, fromDictFileName);
726 substitute(fromDict, substitutions);
741 readDict(diffDict, diffFileName);
743 remove(
dict, diffDict);
744 dict.dictionary::write(
Info,
false);
748 dict.dictionary::write(
Info,
false);
755 localDictPtr->regIOobject::write();
767 outputDictPath.isAbsolute()
780 dictPtr->
write(os,
false);
#define forAll(list, i)
Loop across all elements in list.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
static Stream & writeBanner(Stream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
static constexpr const char * foamFile
Keyword for the FoamFile header sub-dictionary.
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
streamFormat
Enumeration for the format of data in the stream.
static unsigned int defaultPrecision()
Return the default precision.
static streamFormat formatEnum(const word &)
Return stream format of given format name.
Input from memory buffer stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
virtual int precision() const
Get precision of output field.
A List obtained as a section of another List.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
static word controlDictName
The default control dictionary name (normally "controlDict")
static bool & parRun()
Is this a parallel run?
Extract command arguments and options from the supplied argc and argv parameters.
static void addOption(const word &opt, const string ¶m="", const string &usage="")
Add to an option to validOptions with usage information.
static void addNote(const string &)
Add extra notes for the usage information.
T optionRead(const word &opt) const
Read a value from the named option.
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
bool optionFound(const word &opt) const
Return true if the named option is found.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
bool checkRootCase() const
Check root path and case path.
fileName path() const
Return the path to the caseName.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
T optionLookupOrDefault(const word &opt, const T &deflt) const
Read a value from the named option if present.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
bool read(Istream &, const bool keepHeader=false)
Read dictionary from Istream, optionally keeping the header.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present,.
bool remove(const word &)
Remove an entry specified by keyword.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
const dictionary & scopedDict(const word &) const
Find and return a sub-dictionary by scoped lookup.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const
Return true if this entry is a dictionary.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
virtual bool isStream() const
Return true if this entry is a stream.
static int disableFunctionEntries
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
A class for handling file names.
static bool log
Report which file is included to stdout.
localIOdictionary derived from IOdictionary with global set false to disable parallel master reading.
A token holds items read from Istream.
const word & wordToken() const
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
int main(int argc, char *argv[])
Function with which to merge one dictionary into another. Intended for user-facing dictionary merging...
errorManipArg< error, int > exit(error &err, const int errNo=1)
void dictArgList(const Tuple2< string, label > &argString, word &configName, List< Tuple2< wordRe, label >> &args, List< Tuple3< word, string, label >> &namedArgs)
Parse dictionary substitution argument list.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
labelList second(const UList< labelPair > &p)
labelList first(const UList< labelPair > &p)
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
prefixOSstream Pout(cout, "Pout")
bool mergeDictionaries(dictionary &tgtDict, const dictionary &srcDict, const bool wildcards=true, const HashTable< wordList, word > &shortcuts=HashTable< wordList, word >(0))
prefixOSstream Sout(cout, "Sout")
Foam::argList args(argc, argv)