31 template<
class ... Entries>
34 const Entries& ... entries
37 return std::tuple<
const Entries& ...>(
entries ...);
44 T Foam::dictionary::readType
58 T Foam::dictionary::readType(
const word& keyword, ITstream& is)
const
60 return pTraits<T>(is);
64 template<
class ... Entries,
size_t ... Indices>
65 void Foam::dictionary::set
67 const std::tuple<const Entries& ...>& entries,
68 const std::integer_sequence<size_t, Indices ...>&
71 set(std::get<Indices>(entries) ...);
75 template<
class ... Entries>
76 void Foam::dictionary::set
78 const std::tuple<const Entries& ...>& entries
81 set(entries, std::make_integer_sequence<
size_t,
sizeof ... (Entries)>());
87 template<
class ... Entries>
96 template<
class ... Entries>
100 const std::tuple<const Entries& ...>& entries
109 template<
class ... Entries>
114 const std::tuple<const Entries& ...>& entries
123 template<
class ... Entries>
127 const std::tuple<const Entries& ...>& entries
146 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
148 if (entryPtr ==
nullptr)
151 <<
"keyword " << keyword <<
" is undefined in dictionary "
155 return readType<T>(keyword, entryPtr->
stream());
168 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
170 if (entryPtr ==
nullptr)
173 <<
"keyword " << keyword <<
" is undefined in dictionary "
177 return readType<T>(keyword, defaultUnits, entryPtr->
stream());
189 const entry* entryPtr =
190 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
199 return lookup<T>(keywords[0], recursive, patternMatch);
213 const entry* entryPtr =
214 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
219 readType<T>(entryPtr->
keyword(), defaultUnits, entryPtr->
stream());
224 return lookup<T>(keywords[0], recursive, patternMatch);
233 const T& defaultValue,
234 const bool writeDefault
237 const entry* entryPtr = lookupEntryPtr(keyword,
false,
false);
241 return readType<T>(keyword, entryPtr->
stream());
248 <<
" " << defaultValue
249 <<
" in " <<
name().relativePath() <<
endl;
262 const T& defaultValue,
263 const bool writeDefault
266 const entry* entryPtr = lookupEntryPtr(keyword,
false,
false);
270 return readType<T>(keyword, defaultUnits, entryPtr->
stream());
277 <<
" " << defaultValue
278 <<
" in " <<
name().relativePath() <<
endl;
290 const T& defaultValue
293 const entry* entryPtr =
294 lookupEntryPtrBackwardsCompatible(keywords,
false,
false);
303 return lookupOrDefault<T>(keywords[0], defaultValue);
313 const T& defaultValue
316 const entry* entryPtr =
317 lookupEntryPtrBackwardsCompatible(keywords,
false,
false);
322 readType<T>(entryPtr->
keyword(), defaultUnits, entryPtr->
stream());
327 return lookupOrDefault<T>(keywords[0], defaultValue);
336 const T& defaultValue
339 const entry* entryPtr = lookupEntryPtr(keyword,
false,
false);
343 return readType<T>(keyword, entryPtr->
stream());
347 if (writeOptionalEntries > 1)
350 <<
" " << defaultValue
351 <<
" to " <<
name().relativePath() <<
endl;
369 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
373 val = readType<T>(keyword, entryPtr->
stream());
378 if (writeOptionalEntries > 1)
382 <<
" in " <<
name().relativePath() <<
endl;
400 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
404 val = readType<T>(keyword, defaultUnits, entryPtr->
stream());
409 if (writeOptionalEntries > 1)
413 <<
" in " <<
name().relativePath() <<
endl;
429 const entry* entryPtr =
430 lookupScopedEntryPtr(keyword, recursive, patternMatch);
432 if (entryPtr ==
nullptr)
435 <<
"keyword " << keyword <<
" is undefined in dictionary "
451 const entry* entryPtr =
452 lookupScopedEntryPtr(keyword, recursive, patternMatch);
454 if (entryPtr ==
nullptr)
459 ) <<
"keyword " << keyword <<
" is undefined in dictionary "
466 return dynamicCast<const token::Compound<T>>(firstToken.
compoundToken());
478 void Foam::dictionary::set(
const keyType&
k,
const T& t)
484 template<
class ... Entries>
485 void Foam::dictionary::set(
const entry&
e,
const Entries& ... entries)
492 template<
class T,
class ... Entries>
493 void Foam::dictionary::set
497 const Entries& ... entries
507 template<
class EntryType>
511 const word& entryName,
512 const EntryType& value
521 template<
class EntryType>
525 const word& entryName,
527 const EntryType& value
536 template<
class EntryType>
540 const word& entryName,
541 const EntryType& value1,
542 const EntryType& value2
545 if (value1 != value2)
552 template<
class EntryType>
556 const word& entryName,
558 const EntryType& value1,
559 const EntryType& value2
562 if (value1 != value2)
564 writeEntry(os, entryName, defaultUnits, value2);
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
dictionary()
Construct top-level dictionary null.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
T lookupOrAddDefault(const word &, const T &)
Find and return a T, if not found return the given.
T lookupOrDefaultBackwardsCompatible(const wordList &, const T &) const
Find and return a T, trying a list of keywords in sequence,.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
T lookupOrDefault(const word &, const T &, const bool writeDefault=writeOptionalEntries > 0) const
Find and return a T, if not found return the given default.
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,.
static std::tuple< const Entries &... > entries(const Entries &...)
Construct an entries tuple from which to make a dictionary.
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.
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.
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
void add(LagrangianPatchField< typename typeOfSum< Type1, Type2 >::type > &f, const LagrangianPatchField< Type1 > &f1, const LagrangianPatchField< Type2 > &f2)
void assertNoConvertUnits(const word &typeName, const Function1s::unitConversions &units, const dictionary &dict)
Generate an error in an context where unit conversions are not supported.
Ostream & indent(Ostream &os)
Indent stream.