59 "writeOptionalEntries",
95 parent_type(
dict, *this),
101 hashedEntries_.insert(
e.keyword(), &
e);
103 if (
e.keyword().isPattern())
105 patterns_.push_front(&
e);
114 const dictionary&
dict 117 parent_type(
dict, *this),
123 hashedEntries_.insert(
e.keyword(), &
e);
125 if (
e.keyword().isPattern())
127 patterns_.push_front(&
e);
148 const dictionary& parentDict,
196 if (&
p !=
this && !
p.
name().empty())
232 for (
const entry&
e : *
this)
247 for (
const entry&
e : *
this)
286 <<
"Entry '" << keyword <<
"' has " 287 << remaining <<
" excess tokens in stream" <<
nl <<
nl 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()
331 void Foam::dictionary::raiseBadInput
348 <<
"Entry '" << keyword <<
"' with invalid input" <<
nl 364 <<
"Entry '" << keyword <<
"' not found in dictionary " 365 << relativeName() <<
nl 379 return lookupEntry(keyword, matchOpt).stream();
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 512 dictPtr = this->
set(keyword,
dictionary())->dictPtr();
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())
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());
811 <<
"Attempted merge to self, for dictionary " 812 << relativeName() <<
nl 816 bool changed =
false;
818 for (
const entry&
e :
dict)
820 auto fnd = hashedEntries_.find(
e.keyword());
826 if (fnd()->isDict() &&
e.isDict())
828 if (fnd()->dict().merge(
e.dict()))
835 add(
e.clone(*this).ptr(),
true);
842 add(
e.clone(*this).ptr());
854 hashedEntries_.clear();
866 parent_type::transfer(
dict);
867 hashedEntries_.transfer(
dict.hashedEntries_);
868 patterns_.transfer(
dict.patterns_);
869 regexps_.transfer(
dict.regexps_);
890 add(
e.clone(*this).ptr());
900 <<
"Attempted addition to self, for dictionary " 901 << relativeName() <<
nl 907 add(
e.clone(*this).ptr());
917 <<
"Attempted |= merging to self, for dictionary " 918 << relativeName() <<
nl 922 for (
const entry&
e : rhs)
926 add(
e.clone(*this).ptr());
937 <<
"Attempted addition to self, for dictionary " 938 << relativeName() <<
nl 942 for (
const entry&
e : rhs)
944 set(
e.clone(*this).ptr());
Template class for intrusive linked lists.
registerInfoSwitch("writeOptionalEntries", int, Foam::dictionary::writeOptionalEntries)
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. ...
void size(const label n)
Older name for setAddressableSize.
void operator<<=(const dictionary &rhs)
Unconditionally include entries from the given dictionary.
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.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
A list of keyword definitions, which are a keyword followed by a number of values (eg...
const word & name() const noexcept
Return the object name.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void operator|=(const dictionary &rhs)
Conditionally include entries from the given dictionary.
constexpr char nl
The newline '\n' character (0x0a)
A token holds an item read from Istream.
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given scoped keyword (which is prefixed by '$')
Ostream & endl(Ostream &os)
Add newline and flush stream.
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary, otherwise Fatal.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
label k
Boltzmann constant.
The output stream for calculating SHA1 digests.
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
const fileName & name() const noexcept
The dictionary name.
A keyword and a list of tokens is a 'dictionaryEntry'.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
label nRemainingTokens() const noexcept
Number of tokens remaining.
autoPtr< dictionary > clone() const
Construct and return clone.
wordList toc() const
Return the table of contents.
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary for manipulation.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read...
dictionary()
Default construct, a top-level empty dictionary.
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.
Ostream & writeList(Ostream &os, const label shortLen=0) const
Write List, with line-breaks in ASCII when length exceeds shortLen.
static refPtr< OSstream > reportingOutput
Output location when reporting default values.
const dimensionedScalar e
Elementary charge.
const keyType & keyword() const noexcept
Return keyword.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for expressions::valueTypeCode::INVALID.
void operator=(const dictionary &rhs)
Copy assignment.
A class for handling words, derived from Foam::string.
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 '$')
errorManip< error > abort(error &err)
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
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. ...
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 int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
Join two strings with a path separator ('/' by default).
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
label lineNumber() const noexcept
Const access to the current stream line number.
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
static word envExecutable()
Name of the executable from environment variable.
List< word > wordList
List of word.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
option
Enumeration for the data type and search/match modes (bitmask)
virtual ~dictionary()
Destructor.
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...
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
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.
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
void clear()
Clear the dictionary.
A class for handling character strings derived from std::string.
void operator+=(const dictionary &rhs)
Include entries from the given dictionary.
label startLineNumber() const
Return line number of first token in dictionary.
wordList sortedToc() const
Return the sorted table of contents.
An input stream of tokens.
static bool constructed
Global value for constructed job info.
A keyword and a list of tokens is an 'entry'.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...