88#ifndef Foam_dictionary_H
89#define Foam_dictionary_H
105#include "regExpFwd.H"
147 typedef typename std::conditional
151 typedef typename std::conditional
247 return eptr_->dict();
320 matchOpt(
bool recursive,
bool pattern)
365 void raiseBadInput(
const ITstream& is,
const word& keyword)
const;
369 static word executableName();
378 const bool added =
false
428 bool keepHeader = false
671 bool mandatory = true
696 template<class
T, class Predicate>
700 const Predicate& pred,
711 template<class
T, class Predicate>
716 const Predicate& pred,
728 template<class
T, class Predicate>
733 const Predicate& pred,
748 template<class
T, class Predicate>
753 const Predicate& pred,
755 bool mandatory = true
767 template<class
T, class Predicate>
772 const Predicate& pred,
832 const
bool mandatory = false
853 template<class Compare>
867 bool mergeEntry = false
875 bool mergeEntry = false
925 bool mergeEntry = false
1016 const
word& keyword,
1026 const
word& keyword,
1036 const
word& keyword,
1065 const
word& keyword,
1075 const
word& keyword,
1085 const
word& keyword,
1118 const
word& keyword,
1119 std::initializer_list<std::pair<const
char*,
int>> compat,
1131 const
word& keyword,
1132 std::initializer_list<std::pair<const
char*,
int>> compat,
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,
1173 const
word& keyword,
1174 std::initializer_list<std::pair<const
char*,
int>> compat,
1189 const
word& keyword,
1190 std::initializer_list<std::pair<const
char*,
int>> compat,
1205 const
word& keyword,
1206 std::initializer_list<std::pair<const
char*,
int>> compat,
1226 const
word& keyword,
1227 std::initializer_list<std::pair<const
char*,
int>> compat,
1230 bool mandatory = true
1247 const
word& keyword,
1248 std::initializer_list<std::pair<const
char*,
int>> compat,
1292 const
word& keyword,
1297 return getOrDefault<T>(keyword, deflt, matchOpt);
1311 const word& keyword,
1316 return getOrAdd<T>(keyword, deflt, matchOpt);
1331 const
word& keyword,
1332 std::initializer_list<std::pair<const
char*,
int>> compat,
1337 return getOrDefaultCompat<T>(keyword, compat, deflt, matchOpt);
1354 const
word& keyword,
1356 bool patternMatch = true
1359 return found(keyword, matchOpt(recursive, patternMatch));
1367 const
word& keyword,
1372 return findEntry(keyword, matchOpt(recursive, patternMatch));
1380 const
word& keyword,
1385 return findEntry(keyword, matchOpt(recursive, patternMatch));
1393 const
word& keyword,
1398 return findScoped(keyword, matchOpt(recursive, patternMatch));
1430 const
word& keyword,
1435 return lookupEntry(keyword, matchOpt(recursive, patternMatch));
1443 const
word& keyword,
1445 bool patternMatch = true
1448 return lookup(keyword, matchOpt(recursive, patternMatch));
1457 const
word& keyword,
1460 bool patternMatch = true
1463 return getOrDefault(keyword, matchOpt(recursive, patternMatch));
1472 const
word& keyword,
1475 bool patternMatch = true
1478 return getOrAdd(keyword, deflt, matchOpt(recursive, patternMatch));
1487 const
word& keyword,
1490 bool patternMatch = true
1495 (keyword, val, matchOpt(recursive, patternMatch));
1507 const
word& keyword,
1508 bool recursive = false,
1509 bool patternMatch = true
1512 return get<T>(keyword, matchOpt(recursive, patternMatch));
1515 #ifdef COMPAT_OPENFOAM_ORG
1522 const
word& keyword,
1523 bool recursive = false,
1524 bool patternMatch = true
1527 return get<T>(keyword, matchOpt(recursive, patternMatch));
1534 #undef defineDictionaryGetter
1535 #define defineDictionaryGetter(Func, Type) \
1539 const word& keyword, \
1540 enum keyType::option matchOpt = keyType::REGEX \
1543 return get<Type>(keyword, matchOpt); \
1553 #undef defineDictionaryGetter
Non-intrusive doubly-linked list.
Intrusive doubly-linked list.
A HashTable similar to std::unordered_map.
Template class for intrusive linked lists.
An input stream of tokens.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Template class for non-intrusive linked lists.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
friend Ostream & operator(Ostream &os, const UILList< LListBase, T > &lst)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Generic const/non-const dictionary entry searcher.
std::conditional< Const, constdictionary, dictionary >::type dict_type
The const/non-const type for the context and sub-dictionaries.
dict_type * dict_pointer
A pointer to a const/non-const dictionary.
bool found() const noexcept
True if entry was found.
void set(pointer eptr)
Assign the entry.
bool good() const noexcept
True if entry was found.
pointer ptr() const noexcept
A pointer to the entry (nullptr if not found)
dict_reference dict() const
Reference the found entry as a dictionary.
bool isDict() const noexcept
True if found entry is a dictionary.
pointer eptr_
The entry or nullptr.
dict_reference context() const
The containing dictionary context.
std::conditional< Const, constentry, entry >::type value_type
The const/non-const type for entries.
reference operator*() const
A reference to the entry (Error if not found)
dict_pointer dict_
The dictionary context for the entry.
pointer operator->() const noexcept
A pointer to the entry (nullptr if not found)
value_type & reference
A reference to a const/non-const entry.
value_type * pointer
A pointer to a const/non-const entry.
dict_type & dict_reference
A reference to a const/non-const dictionary.
Searcher()
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
const entry * findCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, enum keyType::option matchOpt) const
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
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.
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
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.
bool readIfPresentCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, T &val, enum keyType::option matchOpt=keyType::REGEX) const
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
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
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.
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.
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
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
bool readCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
T getOrDefaultCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
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.
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
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
T lookupOrAddDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
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.
T getCheckOrDefault(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
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
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
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 if entry is found and is a sub-dictionary.
T getOrAdd(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
wordList toc() const
Return the table of contents.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
bool read(Istream &is)
Read dictionary from Istream. Discards the header.
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.
friend const_searcher
Declare friendship with the searcher classes.
bool readCheckIfPresent(const word &keyword, T &val, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
T getCheckOrAdd(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX)
word dictName() const
The local dictionary name (final part of scoped name)
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
T lookupOrDefaultCompat(const word &keyword, std::initializer_list< std::pair< const char *, int > > compat, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
bool readCheck(const word &keyword, T &val, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
bool getBool(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< bool >(const word&, keyType::option)
A keyword and a list of tokens is an 'entry'.
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 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)
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
tmp< faMatrix< Type > > operator+(const faMatrix< Type > &, const faMatrix< Type > &)
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Istream & operator>>(Istream &, directionInfo &)
#define FOAM_DEPRECATED_FOR(since, replacement)