171 using namespace Foam;
184 if (!dictFile().good())
187 <<
"Cannot open file " << dictFileName
194 dictFile.read(firstToken);
197 dictFile.putBack(firstToken);
212 firstEntry->dict().lookup(
"format")
218 IFstream dictFile(dictFileName, dictFormat);
245 remove(entPtr->
dict(), iter().
dict());
248 if (!entPtr->
dict().size())
254 else if (!iter().isDict())
256 if (*entPtr == iter())
276 subDict.changeKeyword(dAk.second(),
word(namedArgs[i].
second()));
293 dAk.second() +
' ' + namedArgs[i].second() +
';'
300 int main(
int argc,
char *argv[])
319 "Rename entry or list of entries"
325 "Set entry value, add new entry or apply list of substitutions"
342 "Set, add or merge entry from a dictionary."
353 "Write differences with respect to the specified dictionary"
358 "List the #include/#includeIfPresent files to standard output"
363 "Read the specified dictionary file and expand the macros etc."
369 "Write with the specified precision"
375 "Path name of the output dictionary"
422 const wordList dictPathComponents(dictPath.components());
424 if (dictPathComponents.size() == 1)
427 <<
"File name " << dictPath
428 <<
" does not contain an instance path needed in parallel"
432 const word instance = dictPathComponents[0];
435 SubList<word>(dictPathComponents, dictPathComponents.size() - 1, 1)
460 dictFormat = readDict(*dictPtr,
args.
path()/dictPath);
465 bool changed =
false;
476 <<
"//\n// " << dictPath <<
"\n//\n";
489 dict.dictionary::write(
Info,
false);
507 readDict(diffDict, diffFileName);
513 const word scopedName(entryName);
524 subDict.changeKeyword(dAk.second(),
word(newValue));
543 entry* ePtr =
nullptr;
547 const fileName fromDictFileName(newValue);
549 readDict(fromDict, fromDictFileName);
564 <<
"Cannot find entry " << entryName
565 <<
" in file " << fromDictFileName
569 ePtr = fePtr->
clone().ptr();
573 IStringStream str(
string(dAk.second()) +
' ' + newValue +
';');
579 Info <<
"New entry " << *ePtr <<
endl;
584 subDict.add(ePtr, merge);
594 subDict.remove(dAk.second());
608 subDict.lookupEntryPtr(dAk.second(),
false,
true);
610 subDict2.lookupEntryPtr(dAk.second(),
false,
true);
616 subDict.remove(dAk.second());
620 remove(ePtr->
dict(), e2Ptr->
dict());
653 if (i < tokens.size() - 1)
660 else if (entPtr->
isDict())
674 <<
"Cannot find entry " << entryName
682 rename(
dict, newNames);
688 substitute(
dict, substitutions);
700 remove(
dict, diffDict);
701 dict.dictionary::write(
Info,
false);
705 dict.dictionary::write(
Info,
false);
712 localDictPtr->regIOobject::write();
731 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.
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 keyword definitions, which are a keyword followed by any number of values (e....
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[])
errorManipArg< error, int > exit(error &err, const int errNo=1)
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.
void dictArgList(const string &argString, word &configName, wordReList &args, List< Tuple2< word, string >> &namedArgs)
Parse dictionary substitution argument list.
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")
prefixOSstream Sout(cout, "Sout")
Foam::argList args(argc, argv)