Go to the documentation of this file.
59 "writeOptionalEntries",
101 hashedEntries_.insert(
e.keyword(), &
e);
103 if (
e.keyword().isPattern())
105 patterns_.insert(&
e);
123 hashedEntries_.insert(
e.keyword(), &
e);
125 if (
e.keyword().isPattern())
127 patterns_.insert(&
e);
196 if (&
p !=
this && !
p.name().empty())
209 return first()->startLineNumber();
220 return last()->endLineNumber();
232 for (
const entry&
e : *
this)
247 for (
const entry&
e : *
this)
280 err <<
"Entry '" << keyword <<
"' has "
281 << remaining <<
" excess tokens in stream" <<
nl <<
nl
283 is.writeList(err, 0);
291 <<
"--> FOAM FATAL IO ERROR:" <<
nl;
294 <<
"Entry '" << keyword <<
"' has "
295 << remaining <<
" excess tokens in stream" <<
nl <<
nl;
299 <<
"file: " << relativeName()
319 <<
"Entry '" << keyword
320 <<
"' had no tokens in stream" <<
nl <<
nl
327 <<
"--> FOAM FATAL IO ERROR:" <<
nl
328 <<
"Entry '" << keyword
329 <<
"' had no tokens in stream" <<
nl <<
nl;
333 <<
"file: " << relativeName()
343 void Foam::dictionary::raiseBadInput
360 <<
"Entry '" << keyword <<
"' with invalid input" <<
nl
376 <<
"Entry '" << keyword <<
"' not found in dictionary "
377 << relativeName() <<
nl
391 return lookupEntry(keyword, matchOpt).stream();
401 if (keyword.size() < 2)
407 const word varName(keyword.substr(1),
false);
415 for (
const entry&
e : finder.dict())
433 if (keyword.size() < 2)
439 const word varName(keyword.substr(1),
false);
447 for (
const entry&
e : finder.dict())
470 <<
"Entry '" << keyword <<
"' not found in dictionary "
471 << relativeName() <<
nl
475 return finder.
dict();
490 <<
"Entry '" << keyword <<
"' not found in dictionary "
491 << relativeName() <<
nl
495 return finder.
dict();
518 <<
"Entry '" << keyword
519 <<
"' is not a sub-dictionary in dictionary "
520 << relativeName() <<
nl
529 <<
"Failed to insert sub-dictionary '" << keyword
530 <<
"' in dictionary "
531 << relativeName() <<
nl
551 return finder.
dict();
557 <<
"Entry '" << keyword
558 <<
"' is not a sub-dictionary in dictionary "
559 << relativeName() <<
nl
566 <<
"Entry '" << keyword
567 <<
"' found but not a sub-dictionary in dictionary "
568 << relativeName() <<
endl;
587 return finder.
dict();
593 <<
"Entry '" << keyword
594 <<
"' found but not a sub-dictionary in dictionary "
595 << relativeName() <<
endl;
607 for (
const entry&
e : *
this)
609 list[
n++] =
e.keyword();
618 return hashedEntries_.sortedToc();
627 for (
const entry&
e : *
this)
629 if (
e.keyword().isPattern() ? patterns : !patterns)
631 list[
n++] =
e.keyword();
647 auto iter = hashedEntries_.find(entryPtr->
keyword());
649 if (mergeEntry && iter.good())
652 if (iter()->isDict() && entryPtr->
isDict())
662 parent_type::replace(iter(), entryPtr);
664 hashedEntries_.erase(iter);
666 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
673 patterns_.insert(entryPtr);
682 <<
"Problem replacing entry "<< entryPtr->
keyword()
683 <<
" in dictionary " << relativeName() <<
endl;
685 parent_type::remove(entryPtr);
692 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
701 patterns_.insert(entryPtr);
710 <<
"Attempt to add entry " << entryPtr->
keyword()
711 <<
" which already exists in dictionary "
712 << relativeName() <<
endl;
721 return add(
e.clone(*this).ptr(), mergeEntry);
793 finder.
dict().clear();
796 return add(entryPtr,
true);
802 return set(
e.clone(*this).ptr());
817 <<
"Attempted merge to self, for dictionary "
818 << relativeName() <<
nl
822 bool changed =
false;
826 auto fnd = hashedEntries_.find(
e.keyword());
832 if (fnd()->isDict() &&
e.isDict())
834 if (fnd()->dict().merge(
e.dict()))
841 add(
e.clone(*this).ptr(),
true);
848 add(
e.clone(*this).ptr());
860 hashedEntries_.clear();
872 parent_type::transfer(
dict);
873 hashedEntries_.transfer(
dict.hashedEntries_);
874 patterns_.transfer(
dict.patterns_);
875 regexps_.transfer(
dict.regexps_);
894 for (
const entry&
e : rhs)
896 add(
e.clone(*this).ptr());
906 <<
"Attempted addition to self, for dictionary "
907 << relativeName() <<
nl
911 for (
const entry&
e : rhs)
913 add(
e.clone(*this).ptr());
923 <<
"Attempted |= merging to self, for dictionary "
924 << relativeName() <<
nl
928 for (
const entry&
e : rhs)
932 add(
e.clone(*this).ptr());
943 <<
"Attempted addition to self, for dictionary "
944 << relativeName() <<
nl
948 for (
const entry&
e : rhs)
950 set(
e.clone(*this).ptr());
A keyword and a list of tokens is an 'entry'.
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
A keyword and a list of tokens is a 'dictionaryEntry'.
void set(List< bool > &bools, const labelRange &range)
Set the specified range 'on' in a boolList.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A class for handling words, derived from Foam::string.
bool isPattern() const noexcept
The keyType is treated as a pattern, not as literal string.
A class for handling file names.
static refPtr< OSstream > reportingOutput
Output location when reporting default values.
void resize(const label len)
Adjust allocated size of list.
void checkITstream(const ITstream &is, const word &keyword) const
dictionary()
Default construct, a top-level empty dictionary.
virtual bool isDict() const noexcept
Return true if this entry is a dictionary.
void operator|=(const dictionary &rhs)
Conditionally include entries from the given dictionary.
label lineNumber() const noexcept
Const access to the current stream line number.
const keyType & keyword() const noexcept
Return keyword.
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds an item read from Istream.
A class for handling character strings derived from std::string.
entry * set(entry *entryPtr)
Assign a new entry, overwriting any existing entry.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
const fileName & name() const noexcept
The dictionary name.
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.
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
Substitute the given keyword (which is prefixed by '$')
void transfer(dictionary &dict)
Transfer the contents of the argument and annul the argument.
static const dictionary null
An empty dictionary, which is also the parent for all dictionaries.
int infoSwitch(const char *name, const int deflt=0)
Lookup info switch or add default value.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
Generic const/non-const dictionary entry searcher.
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.
An input stream of tokens.
fileName relativeName(const bool caseTag=false) const
The dictionary name relative to the case.
virtual ~dictionary()
Destructor.
label startLineNumber() const
Return line number of first token in dictionary.
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Find and return a sub-dictionary.
label endLineNumber() const
Return line number of last token in dictionary.
static fileName envRelativePath(const fileName &input, const bool caseTag=false)
Generic output stream using a standard (STL) stream.
dict_pointer dictPtr() const noexcept
Pointer to the found entry as a dictionary, nullptr otherwise.
dict_reference dict() const
Reference the found entry as a dictionary.
const dictionary & topDict() const
Return the top of the tree.
The output stream for calculating SHA1 digests.
ITstream & lookup(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Template class for intrusive linked lists.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
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)
errorManip< error > abort(error &err)
virtual const dictionary & dict() const =0
Return dictionary, if entry is a dictionary.
static int writeOptionalEntries
Report optional keywords and values if not present in dictionary.
bool good() const noexcept
True if entry was found.
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
virtual const fileName & name() const =0
Return the entry name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
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 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...
Output to string buffer, using a OSstream. Always UNCOMPRESSED.
void operator=(const dictionary &rhs)
Copy assignment.
label k
Boltzmann constant.
const dimensionedScalar e
Elementary charge.
autoPtr< dictionary > clone() const
Construct and return clone.
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
Join two strings with a path separator ('/' by default).
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.
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
tokenList tokens() const
Return the dictionary as a list of tokens.
wordList toc() const
Return the table of contents.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
label nRemainingTokens() const noexcept
Number of tokens remaining.
bool isDict() const noexcept
True if found entry is a dictionary.
defineTypeNameAndDebug(combustionModel, 0)
void clear()
Clear the dictionary.
wordList sortedToc() const
Return the sorted table of contents.
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
reference ref() const
A reference to the entry (Error if not found)
registerInfoSwitch("writeOptionalEntries", int, Foam::dictionary::writeOptionalEntries)
option
Enumeration for the data type and search/match modes (bitmask)