97#ifndef Foam_dictionary_H
98#define Foam_dictionary_H
100#include <type_traits>
159 std::conditional_t<Const, const dictionary, dictionary>;
163 std::conditional_t<Const, const entry, entry>;
248 return (
eptr_ ?
eptr_->streamPtr() :
nullptr);
323 matchOpt(
bool recursive,
bool pattern)
368 void raiseBadInput(
const ITstream& is,
const word& keyword)
const;
372 static word executableName();
381 const bool added =
false
431 bool keepHeader = false
716 template<class
T, class Predicate>
720 const Predicate& pred,
731 template<class
T, class Predicate>
736 const Predicate& pred,
748 template<class
T, class Predicate>
753 const Predicate& pred,
768 template<class
T, class Predicate>
773 const Predicate& pred,
787 template<class
T, class Predicate>
792 const Predicate& pred,
840 const
bool mandatory = false
861 template<class Compare>
875 bool mergeEntry = false
883 bool mergeEntry = false
933 bool mergeEntry = false
1043 const
word& keyword,
1053 const
word& keyword,
1063 const
word& keyword,
1092 const
word& keyword,
1102 const
word& keyword,
1112 const
word& keyword,
1145 const
word& keyword,
1146 std::initializer_list<std::pair<const
char*,
int>> compat,
1159 const
word& keyword,
1160 std::initializer_list<std::pair<const
char*,
int>> compat,
1172 const
word& keyword,
1173 std::initializer_list<std::pair<const
char*,
int>> compat,
1186 const
word& keyword,
1187 std::initializer_list<std::pair<const
char*,
int>> compat,
1200 const
word& keyword,
1201 std::initializer_list<std::pair<const
char*,
int>> compat,
1216 const
word& keyword,
1217 std::initializer_list<std::pair<const
char*,
int>> compat,
1232 const
word& keyword,
1233 std::initializer_list<std::pair<const
char*,
int>> compat,
1253 const
word& keyword,
1254 std::initializer_list<std::pair<const
char*,
int>> compat,
1274 const
word& keyword,
1275 std::initializer_list<std::pair<const
char*,
int>> compat,
1310 #undef defineDictionaryGetter
1311 #define defineDictionaryGetter(Func, Type) \
1315 const word& keyword, \
1316 enum keyType::option matchOpt = keyType::REGEX \
1319 return get<Type>(keyword, matchOpt); \
1329 #undef defineDictionaryGetter
1339 const
word& keyword,
1343 return static_cast<bool>(
findDict(keyword, matchOpt));
1351 const
word& keyword,
1364 const word& keyword,
1366 enum keyType::option matchOpt = keyType::REGEX
1375 ITstream&
operator[](const word& keyword)
const
1385 const word& keyword,
1387 bool patternMatch = true
1390 return found(keyword, matchOpt(recursive, patternMatch));
1398 const word& keyword,
1403 return findEntry(keyword, matchOpt(recursive, patternMatch));
1411 const word& keyword,
1416 return findEntry(keyword, matchOpt(recursive, patternMatch));
1424 const word& keyword,
1429 return findScoped(keyword, matchOpt(recursive, patternMatch));
1461 const word& keyword,
1466 return lookupEntry(keyword, matchOpt(recursive, patternMatch));
1474 const word& keyword,
1476 bool patternMatch = true
1479 return lookup(keyword, matchOpt(recursive, patternMatch));
1488 const word& keyword,
1491 bool patternMatch = true
1494 return getOrDefault(keyword, matchOpt(recursive, patternMatch));
1503 const word& keyword,
1506 bool patternMatch = true
1509 return getOrAdd(keyword, deflt, matchOpt(recursive, patternMatch));
1518 const word& keyword,
1521 bool patternMatch = true
1526 (keyword, val, matchOpt(recursive, patternMatch));
1538 const word& keyword,
1539 bool recursive = false,
1540 bool patternMatch = true
1543 return get<T>(keyword, matchOpt(recursive, patternMatch));
1546 #ifdef COMPAT_OPENFOAM_ORG
1553 const word& keyword,
1554 bool recursive = false,
1555 bool patternMatch = true
1558 return get<T>(keyword, matchOpt(recursive, patternMatch));
Non-intrusive doubly-linked list.
Intrusive doubly-linked list.
A HashTable similar to std::unordered_map.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
An input stream of tokens.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Generic output stream using a standard (STL) stream.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
friend Ostream & operator(Ostream &os, const UILList< DLListBase, T > &lst)
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Generic const/non-const dictionary entry searcher.
void set(pointer eptr) noexcept
Assign the entry.
dict_type & dict_reference
A reference to a const/non-const dictionary.
bool found() const noexcept
True if entry was found.
value_type * pointer
A pointer to a const/non-const entry.
bool good() const noexcept
True if entry was found.
std::conditional_t< Const, const dictionary, dictionary > dict_type
The const/non-const type for the context and sub-dictionaries.
value_type & reference
A reference to a const/non-const entry.
pointer ptr() const noexcept
A pointer to the entry (nullptr if not found).
dict_reference dict() const
bool isDict() const noexcept
True if found entry is a dictionary.
dict_type * dict_pointer
A pointer to a const/non-const dictionary.
dict_reference context() const
The containing dictionary context.
Searcher(dict_pointer dict) noexcept
Implicit construct for the given dictionary context.
std::conditional_t< Const, const entry, entry > value_type
The const/non-const type for entries.
reference operator*() const
A reference to the entry (Error if not found).
ITstream * streamPtr() const noexcept
Pointer to the found entry as a stream, nullptr otherwise.
pointer operator->() const noexcept
A pointer to the entry (nullptr if not found).
bool isStream() const noexcept
True if found entry is a stream.
ITstream & stream() const
Return the found entry as a ITstream. Error if not found, or not a stream.
constexpr Searcher() noexcept
Default construct.
reference ref() const
A reference to the entry (Error if not found).
dict_pointer dictPtr() const noexcept
Pointer to the found entry as a dictionary, nullptr otherwise.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
Find and return a sub-dictionary as a copy, otherwise return an empty dictionary.
const entry * findCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt) const
Find and return an entry pointer if present, or return a nullptr, using any compatibility names if ne...
bool foundCompat(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.
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.
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
bool isNullDict() const noexcept
The dictionary is actually dictionary::null (root dictionary).
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
static int reportOptional() noexcept
Return the state of reporting optional (default) entries.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
Change the keyword for an entry,.
const fileName & name() const noexcept
The dictionary name.
const entry * findScoped(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for a scoped entry (const access) with the given keyword.
const dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary pointer if present (and it is a dictionary) otherwise return nullptr...
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....
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
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...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
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,...
fileName getFileName(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get<fileName>(const word&, keyType::option).
const entry * lookupScopedEntryPtr(const word &keyword, bool recursive, bool patternMatch) const
Deprecated(2018-10).
const dictionary & topDict() const
Return the top of the tree.
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.
T lookupType(const word &keyword, bool recursive=false, bool patternMatch=true) const
Deprecated(2018-10) find and return a T.
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given keyword (which is prefixed by '$').
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.
dictionary()
Default construct, a top-level empty dictionary.
autoPtr< dictionary > clone() const
Construct and return clone.
entry * lookupEntryPtr(const word &keyword, bool recursive, bool patternMatch)
Deprecated(2018-10).
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,...
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
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 lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Same as getOrDefault().
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.
string getString(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get<string>(const word&, keyType::option).
word getWord(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get<word>(const word&, keyType::option).
const_searcher csearchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using scoping.
const dictionary * findScopedDict(const fileName &dictPath) const
Locate a sub-dictionary using slash-scoping.
bool remove(const word &keyword)
Remove an entry specified by keyword.
tokenList tokens() const
Return the dictionary as a list of tokens.
static autoPtr< dictionary > New(Istream &is)
Construct top-level dictionary on freestore from Istream.
label getLabel(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get<label>(const word&, keyType::option).
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
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...
T lookupOrAddDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
Same as getOrAdd().
const dictionary * subDictPtr(const word &keyword) const
Deprecated(2018-10).
friend class entry
Declare friendship with the entry class for IO.
dictionary * makeScopedDict(const fileName &dictPath)
Locate existing or create sub-dictionary using slash-scoping.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream. FatalIOError if not found, or not a stream.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
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...
const_searcher search(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
label endLineNumber() const
Return line number of last token in dictionary.
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$').
void writeEntries(Ostream &os, const bool extraNewLine=false) const
Write dictionary entries.
wordList sortedToc() const
Return the sorted table of contents.
ITstream & lookupCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry data stream, using any compatibility names if needed.
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
const dictionary * cfindScopedDict(const fileName &dictPath) const
Locate a sub-dictionary using slash-scoping.
scalar getScalar(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get<scalar>(const word&, keyType::option).
const dictionary & parent() const noexcept
Return the parent dictionary.
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
const entry & lookupEntryCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt) const
Find and return an entry if present, otherwise FatalIOError, using any compatibility names if needed.
const_searcher csearch(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
Searcher< false > searcher
Searcher with non-const access.
Searcher< true > const_searcher
Searcher with const access.
void clear()
Clear the dictionary.
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Check for existence of a sub-dictionary. Generally prefer findDict() for more flexibility.
ITstream * findStream(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return an entry stream if present (and it is a stream) otherwise return nullptr.
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.
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
wordList toc() const
Return the table of contents.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
bool read(Istream &is)
Read dictionary from Istream (discards the header). Reads entries until EOF or when the first token i...
label startLineNumber() const
Return line number of first token in dictionary.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
const_searcher searchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using dot or slash scoping.
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...
word dictName() const
The local dictionary name (final part of scoped name).
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
bool getBool(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get<bool>(const word&, keyType::option).
A class for handling file names.
A class for handling keywords in dictionaries.
option
Enumeration for the data type and search/match modes (bitmask).
@ REGEX
Regular expression.
@ RECURSIVE
Recursive search (eg, in dictionary).
Lookup type of boundary radiation properties.
A class for managing references or pointers (no reference counting).
A token holds an item read from Istream.
A class for handling words, derived from Foam::string.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
#define ClassName(TypeNameString)
Add typeName information from argument TypeNameString to a class.
#define defineDictionaryGetter(Func, Type)
OBJstream os(runTime.globalPath()/outputName)
fileName dictPath(runTime.system()/regionDir/faMesh::prefix()/areaRegionDir/dictName)
ILList< DLListBase, T > IDLList
List< word > wordList
List of word.
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
Istream & operator>>(Istream &, directionInfo &)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
List< token > tokenList
List of token, used for dictionary primitive entry (for example).
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
LList< DLListBase, T > DLList
#define FOAM_DEPRECATED_FOR(since, replacement)
#define FOAM_DEPRECATED_STRICT(since, replacement)