35void Foam::dictionary::reportDefault
45 <<
"No optional entry: " << keyword
46 <<
" Default: " << deflt <<
nl
53 os <<
"-- Executable: "
54 << dictionary::executableName()
72 os <<
" Default: " << deflt;
84template<
class Compare>
87 return hashedEntries_.sortedToc(comp);
118template<
class T,
class Predicate>
122 const Predicate& pred,
136 std::initializer_list<std::pair<const char*,int>> compat,
154 const entry* eptr = csearch(keyword, matchOpt).ptr();
163 checkITstream(is, keyword);
167 else if (writeOptionalEntries)
169 reportDefault(keyword, deflt);
184 const entry* eptr = csearch(keyword, matchOpt).ptr();
190 ITstream& is = eptr->stream();
193 checkITstream(is, keyword);
197 else if (writeOptionalEntries)
199 reportDefault(keyword, deflt,
true);
207template<
class T,
class Predicate>
212 const Predicate& pred,
220 <<
"Entry '" << keyword <<
"' with invalid default in dictionary "
226 const entry* eptr = csearch(keyword, matchOpt).ptr();
232 ITstream& is = eptr->stream();
235 checkITstream(is, keyword);
239 raiseBadInput(is, keyword);
244 else if (writeOptionalEntries)
246 reportDefault(keyword, deflt);
253template<
class T,
class Predicate>
258 const Predicate& pred,
266 <<
"Entry '" << keyword <<
"' with invalid default in dictionary "
272 const entry* eptr = csearch(keyword, matchOpt).ptr();
281 checkITstream(is, keyword);
285 raiseBadInput(is, keyword);
290 else if (writeOptionalEntries)
292 reportDefault(keyword, deflt,
true);
314 const entry* eptr = csearch(keyword, matchOpt).ptr();
318 ITstream& is = eptr->stream();
321 checkITstream(is, keyword);
328 <<
"Entry '" << keyword <<
"' not found in dictionary "
337template<
class T,
class Predicate>
342 const Predicate& pred,
352 const entry* eptr = csearch(keyword, matchOpt).ptr();
359 checkITstream(is, keyword);
363 raiseBadInput(is, keyword);
371 <<
"Entry '" << keyword <<
"' not found in dictionary "
384 std::initializer_list<std::pair<const char*,int>> compat,
395 const entry* eptr = csearchCompat(keyword, compat, matchOpt).ptr();
402 checkITstream(is, keyword);
409 <<
"Entry '" << keyword <<
"' not found in dictionary "
437template<
class T,
class Predicate>
442 const Predicate& pred,
447 return readCheck<T, Predicate>
462 std::initializer_list<std::pair<const char*,int>> compat,
467 const entry* eptr = csearchCompat(keyword, compat, matchOpt).ptr();
476 checkITstream(is, keyword);
480 else if (writeOptionalEntries)
482 reportDefault(keyword, deflt);
493 std::initializer_list<std::pair<const char*,int>> compat,
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
readOption
Enumeration defining read preferences.
@ NO_READ
Nothing to be read.
@ READ_IF_PRESENT
Reading is optional [identical to LAZY_READ].
An input stream of tokens.
virtual Ostream & writeQuoted(const char *str, std::streamsize len, const bool quoted=true) override
Write character/string content, with/without surrounding quotes.
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T. FatalIOError if not found, or if the number of tokens is incorrect.
bool isNullDict() const noexcept
The dictionary is actually dictionary::null (root dictionary).
bool readIfPresentCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val using any compatibility names if needed....
void checkITstream(const ITstream &is, const word &keyword) const
Check after reading if the input token stream has unconsumed tokens remaining or if there were no tok...
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect,...
bool readCheck(const word &keyword, T &val, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val. FatalIOError if it is found and the number of tokens is incorrect,...
static refPtr< OSstream > reportingOutput
Output location when reporting default values.
const_searcher csearchCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword and any compatibility names.
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
T getCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T using any compatibility names if needed. FatalIOError if not found,...
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
T getOrDefaultCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value using any compatibility names if needed.
T getCheck(const word &keyword, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T with additional checking FatalIOError if not found, or if the number of tokens is...
friend class entry
Declare friendship with the entry class for IO.
T getCheckOrDefault(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
bool readCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, T &val, enum keyType::option matchOpt=keyType::REGEX, IOobjectOption::readOption readOpt=IOobjectOption::MUST_READ) const
Find entry and assign to T val using any compatibility names if needed. FatalIOError if there are exc...
wordList sortedToc() const
Return the sorted table of contents.
const_searcher csearch(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
T getOrAdd(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
Find and return a T, or return the given default value and add it to dictionary. FatalIOError if it i...
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
bool readCheckIfPresent(const word &keyword, T &val, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry if present, and assign to T val. FatalIOError if it is found and the number of tokens i...
T getCheckOrAdd(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX)
Find and return a T, or return the given default value and add it to dictionary. FatalIOError if it i...
A keyword and a list of tokens is an 'entry'.
virtual ITstream & stream() const =0
Return token stream, if entry is a primitive entry.
A class for handling keywords in dictionaries.
option
Enumeration for the data type and search/match modes (bitmask).
OSstream & stream(OSstream *alternative=nullptr, int communicator=-1)
Return OSstream for output operations.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A class for handling words, derived from Foam::string.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
List< word > wordList
List of word.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
messageStream InfoErr
Information stream (stderr output on master, null elsewhere).
errorManipArg< error, int > exit(error &err, const int errNo=1)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
constexpr char nl
The newline '\n' character (0x0a).