32 T Foam::dictionary::readType
35 const unitConversion& defaultUnits,
39 assertNoConvertUnits(pTraits<T>::typeName, keyword, defaultUnits, is);
41 return pTraits<T>(is);
46 T Foam::dictionary::readType(
const word& keyword, ITstream& is)
const
48 return pTraits<T>(is);
54 template<
class T,
class ... KeysAndTs>
59 const KeysAndTs& ... keysAndTs
64 set(
k, t, keysAndTs ...);
68 template<
class T,
class ... KeysAndTs>
74 const KeysAndTs& ... keysAndTs
80 set(
k, t, keysAndTs ...);
94 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
96 if (entryPtr ==
nullptr)
99 <<
"keyword " << keyword <<
" is undefined in dictionary "
103 return readType<T>(keyword, entryPtr->
stream());
116 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
118 if (entryPtr ==
nullptr)
121 <<
"keyword " << keyword <<
" is undefined in dictionary "
125 return readType<T>(keyword, defaultUnits, entryPtr->
stream());
137 const entry* entryPtr =
138 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
147 return lookup<T>(keywords[0], recursive, patternMatch);
161 const entry* entryPtr =
162 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
167 readType<T>(entryPtr->
keyword(), defaultUnits, entryPtr->
stream());
172 return lookup<T>(keywords[0], recursive, patternMatch);
186 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
190 return readType<T>(keyword, entryPtr->
stream());
194 if (writeOptionalEntries)
197 <<
"Optional entry '" << keyword <<
"' is not present,"
198 <<
" returning the default value '" << deflt <<
"'"
217 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
221 return readType<T>(keyword, defaultUnits, entryPtr->
stream());
225 if (writeOptionalEntries)
228 <<
"Optional entry '" << keyword <<
"' is not present,"
229 <<
" returning the default value '" << deflt <<
"'"
247 const entry* entryPtr =
248 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
257 return lookupOrDefault<T>(keywords[0], deflt, recursive, patternMatch);
272 const entry* entryPtr =
273 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
278 readType<T>(entryPtr->
keyword(), defaultUnits, entryPtr->
stream());
283 return lookupOrDefault<T>(keywords[0], deflt, recursive, patternMatch);
297 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
301 return readType<T>(keyword, entryPtr->
stream());
305 if (writeOptionalEntries)
308 <<
"Optional entry '" << keyword <<
"' is not present,"
309 <<
" adding and returning the default value '" << deflt <<
"'"
328 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
332 val = readType<T>(keyword, entryPtr->
stream());
337 if (writeOptionalEntries)
340 <<
"Optional entry '" << keyword <<
"' is not present,"
341 <<
" the default value '" << val <<
"' will be used."
360 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
364 val = readType<T>(keyword, defaultUnits, entryPtr->
stream());
369 if (writeOptionalEntries)
372 <<
"Optional entry '" << keyword <<
"' is not present,"
373 <<
" the default value '" << val <<
"' will be used."
390 const entry* entryPtr =
391 lookupScopedEntryPtr(keyword, recursive, patternMatch);
393 if (entryPtr ==
nullptr)
396 <<
"keyword " << keyword <<
" is undefined in dictionary "
412 const entry* entryPtr =
413 lookupScopedEntryPtr(keyword, recursive, patternMatch);
415 if (entryPtr ==
nullptr)
420 ) <<
"keyword " << keyword <<
" is undefined in dictionary "
427 return dynamicCast<const token::Compound<T>>(firstToken.
compoundToken());
445 template<
class T,
class ... KeysAndTs>
450 const KeysAndTs& ... keysAndTs
460 template<
class EntryType>
464 const word& entryName,
465 const EntryType& value
474 template<
class EntryType>
478 const word& entryName,
480 const EntryType& value
489 template<
class EntryType>
493 const word& entryName,
494 const EntryType& value1,
495 const EntryType& value2
498 if (value1 != value2)
505 template<
class EntryType>
509 const word& entryName,
511 const EntryType& value1,
512 const EntryType& value2
515 if (value1 != value2)
517 writeEntry(os, entryName, defaultUnits, value2);
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of keyword definitions, which are a keyword followed by any number of values (e....
T lookupOrDefaultBackwardsCompatible(const wordList &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, trying a list of keywords in sequence,.
dictionary()
Construct top-level dictionary null.
T lookupOrDefault(const word &, const T &, bool recursive=false, bool patternMatch=true) const
Find and return a T, if not found return the given default.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
void set(entry *)
Assign a new entry, overwrite any existing entry.
T lookupOrAddDefault(const word &, const T &, bool recursive=false, bool patternMatch=true)
Find and return a T, if not found return the given.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
const T & lookupCompoundScoped(const word &keyword, bool recursive, bool patternMatch) const
Find return the reference to the compound T,.
T lookupScoped(const word &, bool recursive=false, bool patternMatch=true) const
Find and return a T,.
A keyword and a list of tokens is an 'entry'.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
const keyType & keyword() const
Return keyword.
A class for handling file names.
A class for handling keywords in dictionaries.
Traits class for primitives.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
A token holds items read from Istream.
const compound & compoundToken() const
Unit conversion structure. Contains the associated dimensions and the multiplier with which to conver...
A class for handling words, derived from string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
#define IOInfoInFunction(ios)
Report an IO information message using Foam::Info.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void writeEntryIfDifferent(Ostream &os, const word &entryName, const EntryType &value1, const EntryType &value2)
Helper function to write the keyword and entry only if the.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)