179 using namespace Foam;
189 const bool create =
false
198 if (!dictFile.good())
207 <<
"Cannot open file " << dictFileName
215 dictFile.read(firstToken);
218 dictFile.putBack(firstToken);
233 firstEntry->dict().lookup(
"format")
239 IFstream dictFile(dictFileName, dictFormat);
266 remove(entPtr->
dict(), iter().
dict());
269 if (!entPtr->
dict().size())
275 else if (!iter().isDict())
277 if (*entPtr == iter())
297 subDict.changeKeyword(dAk.second(),
word(namedArgs[i].
second()));
325 dAk.second() +
' ' + namedArgs[i].second() +
';'
332 int main(
int argc,
char *argv[])
351 "Rename entry or list of entries"
357 "Set entry value, add new entry or apply list of substitutions"
374 "Set, add or merge entry from a dictionary."
385 "Write differences with respect to the specified dictionary"
390 "List the #include/#includeIfPresent files to standard output"
395 "Read the specified dictionary file and expand the macros etc."
401 "Write with the specified precision"
406 "Create a new dictionary if the input dictionary does not exist."
412 "Path name of the output dictionary"
417 "Operate without outputting to the terminal or raising errors"
468 const wordList dictPathComponents(dictPath.components());
470 if (dictPathComponents.size() == 1)
473 <<
"File name " << dictPath
474 <<
" does not contain an instance path needed in parallel"
478 const word instance = dictPathComponents[0];
481 SubList<word>(dictPathComponents, dictPathComponents.size() - 1, 1)
510 dictPath.isAbsolute()
519 bool changed =
false;
530 <<
"//\n// " << dictPath <<
"\n//\n";
543 dict.dictionary::write(
Info,
false);
558 const word scopedName(entryName);
569 subDict.changeKeyword(dAk.second(),
word(newValue));
588 entry* ePtr =
nullptr;
592 const fileName fromDictFileName(newValue);
594 readDict(fromDict, fromDictFileName);
609 <<
"Cannot find entry " << entryName
610 <<
" in file " << fromDictFileName
614 ePtr = fePtr->
clone().ptr();
618 IStringStream str(
string(dAk.second()) +
' ' + newValue +
';');
624 Info <<
"New entry " << *ePtr <<
endl;
629 subDict.add(ePtr, merge);
639 subDict.remove(dAk.second());
647 readDict(diffDict, diffFileName);
655 subDict.lookupEntryPtr(dAk.second(),
false,
true);
657 subDict2.lookupEntryPtr(dAk.second(),
false,
true);
663 subDict.remove(dAk.second());
667 remove(ePtr->
dict(), e2Ptr->
dict());
699 if (i < tokens.size() - 1)
706 else if (entPtr->
isDict())
720 <<
"Cannot find entry " << entryName
728 rename(
dict, newNames);
734 substitute(
dict, substitutions);
743 readDict(fromDict, fromDictFileName);
748 substitute(fromDict, substitutions);
763 readDict(diffDict, diffFileName);
765 remove(
dict, diffDict);
766 dict.dictionary::write(
Info,
false);
770 dict.dictionary::write(
Info,
false);
777 localDictPtr->regIOobject::write();
789 outputDictPath.isAbsolute()
805 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 bool writeHeader(Ostream &os, const IOstream::versionNumber version, const IOstream::streamFormat format, const word &type, const string ¬e, const fileName &location, const word &name)
Write header.
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)