Go to the documentation of this file.
91 #include <type_traits>
104 #include "regExpFwd.H"
145 typedef typename std::conditional
149 typedef typename std::conditional
199 inline bool good()
const
205 inline bool found()
const
229 inline bool isDict()
const
244 return eptr_->dict();
317 matchOpt(
bool recursive,
bool pattern)
360 void raiseBadInput(
const ITstream& is,
const word& keyword)
const;
363 fileName relativeName(
const bool caseTag=
false)
const;
371 const bool added =
false
404 bool keepHeader =
false
463 const auto i = scopedName.rfind(
'.');
464 if (i == std::string::npos)
469 return scopedName.substr(i+1);
635 bool mandatory =
true
659 template<
class T,
class Predicate>
663 const Predicate& pred,
672 template<
class T,
class Predicate>
677 const Predicate& pred,
687 template<
class T,
class Predicate>
692 const Predicate& pred,
706 template<
class T,
class Predicate>
711 const Predicate& pred,
713 bool mandatory =
true
725 template<
class T,
class Predicate>
730 const Predicate& pred,
785 const bool mandatory =
false
805 template<
class Compare>
819 bool mergeEntry =
false
827 bool mergeEntry =
false
872 bool mergeEntry =
false
1015 const word& keyword,
1025 const word& keyword,
1035 const word& keyword,
1070 const word& keyword,
1071 std::initializer_list<std::pair<const char*,int>> compat,
1084 const word& keyword,
1085 std::initializer_list<std::pair<const char*,int>> compat,
1098 const word& keyword,
1099 std::initializer_list<std::pair<const char*,int>> compat,
1112 const word& keyword,
1113 std::initializer_list<std::pair<const char*,int>> compat,
1127 const word& keyword,
1128 std::initializer_list<std::pair<const char*,int>> compat,
1144 const word& keyword,
1145 std::initializer_list<std::pair<const char*,int>> compat,
1160 const word& keyword,
1161 std::initializer_list<std::pair<const char*,int>> compat,
1181 const word& keyword,
1182 std::initializer_list<std::pair<const char*,int>> compat,
1185 bool mandatory =
true
1203 const word& keyword,
1204 std::initializer_list<std::pair<const char*,int>> compat,
1246 const word& keyword,
1251 return getOrDefault<T>(keyword, deflt, matchOpt);
1263 const word& keyword,
1268 return getOrAdd<T>(keyword, deflt, matchOpt);
1282 const word& keyword,
1283 std::initializer_list<std::pair<const char*,int>> compat,
1288 return getOrDefaultCompat<T>(keyword, compat, deflt, matchOpt);
1306 const
word& keyword,
1307 bool recursive = false,
1308 bool patternMatch = true
1311 return get<T>(keyword, matchOpt(recursive, patternMatch));
1319 const
word& keyword,
1321 bool patternMatch = true
1324 return found(keyword, matchOpt(recursive, patternMatch));
1332 const
word& keyword,
1337 return findEntry(keyword, matchOpt(recursive, patternMatch));
1345 const
word& keyword,
1350 return findEntry(keyword, matchOpt(recursive, patternMatch));
1358 const
word& keyword,
1363 return findScoped(keyword, matchOpt(recursive, patternMatch));
1395 const
word& keyword,
1400 return lookupEntry(keyword, matchOpt(recursive, patternMatch));
1408 const
word& keyword,
1410 bool patternMatch = true
1413 return lookup(keyword, matchOpt(recursive, patternMatch));
1422 const
word& keyword,
1425 bool patternMatch = true
1428 return getOrDefault(keyword, matchOpt(recursive, patternMatch));
1437 const
word& keyword,
1440 bool patternMatch = true
1443 return getOrAdd(keyword, deflt, matchOpt(recursive, patternMatch));
1452 const
word& keyword,
1455 bool patternMatch = true
1460 (keyword, val, matchOpt(recursive, patternMatch));
1466 #undef defineDictionaryGetter
1467 #define defineDictionaryGetter(Func, Type) \
1471 const word& keyword, \
1472 enum keyType::option matchOpt = keyType::REGEX \
1475 return get<Type>(keyword, matchOpt); \
1485 #undef defineDictionaryGetter
A keyword and a list of tokens is an 'entry'.
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
pointer eptr_
The entry or nullptr.
dict_type & dict_reference
A reference to a const/non-const dictionary.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool overwrite=false)
Change the keyword for an entry,.
Non-intrusive doubly-linked list.
A class for handling words, derived from Foam::string.
const entry * lookupScopedEntryPtr(const word &keyword, bool recursive, bool patternMatch) const
Deprecated(2018-10)
dict_pointer dictPtr() const
Pointer to the found entry as a dictionary or nullptr otherwise.
A class for handling file names.
dict_type * dict_pointer
A pointer to a const/non-const dictionary.
T lookupOrDefaultCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
scalar getScalar(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< scalar >(const word&, keyType::option)
T getOrAdd(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
static autoPtr< dictionary > New(Istream &is)
Construct top-level dictionary on freestore from Istream.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
void checkITstream(const ITstream &is, const word &keyword) const
dictionary()
Construct top-level dictionary null.
T getCheckOrAdd(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX)
static std::string name(const std::string &str)
Return basename (part beyond last /), including its extension.
T getOrDefaultCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, const T &deflt, enum keyType::option=keyType::REGEX) const
void operator|=(const dictionary &rhs)
Conditionally include entries from the given dictionary.
const_searcher searchScoped(const word &keyword, enum keyType::option) const
Search using dot or slash scoping.
const dictionary * cfindScopedDict(const fileName &dictPath) const
Locate a sub-dictionary using slash-scoping.
string getString(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< string >(const word&, keyType::option)
T lookupOrAddDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX)
bool foundCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option=keyType::REGEX) const
Search dictionary for given keyword and any compatibility names.
Istream & operator>>(Istream &, directionInfo &)
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
T getCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option=keyType::REGEX) const
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
T lookupOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
void operator+=(const dictionary &rhs)
Include entries from the given dictionary.
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
reference operator*() const
A reference to the entry (Error if not found)
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given keyword (which is prefixed by '$')
pointer operator->() const
A pointer to the entry (nullptr if not found)
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
dict_reference context() const
The containing dictionary context.
bool getBool(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< bool >(const word&, keyType::option)
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
fileName getFileName(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< fileName >(const word&, keyType::option)
Template class for non-intrusive linked lists.
Generic const/non-const dictionary entry searcher.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
A class for handling keywords in dictionaries.
void operator<<=(const dictionary &rhs)
Unconditionally include entries from the given dictionary.
bool merge(const dictionary &dict)
Merge entries from the given dictionary.
friend class entry
Declare friendship with the entry class for IO.
const fileName & name() const
The dictionary name.
void writeEntry(Ostream &os) const
Write sub-dictionary with its dictName as its header.
bool readIfPresentCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, T &val, enum keyType::option=keyType::REGEX) const
const dictionary * findScopedDict(const fileName &dictPath) const
Locate a sub-dictionary using slash-scoping.
const entry & lookupEntryCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option) const
Recursive search (eg, in dictionary)
An input stream of tokens.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
const_searcher csearchScoped(const word &keyword, enum keyType::option) const
Search using scoping.
dictionary * makeScopedDict(const fileName &dictPath)
Locate existing or create sub-dictionary using slash-scoping.
Macro definitions for declaring ClassName(), NamespaceName(), etc.
virtual ~dictionary()
Destructor.
label startLineNumber() const
Return line number of first token in dictionary.
const_searcher csearch(const word &keyword, enum keyType::option=keyType::REGEX) const
Search dictionary for given keyword.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
label endLineNumber() const
Return line number of last token in dictionary.
Searcher< true > const_searcher
Searcher with const access.
const dictionary & parent() const
Return the parent dictionary.
bool readEntry(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
bool good() const
True if entry was found.
T getCheckOrDefault(const word &keyword, const T &deflt, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
value_type * pointer
A pointer to a const/non-const entry.
dict_reference dict() const
Reference the found entry as a dictionary.
Lookup type of boundary radiation properties.
const dictionary & topDict() const
Return the top of the tree.
std::conditional< Const, const entry, entry >::type value_type
The const/non-const type for entries.
word dictName() const
The local dictionary name (final part of scoped name)
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
pointer ptr() const
A pointer to the entry (nullptr if not found)
void writeEntries(Ostream &os, const bool extraNewLine=false) const
Write dictionary entries.
friend Ostream & operator<<(Ostream &os, const dictionary &dict)
Write dictionary to Ostream.
Template class for intrusive linked lists.
bool found() const
True if entry was found.
Searcher()
Construct null.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
fileName & name()
The dictionary name for modification (use with caution).
value_type & reference
A reference to a const/non-const entry.
word getWord(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< word >(const word&, keyType::option)
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
bool read(Istream &is)
Read dictionary from Istream.
label getLabel(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Same as get< label >(const word&, keyType::option)
const_searcher csearchCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option=keyType::REGEX) const
Search dictionary for given keyword and any compatibility names.
friend Istream & operator>>(Istream &is, dictionary &dict)
Read dictionary from Istream.
const dictionary * subDictPtr(const word &keyword) const
Deprecated(2018-10)
bool readCheck(const word &keyword, T &val, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX, bool mandatory=true) const
A HashTable similar to std::unordered_map.
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Check if entry is found and is a sub-dictionary.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
entry * lookupEntryPtr(const word &keyword, bool recursive, bool patternMatch)
Deprecated(2018-10)
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 remove(const word &keyword)
Remove an entry specified by keyword.
void write(Ostream &os, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
dict_pointer dict_
The dictionary context for the entry.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
ITstream & lookupCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option=keyType::REGEX) const
#define defineDictionaryGetter(Func, Type)
bool readCheckIfPresent(const word &keyword, T &val, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
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.
void operator=(const dictionary &rhs)
Copy assignment.
Searcher< false > searcher
Searcher with non-const access.
Searcher(dict_pointer dict)
Construct for the given dictionary context.
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
label k
Boltzmann constant.
const dimensionedScalar e
Elementary charge.
bool readCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, T &val, enum keyType::option=keyType::REGEX, bool mandatory=true) const
autoPtr< dictionary > clone() const
Construct and return clone.
bool isDict() const
True if found entry is a dictionary.
const_searcher search(const word &keyword, enum keyType::option=keyType::REGEX) const
Search dictionary for given keyword.
T getCheck(const word &keyword, const Predicate &pred, enum keyType::option matchOpt=keyType::REGEX) const
class FOAM_DEPRECATED_FOR(2017-05, "Foam::Enum") NamedEnum
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$')
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
void set(pointer eptr)
Assign the entry.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
tokenList tokens() const
Return the dictionary as a list of tokens.
wordList toc() const
Return the table of contents.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
const entry * findCompat(const word &keyword, std::initializer_list< std::pair< const char *, int >> compat, enum keyType::option) const
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
friend const_searcher
Declare friendship with the searcher classes.
T lookupType(const word &keyword, bool recursive=false, bool patternMatch=true) const
Deprecated(2018-10) find and return a T.
bitSet operator|(const bitSet &a, const bitSet &b)
Bitwise-OR of two bitsets.
void clear()
Clear the dictionary.
wordList sortedToc() const
Return the sorted table of contents.
reference ref() const
A reference to the entry (Error if not found)
Intrusive doubly-linked list.
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
option
Enumeration for the data type and search/match modes (bitmask)
std::conditional< Const, const dictionary, dictionary >::type dict_type
The const/non-const type for the context and sub-dictionaries.