96 if (entryName.find(
':') != string::npos)
101 for (
label i = 1; i < entryNames.size(); i++)
115 word keyword(
const word& scopedName)
117 word key(scopedName);
119 if (i != string::npos)
121 key = scopedName.substr(i+1, string::npos);
131 const bool overwrite,
135 if (keyword[0] ==
':')
140 const_cast<dictionary&>(dict.
topDict()),
141 keyword.substr(1, keyword.size()-1),
151 if (dotPos == string::npos)
173 string::const_iterator iter =
174 keyword.begin() + begVar;
178 iter != keyword.end()
189 <<
"No parent of current dictionary" 190 <<
" when searching for " 194 keyword.size() - begVar
198 dictPtr = &dictPtr->
parent();
203 const_cast<dictionary&>(*dictPtr),
204 keyword.substr(endVar),
213 word firstWord = keyword.substr(0, dotPos);
222 if (!entPtr || !entPtr->
isDict())
225 <<
"keyword " << firstWord
226 <<
" is undefined in dictionary " 227 << dict.
name() <<
" or is not a dictionary" 229 <<
"Valid keywords are " << dict.
keys()
237 const_cast<dictionary&>(firstDict),
238 keyword.substr(dotPos, keyword.size()-dotPos),
249 int main(
int argc,
char *argv[])
266 "set entry value or add new entry" 277 "List the #include/#includeIfPresent files to standard output." 282 "Read the specified dictionary file, expand the macros etc. and write " 283 "the resulting dictionary to standard output." 299 if (dictFile().good())
301 bool changed =
false;
305 dict.
read(dictFile(),
true);
314 <<
"//\n// " << dictFileName <<
"\n//\n";
324 word scopedName(scope(entryName));
335 word key(keyword(scopedName));
338 setScoped(dict, scopedName, overwrite,
entry::New(str).ptr());
385 else if (entPtr->
isDict())
399 <<
"Cannot find entry " << entryName
421 dict.
write(os,
false);
428 <<
"Cannot open file " << dictFileName
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)
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
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.
bool optionReadIfPresent(const word &opt, T &) const
Read a value from the named option if present.
static const dictionary null
Null dictionary.
static bool New(dictionary &parentDict, Istream &)
Construct from Istream and insert into dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
static SLList< string > validArgs
A list of valid (mandatory) arguments.
const fileName & name() const
Return the dictionary name.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
bool optionFound(const word &opt) const
Return true if the named option is found.
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
A class for handling words, derived from string.
Extract command arguments and options from the supplied argc and argv parameters. ...
wordList components(const char delimiter='/') const
Return path components as wordList.
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)
static Stream & writeEndDivider(Stream &os)
Write the standard end file divider.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Input from memory buffer stream.
void set(entry *)
Assign a new entry, overwrite any existing entry.
static void noBanner()
Disable emitting the banner information.
const dictionary & parent() const
Return the parent dictionary.
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.
static bool log
Report which file is included to stdout.
void clear()
Clear the dictionary.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
Foam::argList args(argc, argv)
const dictionary & topDict() const
Return the top of the tree.
virtual bool isStream() const
Return true if this entry is a stream.
virtual bool isDict() const
Return true if this entry is a dictionary.
A keyword and a list of tokens is an 'entry'.