97 #ifndef Foam_dictionary_H 98 #define Foam_dictionary_H 100 #include <type_traits> 157 typedef typename std::conditional
161 typedef typename std::conditional
247 return (
eptr_ ?
eptr_->streamPtr() :
nullptr);
322 matchOpt(
bool recursive,
bool pattern)
367 void raiseBadInput(
const ITstream& is,
const word& keyword)
const;
371 static word executableName();
380 const bool added =
false 430 bool keepHeader = false
715 template<class
T, class Predicate>
719 const Predicate& pred,
730 template<class
T, class Predicate>
735 const Predicate& pred,
747 template<class
T, class Predicate>
752 const Predicate& pred,
767 template<class
T, class Predicate>
772 const Predicate& pred,
786 template<class
T, class Predicate>
791 const Predicate& pred,
839 const
bool mandatory = false
860 template<class Compare>
874 bool mergeEntry = false
882 bool mergeEntry = false
932 bool mergeEntry = false
1027 const
word& keyword,
1037 const
word& keyword,
1047 const
word& keyword,
1076 const
word& keyword,
1086 const
word& keyword,
1096 const
word& keyword,
1129 const
word& keyword,
1130 std::initializer_list<
std::pair<const
char*,
int>> compat,
1143 const
word& keyword,
1144 std::initializer_list<
std::pair<const
char*,
int>> compat,
1156 const
word& keyword,
1157 std::initializer_list<
std::pair<const
char*,
int>> compat,
1170 const
word& keyword,
1171 std::initializer_list<
std::pair<const
char*,
int>> compat,
1184 const
word& keyword,
1185 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,
1237 const
word& keyword,
1238 std::initializer_list<
std::pair<const
char*,
int>> compat,
1258 const
word& keyword,
1259 std::initializer_list<
std::pair<const
char*,
int>> compat,
1294 #undef defineDictionaryGetter 1295 #define defineDictionaryGetter(Func, Type) \ 1299 const word& keyword, \ 1300 enum keyType::option matchOpt = keyType::REGEX \ 1303 return get<Type>(keyword, matchOpt); \ 1313 #undef defineDictionaryGetter 1323 const
word& keyword,
1327 return static_cast<bool>(
findDict(keyword, matchOpt));
1335 const
word& keyword,
1340 return getOrDefault<T>(keyword, deflt, matchOpt);
1348 const word& keyword,
1350 enum keyType::option matchOpt = keyType::REGEX
1353 return getOrAdd<T>(keyword, deflt, matchOpt);
1359 ITstream&
operator[](const word& keyword)
const 1369 const word& keyword,
1371 bool patternMatch = true
1374 return found(keyword, matchOpt(recursive, patternMatch));
1382 const word& keyword,
1387 return findEntry(keyword, matchOpt(recursive, patternMatch));
1395 const word& keyword,
1400 return findEntry(keyword, matchOpt(recursive, patternMatch));
1408 const word& keyword,
1413 return findScoped(keyword, matchOpt(recursive, patternMatch));
1445 const word& keyword,
1450 return lookupEntry(keyword, matchOpt(recursive, patternMatch));
1458 const word& keyword,
1460 bool patternMatch = true
1463 return lookup(keyword, matchOpt(recursive, patternMatch));
1472 const word& keyword,
1475 bool patternMatch = true
1478 return getOrDefault(keyword, matchOpt(recursive, patternMatch));
1487 const word& keyword,
1490 bool patternMatch = true
1493 return getOrAdd(keyword, deflt, matchOpt(recursive, patternMatch));
1502 const word& keyword,
1505 bool patternMatch = true
1510 (keyword, val, matchOpt(recursive, patternMatch));
1522 const word& keyword,
1523 bool recursive = false,
1524 bool patternMatch = true
1527 return get<T>(keyword, matchOpt(recursive, patternMatch));
1530 #ifdef COMPAT_OPENFOAM_ORG 1537 const word& keyword,
1538 bool recursive = false,
1539 bool patternMatch = true
1542 return get<T>(keyword, matchOpt(recursive, patternMatch));
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
Template class for intrusive linked lists.
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...
dict_reference dict() const
Return the found entry as a dictionary. Error if not found, or not a dictionary.
word dictName() const
The local dictionary name (final part of scoped name)
string getString(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< string >(const word&, keyType::option)
A class for handling keywords in dictionaries.
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. ...
value_type & reference
A reference to a const/non-const entry.
entry * lookupEntryPtr(const word &keyword, bool recursive, bool patternMatch)
Deprecated(2018-10)
static int reportOptional() noexcept
Return the state of reporting optional (default) entries.
A class for handling file names.
label endLineNumber() const
Return line number of last token in dictionary.
tokenList tokens() const
Return the dictionary as a list of tokens.
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. FatalIOError if it is found and there are excess tokens.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
pointer eptr_
The entry or nullptr.
bool found() const noexcept
True if entry was found.
bool read(Istream &is)
Read dictionary from Istream (discards the header). Reads entries until EOF or when the first token i...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
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...
reference operator*() const
A reference to the entry (Error if not found)
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
dict_pointer dictPtr() const noexcept
Pointer to the found entry as a dictionary, nullptr otherwise.
Template class for non-intrusive linked lists.
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.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
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...
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$')
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...
ITstream & stream() const
Return the found entry as a ITstream. Error if not found, or not a stream.
std::conditional< Const, const entry, entry >::type value_type
The const/non-const type for entries.
T lookupOrAddDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
Same as getOrAdd()
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
label k
Boltzmann constant.
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.
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
Lookup type of boundary radiation properties.
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Same as getOrDefault()
const fileName & name() const noexcept
The dictionary name.
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...
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
A class for managing references or pointers (no reference counting)
autoPtr< dictionary > clone() const
Construct and return clone.
label getLabel(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< label >(const word&, keyType::option)
constexpr Searcher() noexcept
Default construct.
Recursive search (eg, in dictionary)
wordList toc() const
Return the table of contents.
const entry * findScoped(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for a scoped entry (const access) with the given keyword.
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
bool isStream() const noexcept
True if found entry is a stream.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
Searcher< false > searcher
Searcher with non-const access.
bool remove(const word &keyword)
Remove an entry specified by keyword.
const_searcher search(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
dictionary()
Default construct, a top-level empty dictionary.
const dictionary * findScopedDict(const fileName &dictPath) const
Locate a sub-dictionary using slash-scoping.
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...
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
static refPtr< OSstream > reportingOutput
Output location when reporting default values.
const dimensionedScalar e
Elementary charge.
static autoPtr< dictionary > New(Istream &is)
Construct top-level dictionary on freestore from Istream.
Intrusive doubly-linked list.
const dictionary & parent() const noexcept
Return the parent dictionary.
Generic const/non-const dictionary entry searcher.
bool good() const noexcept
True if entry was found.
A class for handling words, derived from Foam::string.
dict_reference context() const
The containing dictionary context.
value_type * pointer
A pointer to a const/non-const entry.
dict_type & dict_reference
A reference to a const/non-const dictionary.
Istream & operator>>(Istream &, directionInfo &)
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.
reference ref() const
A reference to the entry (Error if not found)
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...
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
const dictionary & topDict() const
Return the top of the tree.
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given keyword (which is prefixed by '$')
const entry * lookupScopedEntryPtr(const word &keyword, bool recursive, bool patternMatch) const
Deprecated(2018-10)
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.
dict_type * dict_pointer
A pointer to a const/non-const dictionary.
A HashTable similar to std::unordered_map.
word getWord(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< word >(const word&, keyType::option)
scalar getScalar(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< scalar >(const word&, keyType::option)
#define FOAM_DEPRECATED_STRICT(since, replacement)
An Ostream is an abstract base class for all output systems (streams, files, token lists...
T * pointer
Pointer for value_type.
std::conditional< Const, const dictionary, dictionary >::type dict_type
The const/non-const type for the context and sub-dictionaries.
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...
OBJstream os(runTime.globalPath()/outputName)
const dictionary * cfindScopedDict(const fileName &dictPath) const
Locate a sub-dictionary using slash-scoping.
const_searcher csearchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using scoping.
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. ...
Searcher< true > const_searcher
Searcher with const access.
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
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...
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, or if there are excess tokens.
const_searcher searchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using dot or slash scoping.
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.
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...
dictionary * makeScopedDict(const fileName &dictPath)
Locate existing or create sub-dictionary using slash-scoping.
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.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
bool isDict() const noexcept
True if found entry is a dictionary.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
Searcher(dict_pointer dict) noexcept
Implicit construct for the given dictionary context.
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
option
Enumeration for the data type and search/match modes (bitmask)
const entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find an entry (const access) with the given keyword.
dict_pointer dict_
The dictionary context for the entry.
Non-intrusive doubly-linked list.
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...
#define defineDictionaryGetter(Func, Type)
ITstream * streamPtr() const noexcept
Pointer to the found entry as a stream, nullptr otherwise.
const dictionary * subDictPtr(const word &keyword) const
Deprecated(2018-10)
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
friend class entry
Declare friendship with the entry class for IO.
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 lookupType(const word &keyword, bool recursive=false, bool patternMatch=true) const
Deprecated(2018-10) find and return a T.
const_searcher csearch(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search dictionary for given keyword.
pointer ptr() const noexcept
A pointer to the entry (nullptr if not found)
void clear()
Clear the dictionary.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
Change the keyword for an entry,.
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...
fileName getFileName(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< fileName >(const word&, keyType::option)
friend Ostream & operator(Ostream &os, const UILList< LListBase, T > &lst)
Write UILList to Ostream with line breaks, as per writeList() with shortLen=-1.
void writeEntries(Ostream &os, const bool extraNewLine=false) const
Write dictionary entries.
label startLineNumber() const
Return line number of first token in dictionary.
bool isNullDict() const noexcept
The dictionary is actually dictionary::null (root dictionary)
wordList sortedToc() const
Return the sorted table of contents.
An input stream of tokens.
pointer operator->() const noexcept
A pointer to the entry (nullptr if not found)
A keyword and a list of tokens is an 'entry'.
bool getBool(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< bool >(const word&, keyType::option)
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...
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...