120 using namespace Foam;
127 if (entryName.find(
':') != string::npos)
132 for (
label i = 1; i < entryNames.size(); i++)
149 if (i != string::npos)
153 scopedName.substr(0, i),
154 scopedName.substr(i+1, string::npos)
167 const word& subDictName
170 if (subDictName ==
"")
182 if (!entPtr || !entPtr->
isDict())
185 <<
"keyword " << subDictName
186 <<
" is undefined in dictionary " 187 << dict.
name() <<
" or is not a dictionary" 189 <<
"Valid keywords are " << dict.
keys()
192 return entPtr->
dict();
201 const entry* entPtr = dict.lookupEntryPtr
221 if (!entPtr->
dict().size())
223 dict.remove(iter().keyword());
227 else if (!iter().isDict())
229 if (*entPtr == iter())
231 dict.remove(iter().keyword());
239 int main(
int argc,
char *argv[])
258 "Set entry value or add new entry" 275 "Write differences with respect to the specified dictionary" 280 "List the #include/#includeIfPresent files to standard output" 285 "Read the specified dictionary file, expand the macros etc. and write " 286 "the resulting dictionary to standard output" 290 "disableFunctionEntries",
291 "Disable expansion of dictionary directives - #include, #codeStream etc" 312 if (!dictFile().good())
315 <<
"Cannot open file " << dictFileName
320 bool changed =
false;
324 dict.
read(dictFile(),
true);
333 <<
"//\n// " << dictFileName <<
"\n//\n";
347 if (!diffFile().good())
350 <<
"Cannot open file " << diffFileName
355 diffDict.
read(diffFile(),
true);
362 word scopedName(scope(entryName));
375 IStringStream str(
string(dAk.second()) +
' ' + newValue +
';');
407 const_cast<dictionary&
>(d).
remove(dAk.second());
421 d.lookupEntryPtr(dAk.second(),
false,
true);
423 d2.lookupEntryPtr(dAk.second(),
false,
true);
429 const_cast<dictionary&
>(d).
remove(dAk.second());
470 if (i < tokens.size() - 1)
477 else if (entPtr->
isDict())
491 <<
"Cannot find entry " << entryName
505 remove(
dict, diffDict);
518 dict.
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 read(Istream &)
Read dictionary from Istream.
#define forAll(list, i)
Loop across all elements in 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.
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.
static Stream & writeDivider(Stream &os)
Write the standard file section divider.
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
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 optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
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.
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.
graph_traits< Graph >::vertices_size_type size_type
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
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)
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
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)
A keyword and a list of tokens is an 'entry'.