88 #ifndef Foam_dictionary_H 89 #define Foam_dictionary_H 91 #include <type_traits> 148 typedef typename std::conditional
152 typedef typename std::conditional
233 return eptr_->dict();
306 matchOpt(
bool recursive,
bool pattern)
351 void raiseBadInput(
const ITstream& is,
const word& keyword)
const;
355 static word executableName();
364 const bool added =
false 414 bool keepHeader = false
697 template<class
T, class Predicate>
701 const Predicate& pred,
712 template<class
T, class Predicate>
717 const Predicate& pred,
729 template<class
T, class Predicate>
734 const Predicate& pred,
749 template<class
T, class Predicate>
754 const Predicate& pred,
768 template<class
T, class Predicate>
773 const Predicate& pred,
821 const
bool mandatory = false
842 template<class Compare>
856 bool mergeEntry = false
864 bool mergeEntry = false
914 bool mergeEntry = false
1005 const
word& keyword,
1015 const
word& keyword,
1025 const
word& keyword,
1054 const
word& keyword,
1064 const
word& keyword,
1074 const
word& keyword,
1107 const
word& keyword,
1108 std::initializer_list<
std::pair<const
char*,
int>> compat,
1121 const
word& keyword,
1122 std::initializer_list<
std::pair<const
char*,
int>> compat,
1134 const
word& keyword,
1135 std::initializer_list<
std::pair<const
char*,
int>> compat,
1148 const
word& keyword,
1149 std::initializer_list<
std::pair<const
char*,
int>> compat,
1162 const
word& keyword,
1163 std::initializer_list<
std::pair<const
char*,
int>> compat,
1178 const
word& keyword,
1179 std::initializer_list<
std::pair<const
char*,
int>> compat,
1194 const
word& keyword,
1195 std::initializer_list<
std::pair<const
char*,
int>> compat,
1215 const
word& keyword,
1216 std::initializer_list<
std::pair<const
char*,
int>> compat,
1236 const
word& keyword,
1237 std::initializer_list<
std::pair<const
char*,
int>> compat,
1272 #undef defineDictionaryGetter 1273 #define defineDictionaryGetter(Func, Type) \ 1277 const word& keyword, \ 1278 enum keyType::option matchOpt = keyType::REGEX \ 1281 return get<Type>(keyword, matchOpt); \ 1291 #undef defineDictionaryGetter 1305 const word& keyword,
1310 return getOrDefault<T>(keyword, deflt, matchOpt);
1324 const word& keyword,
1329 return getOrAdd<T>(keyword, deflt, matchOpt);
1335 ITstream&
operator[](const word& keyword)
const 1345 const word& keyword,
1347 bool patternMatch = true
1350 return found(keyword, matchOpt(recursive, patternMatch));
1358 const word& keyword,
1363 return findEntry(keyword, matchOpt(recursive, patternMatch));
1371 const word& keyword,
1376 return findEntry(keyword, matchOpt(recursive, patternMatch));
1384 const word& keyword,
1389 return findScoped(keyword, matchOpt(recursive, patternMatch));
1421 const word& keyword,
1426 return lookupEntry(keyword, matchOpt(recursive, patternMatch));
1434 const word& keyword,
1436 bool patternMatch = true
1439 return lookup(keyword, matchOpt(recursive, patternMatch));
1448 const word& keyword,
1451 bool patternMatch = true
1454 return getOrDefault(keyword, matchOpt(recursive, patternMatch));
1463 const word& keyword,
1466 bool patternMatch = true
1469 return getOrAdd(keyword, deflt, matchOpt(recursive, patternMatch));
1478 const word& keyword,
1481 bool patternMatch = true
1486 (keyword, val, matchOpt(recursive, patternMatch));
1498 const word& keyword,
1499 bool recursive = false,
1500 bool patternMatch = true
1503 return get<T>(keyword, matchOpt(recursive, patternMatch));
1506 #ifdef COMPAT_OPENFOAM_ORG 1513 const word& keyword,
1514 bool recursive = false,
1515 bool patternMatch = true
1518 return get<T>(keyword, matchOpt(recursive, patternMatch));
1529 dictionary
operator+(
const dictionary& dict1,
const dictionary& dict2);
1534 dictionary
operator|(
const dictionary& dict1,
const dictionary& dict2);
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
Reference the found entry as 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.
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.
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...
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)
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.
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
Find and return a T, or return the given default value. FatalIOError if it is found and the number of...
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 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)
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.
T & reference
Reference for value_type.
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
Find a sub-dictionary.
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.
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)
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 a sub-dictionary) otherwise return nullptr...