59 "writeOptionalEntries",
95 parent_type(
dict, *this),
101 hashedEntries_.insert(
e.keyword(), &
e);
103 if (
e.keyword().isPattern())
105 patterns_.push_front(&
e);
117 parent_type(
dict, *this),
123 hashedEntries_.insert(
e.keyword(), &
e);
125 if (
e.keyword().isPattern())
127 patterns_.push_front(&
e);
196 if (&
p !=
this && !
p.name().empty())
232 for (
const entry&
e : *
this)
247 for (
const entry&
e : *
this)
263 const label remaining = (is.size() ? is.nRemainingTokens() : -100);
286 <<
"Entry '" << keyword <<
"' has "
287 << remaining <<
" excess tokens in stream" <<
nl <<
nl
289 is.writeList(err, 0);
293 err <<
"Entry '" << keyword
294 <<
"' had no tokens in stream" <<
nl <<
nl;
305 <<
"--> FOAM FATAL IO ERROR:" <<
nl;
310 <<
"Entry '" << keyword <<
"' has "
311 << remaining <<
" excess tokens in stream" <<
nl <<
nl;
316 <<
"Entry '" << keyword
317 <<
"' had no tokens in stream" <<
nl <<
nl;
322 <<
"file: " << relativeName()
323 <<
" at line " << is.lineNumber() <<
'.' <<
nl
331void Foam::dictionary::raiseBadInput
348 <<
"Entry '" << keyword <<
"' with invalid input" <<
nl
359 const entry* eptr = findEntry(keyword, matchOpt);
364 <<
"Entry '" << keyword <<
"' not found in dictionary "
365 << relativeName() <<
nl
389 if (keyword.size() < 2)
395 const word varName(keyword.substr(1),
false);
403 for (
const entry&
e : finder.dict())
421 if (keyword.size() < 2)
427 const word varName(keyword.substr(1),
false);
435 for (
const entry&
e : finder.dict())
453 const const_searcher finder(csearch(keyword, matchOpt));
458 <<
"Entry '" << keyword <<
"' not found in dictionary "
459 << relativeName() <<
nl
463 return finder.dict();
473 searcher finder(
search(keyword, matchOpt));
478 <<
"Entry '" << keyword <<
"' not found in dictionary "
479 << relativeName() <<
nl
483 return finder.dict();
493 searcher finder(
search(keyword, matchOpt));
506 <<
"Entry '" << keyword
507 <<
"' is not a sub-dictionary in dictionary "
508 << relativeName() <<
nl
517 <<
"Failed to insert sub-dictionary '" << keyword
518 <<
"' in dictionary "
519 << relativeName() <<
nl
534 const const_searcher finder(csearch(keyword, matchOpt));
547 <<
"Entry '" << keyword
548 <<
"' is not a sub-dictionary in dictionary "
549 << relativeName() <<
nl
556 <<
"Entry '" << keyword
557 <<
"' found but not a sub-dictionary in dictionary "
558 << relativeName() <<
endl;
572 const const_searcher finder(csearch(keyword, matchOpt));
585 <<
"Entry '" << keyword
586 <<
"' found but not a sub-dictionary in dictionary "
599 for (
const entry&
e : *
this)
601 list[
n++] =
e.keyword();
610 return hashedEntries_.sortedToc();
619 for (
const entry&
e : *
this)
621 if (
e.keyword().isPattern() ? patterns : !patterns)
623 list[
n++] =
e.keyword();
639 auto iter = hashedEntries_.find(entryPtr->keyword());
641 if (mergeEntry && iter.good())
644 if (iter()->isDict() && entryPtr->isDict())
646 iter()->dict().merge(entryPtr->dict());
654 parent_type::replace(iter(), entryPtr);
656 hashedEntries_.erase(iter);
658 if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
663 if (entryPtr->keyword().isPattern())
665 patterns_.push_front(entryPtr);
674 <<
"Problem replacing entry "<< entryPtr->keyword()
675 <<
" in dictionary " << relativeName() <<
endl;
677 parent_type::remove(entryPtr);
684 if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
689 parent_type::push_back(entryPtr);
691 if (entryPtr->keyword().isPattern())
693 patterns_.push_front(entryPtr);
702 <<
"Attempt to add entry " << entryPtr->
keyword()
703 <<
" which already exists in dictionary "
713 return add(
e.clone(*this).ptr(), mergeEntry);
790 return add(entryPtr,
true);
796 return set(
e.clone(*this).ptr());
829 <<
"Attempted merge to self, for dictionary "
830 << relativeName() <<
nl
834 bool changed =
false;
836 for (
const entry&
e :
dict)
838 auto fnd = hashedEntries_.find(
e.keyword());
844 if (fnd()->isDict() &&
e.isDict())
846 if (fnd()->
dict().merge(
e.dict()))
872 hashedEntries_.clear();
884 parent_type::transfer(
dict);
885 hashedEntries_.transfer(
dict.hashedEntries_);
886 patterns_.transfer(
dict.patterns_);
887 regexps_.transfer(
dict.regexps_);
908 add(
e.clone(*this).ptr());
918 <<
"Attempted addition to self, for dictionary "
919 << relativeName() <<
nl
925 add(
e.clone(*this).ptr());
935 <<
"Attempted |= merging to self, for dictionary "
936 << relativeName() <<
nl
944 add(
e.clone(*this).ptr());
955 <<
"Attempted addition to self, for dictionary "
956 << relativeName() <<
nl
962 set(
e.clone(*this).ptr());
969Foam::dictionary Foam::operator+
bool empty() const noexcept
True if the list is empty.
void push_back(link *item)
Add at back of list.
link * replace(link *oldLink, link *newLink)
Replace oldLink with newLink and return element.
label size() const noexcept
The number of elements in list.
tmp< GeometricField< Type, PatchField, GeoMesh > > clone() const
Clone.
void transfer(ILList< DLListBase, T > &lst)
label lineNumber() const noexcept
Const access to the current stream line number.
An input stream of tokens.
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
label nRemainingTokens() const noexcept
Number of tokens remaining.
static bool constructed
Global value for constructed job info.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void resize(const label len)
Adjust allocated size of list.
An OSstream with internal List storage.
The output stream for calculating SHA1 digests.
Generic output stream using a standard (STL) stream.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
void size(const label n)
Older name for setAddressableSize.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
static fileName envRelativePath(const fileName &input, const bool caseTag=false)
Return the input relative to the globalPath by stripping off a leading value of the envGlobalPath.
static word envExecutable()
Name of the executable from environment variable.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
A keyword and a list of tokens is a 'dictionaryEntry'.
bool good() const noexcept
True if entry was found.
dict_reference dict() const
Return the found entry as a dictionary. Error if not found, or not a dictionary.
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.
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary, otherwise return this dictionary.
const fileName & name() const noexcept
The dictionary name.
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.
const dictionary & topDict() const
Return the top of the tree.
void operator<<=(const dictionary &rhs)
Unconditionally include entries from the given dictionary.
static refPtr< OSstream > reportingOutput
Output location when reporting default values.
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given keyword (which is prefixed by '$').
dictionary()
Default construct, a top-level empty dictionary.
autoPtr< dictionary > clone() const
Construct and return clone.
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.
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.
const_searcher csearchScoped(const word &keyword, enum keyType::option matchOpt) const
Search using scoping.
tokenList tokens() const
Return the dictionary as a list of tokens.
void operator|=(const dictionary &rhs)
Conditionally include entries from the given dictionary.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
friend class entry
Declare friendship with the entry class for IO.
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.
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 '$').
wordList sortedToc() const
Return the sorted table of contents.
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_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.
virtual ~dictionary()
Destructor.
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.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
wordList toc() const
Return the table of contents.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
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.
void operator=(const dictionary &rhs)
Copy assignment.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
void operator+=(const dictionary &rhs)
Include entries from the given dictionary.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const noexcept
True if this entry is a dictionary.
virtual const fileName & name() const =0
Return the entry name.
const keyType & keyword() const noexcept
Return keyword.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary, otherwise Fatal.
A class for handling file names.
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
Join two strings with a path separator ('/' by default).
A class for handling keywords in dictionaries.
option
Enumeration for the data type and search/match modes (bitmask).
@ REGEX
Regular expression.
bool isPattern() const noexcept
The keyType is treated as a pattern, not as literal string.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A class for managing references or pointers (no reference counting).
A class for handling character strings derived from std::string.
A token holds an item read from Istream.
A class for handling words, derived from Foam::string.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
OBJstream os(runTime.globalPath()/outputName)
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
void set(List< bool > &bools, const labelUList &locations)
Set the listed locations (assign 'true').
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
List< word > wordList
List of word.
Ostream & endl(Ostream &os)
Add newline and flush stream.
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
errorManip< error > abort(error &err)
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
List< token > tokenList
List of token, used for dictionary primitive entry (for example).
errorManipArg< error, int > exit(error &err, const int errNo=1)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
constexpr char nl
The newline '\n' character (0x0a).
#define registerInfoSwitch(Name, Type, SwitchVar)