159 using namespace Foam;
172 if (!dictFile().good())
175 <<
"Cannot open file " << dictFileName
182 dictFile.read(firstToken);
185 dictFile.putBack(firstToken);
200 firstEntry->dict().lookup(
"format")
206 IFstream dictFile(dictFileName, dictFormat);
222 && entryName.find(
'/') != string::npos
228 for (
label i = 1; i < entryNames.size(); i++)
258 remove(entPtr->
dict(), iter().
dict());
261 if (!entPtr->
dict().size())
267 else if (!iter().isDict())
269 if (*entPtr == iter())
291 dAk.second() +
' ' + namedArgs[i].second() +
';'
298 int main(
int argc,
char *argv[])
317 "Set entry value, add new entry or apply list of substitutions"
334 "Set, add or merge entry from a dictionary."
345 "Write differences with respect to the specified dictionary"
350 "List the #include/#includeIfPresent files to standard output"
355 "Read the specified dictionary file, expand the macros etc. and write "
356 "the resulting dictionary to standard output"
362 "Write with the specified precision"
409 const wordList dictPathComponents(dictPath.components());
411 if (dictPathComponents.size() == 1)
414 <<
"File name " << dictPath
415 <<
" does not contain an instance path needed in parallel"
419 const word instance = dictPathComponents[0];
422 SubList<word>(dictPathComponents, dictPathComponents.size() - 1, 1)
447 dictFormat = readDict(*dictPtr, dictPath);
452 bool changed =
false;
461 <<
"//\n// " << dictPath <<
"\n//\n";
474 dict.dictionary::write(
Info,
false);
487 readDict(diffDict, diffFileName);
493 const word scopedName(dotToSlash(entryName));
509 entry* ePtr =
nullptr;
513 const fileName fromDictFileName(newValue);
515 readDict(fromDict, fromDictFileName);
530 <<
"Cannot find entry " << entryName
531 <<
" in file " << fromDictFileName
535 ePtr = fePtr->
clone().ptr();
539 IStringStream str(
string(dAk.second()) +
' ' + newValue +
';');
545 Info <<
"New entry " << *ePtr <<
endl;
550 subDict.add(ePtr, merge);
560 subDict.remove(dAk.second());
574 subDict.lookupEntryPtr(dAk.second(),
false,
true);
576 subDict2.lookupEntryPtr(dAk.second(),
false,
true);
582 subDict.remove(dAk.second());
586 remove(ePtr->
dict(), e2Ptr->
dict());
619 if (i < tokens.size() - 1)
626 else if (entPtr->
isDict())
640 <<
"Cannot find entry " << entryName
648 substitute(
dict, substitutions);
660 remove(
dict, diffDict);
661 dict.dictionary::write(
Info,
false);
665 dict.dictionary::write(
Info,
false);
672 localDictPtr->regIOobject::write();
685 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)