160 using namespace Foam;
173 if (!dictFile().good())
176 <<
"Cannot open file " << dictFileName
183 dictFile.read(firstToken);
186 dictFile.putBack(firstToken);
201 firstEntry->dict().lookup(
"format")
207 IFstream dictFile(dictFileName, dictFormat);
223 && entryName.find(
'/') != string::npos
229 for (
label i = 1; i < entryNames.size(); i++)
259 remove(entPtr->
dict(), iter().
dict());
262 if (!entPtr->
dict().size())
268 else if (!iter().isDict())
270 if (*entPtr == iter())
292 dAk.second() +
' ' + namedArgs[i].second() +
';'
299 int main(
int argc,
char *argv[])
318 "Set entry value, add new entry or apply list of substitutions"
335 "Set, add or merge entry from a dictionary."
346 "Write differences with respect to the specified dictionary"
351 "List the #include/#includeIfPresent files to standard output"
356 "Read the specified dictionary file, expand the macros etc. and write "
357 "the resulting dictionary to standard output"
363 "Write with the specified precision"
410 const wordList dictPathComponents(dictPath.components());
412 if (dictPathComponents.size() == 1)
415 <<
"File name " << dictPath
416 <<
" does not contain an instance path needed in parallel"
420 const word instance = dictPathComponents[0];
423 SubList<word>(dictPathComponents, dictPathComponents.size() - 1, 1)
448 dictFormat = readDict(*dictPtr, dictPath);
453 bool changed =
false;
462 <<
"//\n// " << dictPath <<
"\n//\n";
475 dict.dictionary::write(
Info,
false);
488 readDict(diffDict, diffFileName);
494 const word scopedName(dotToSlash(entryName));
510 entry* ePtr =
nullptr;
514 const fileName fromDictFileName(newValue);
516 readDict(fromDict, fromDictFileName);
531 <<
"Cannot find entry " << entryName
532 <<
" in file " << fromDictFileName
536 ePtr = fePtr->
clone().ptr();
540 IStringStream str(
string(dAk.second()) +
' ' + newValue +
';');
546 Info <<
"New entry " << *ePtr <<
endl;
551 subDict.add(ePtr, merge);
561 subDict.remove(dAk.second());
575 subDict.lookupEntryPtr(dAk.second(),
false,
true);
577 subDict2.lookupEntryPtr(dAk.second(),
false,
true);
583 subDict.remove(dAk.second());
587 remove(ePtr->
dict(), e2Ptr->
dict());
620 if (i < tokens.size() - 1)
627 else if (entPtr->
isDict())
641 <<
"Cannot find entry " << entryName
649 substitute(
dict, substitutions);
661 remove(
dict, diffDict);
662 dict.dictionary::write(
Info,
false);
666 dict.dictionary::write(
Info,
false);
673 localDictPtr->regIOobject::write();
686 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.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
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.
wordList components(const char delimiter='/') const
Return path components as wordList.
static bool log
Report which file is included to stdout.
static bool dot()
Return true if the inputSyntax is dot.
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 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)