148 using namespace Foam;
161 if (!dictFile().good())
164 <<
"Cannot open file " << dictFileName
171 dictFile.read(firstToken);
174 dictFile.putBack(firstToken);
189 firstEntry->dict().lookup(
"format")
195 IFstream dictFile(dictFileName, dictFormat);
199 dict.
read(dictFile(),
true);
211 && entryName.find(
'/') != string::npos
217 for (
label i = 1; i < entryNames.size(); i++)
238 if (i != string::npos)
242 scopedName.substr(0, i),
243 scopedName.substr(i+1, string::npos)
256 const word& subDictName
259 if (subDictName ==
"")
271 if (!entPtr || !entPtr->
isDict())
274 <<
"keyword " << subDictName
275 <<
" is undefined in dictionary " 276 << dict.
name() <<
" or is not a dictionary" 278 <<
"Valid keywords are " << dict.
keys()
281 return entPtr->
dict();
290 const entry* entPtr = dict.lookupEntryPtr
310 if (!entPtr->
dict().size())
312 dict.remove(iter().keyword());
316 else if (!iter().isDict())
318 if (*entPtr == iter())
320 dict.remove(iter().keyword());
328 int main(
int argc,
char *argv[])
348 "Set entry value or add new entry" 365 "Set, add or merge entry from a dictionary." 376 "Write differences with respect to the specified dictionary" 381 "List the #include/#includeIfPresent files to standard output" 386 "Read the specified dictionary file, expand the macros etc. and write " 387 "the resulting dictionary to standard output" 408 Time* runTimePtr =
nullptr;
427 if (dictPathComponents.size() == 1)
431 <<
" does not contain an instance path needed in parallel" 435 const word instance = dictPathComponents[0];
438 SubList<word>(dictPathComponents, dictPathComponents.size() - 1, 1)
463 dictFormat = readDict(*dictPtr,
dictPath);
466 dictionary& dict = localDictPtr ? *localDictPtr : *dictPtr;
468 bool changed =
false;
477 <<
"//\n// " <<
dictPath <<
"\n//\n";
478 dict.dictionary::write(
Info,
false);
491 readDict(diffDict, diffFileName);
498 const word scopedName(scope(entryName));
514 entry* ePtr =
nullptr;
518 const fileName fromDictFileName(newValue);
520 readDict(fromDict, fromDictFileName);
535 <<
"Cannot find entry " << entryName
536 <<
" in file " << fromDictFileName
540 ePtr = fePtr->
clone().ptr();
544 IStringStream str(
string(dAk.second()) +
' ' + newValue +
';');
550 Info <<
"New entry " << *ePtr <<
endl;
577 const_cast<dictionary&
>(d).
remove(dAk.second());
591 d.lookupEntryPtr(dAk.second(),
false,
true);
593 d2.lookupEntryPtr(dAk.second(),
false,
true);
599 const_cast<dictionary&
>(d).
remove(dAk.second());
640 if (i < tokens.size() - 1)
647 else if (entPtr->
isDict())
661 <<
"Cannot find entry " << entryName
675 remove(
dict, diffDict);
676 dict.dictionary::write(
Info,
false);
680 dict.dictionary::write(
Info,
false);
687 localDictPtr->regIOobject::write();
693 if (dictPtr->
found(IOobject::foamFile))
697 dictPtr->
remove(IOobject::foamFile);
700 dictPtr->
write(os,
false);
virtual bool isStream() const
Return true if this entry is a stream.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
bool checkRootCase() const
Check root path and case path.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
#define forAll(list, i)
Loop across all elements in list.
static streamFormat formatEnum(const word &)
Return stream format of given format name.
bool remove(const word &)
Remove an entry specified by keyword.
static void removeOption(const word &opt)
Remove option from validOptions and from optionUsage.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
static Stream & writeBanner(Stream &os, bool noHint=false)
Write the standard OpenFOAM file/dictionary banner.
errorManipArg< error, int > exit(error &err, const int errNo=1)
A list of keyword definitions, which are a keyword followed by any number of values (e...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const word & wordToken() const
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
A token holds items read from Istream.
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
static bool dot()
Return true if the inputSyntax is dot.
Ostream & endl(Ostream &os)
Add newline and flush stream.
bool optionFound(const word &opt) const
Return true if the named option is found.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
bool read(Istream &, const bool keepHeader=false)
Read dictionary from Istream, optionally keeping the header.
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
void exit(const int errNo=1)
Exit : can be called for any error to exit program.
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
wordList components(const char delimiter='/') const
Return path components as wordList.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
localIOdictionary is derived from IOdictionary but excludes parallel master reading.
Info<< "Create engine time\"<< endl;autoPtr< engineTime > runTimePtr(engineTime::New(Time::controlDictName, args.rootPath(), args.caseName()))
A List obtained as a section of another List.
static int disableFunctionEntries
const fileName & name() const
Return the dictionary name.
A class for handling words, derived from string.
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.
streamFormat
Enumeration for the format of data in the stream.
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
bool readScalar(const char *buf, doubleScalar &s)
Read whole of buf as a scalar. Return true if successful.
static word controlDictName
The default control dictionary name (normally "controlDict")
graph_traits< Graph >::vertices_size_type size_type
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
static char scopeChar()
Return true if the inputSyntax is slash.
virtual bool isDict() const
Return true if this entry is a dictionary.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
static constexpr const char * foamFile
Keyword for the FoamFile header sub-dictionary.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
static bool & parRun()
Is this a parallel run?
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Input from memory buffer stream.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
static void addBoolOption(const word &opt, const string &usage="")
Add to a bool option to validOptions with usage information.
static void addNote(const string &)
Add extra notes for the usage information.
T * first()
Return the first entry.
static bool log
Report which file is included to stdout.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
Foam::argList args(argc, argv)
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
A keyword and a list of tokens is an 'entry'.