Go to the documentation of this file.
59 "writeOptionalEntries",
95 parent_type(
dict, *this),
101 hashedEntries_.insert(
e.keyword(), &
e);
103 if (
e.keyword().isPattern())
105 patterns_.insert(&
e);
114 const dictionary&
dict
117 parent_type(
dict, *this),
119 parent_(dictionary::null)
123 hashedEntries_.insert(
e.keyword(), &
e);
125 if (
e.keyword().isPattern())
127 patterns_.insert(&
e);
137 parent_(dictionary::null)
148 const dictionary& parentDict,
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
371 const const_searcher finder(csearch(keyword, matchOpt));
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())
465 const const_searcher finder(csearch(keyword, matchOpt));
470 <<
"Entry '" << keyword <<
"' not found in dictionary "
471 << relativeName() <<
nl
475 return finder.dict();
485 searcher finder(
search(keyword, matchOpt));
490 <<
"Entry '" << keyword <<
"' not found in dictionary "
491 << relativeName() <<
nl
495 return finder.dict();
505 searcher finder(
search(keyword, matchOpt));
507 dictionary* ptr = finder.dictPtr();
518 <<
"Entry '" << keyword
519 <<
"' is not a sub-dictionary in dictionary "
520 << relativeName() <<
nl
524 ptr = this->
set(keyword, dictionary())->dictPtr();
529 <<
"Failed to insert sub-dictionary '" << keyword
530 <<
"' in dictionary "
531 << relativeName() <<
nl
546 const const_searcher finder(csearch(keyword, matchOpt));
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;
582 const const_searcher finder(csearch(keyword, matchOpt));
587 return finder.dict();
593 <<
"Entry '" << keyword
594 <<
"' found but not a sub-dictionary in dictionary "
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))
671 if (entryPtr->keyword().isPattern())
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))
699 if (entryPtr->keyword().isPattern())
701 patterns_.insert(entryPtr);
710 <<
"Attempt to add entry " << entryPtr->keyword()
711 <<
" which already exists in dictionary "
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;
824 for (
const entry&
e :
dict)
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_);
896 add(
e.clone(*this).ptr());
906 <<
"Attempted addition to self, for dictionary "
907 << relativeName() <<
nl
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());
959 const dictionary& dict1,
960 const dictionary& dict2
971 const dictionary& dict1,
972 const dictionary& dict2
975 dictionary result(dict1);
A keyword and a list of tokens is an 'entry'.
static autoPtr< T > New(Args &&... args)
A keyword and a list of tokens is a 'dictionaryEntry'.
void set(List< bool > &bools, const labelRange &range)
const fileName & name() const noexcept
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
A class for handling file names.
static refPtr< OSstream > reportingOutput
void resize(const label len)
void checkITstream(const ITstream &is, const word &keyword) const
virtual bool isDict() const noexcept
void operator|=(const dictionary &rhs)
label lineNumber() const noexcept
const keyType & keyword() const noexcept
Ostream & endl(Ostream &os)
A token holds an item read from Istream.
A class for handling character strings derived from std::string.
entry * set(entry *entryPtr)
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
void operator+=(const dictionary &rhs)
dictionary & subDictOrAdd(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
bool substituteKeyword(const word &keyword, bool mergeEntry=false)
void transfer(dictionary &dict)
static const dictionary null
List< word > wordList
A List of words.
int infoSwitch(const char *name, const int deflt=0)
List< keyType > keys(bool patterns=false) const
A class for handling keywords in dictionaries.
void operator<<=(const dictionary &rhs)
bool merge(const dictionary &dict)
An input stream of tokens.
fileName relativeName(const bool caseTag=false) const
label startLineNumber() const
const dictionary & subDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
label endLineNumber() const
static fileName envRelativePath(const fileName &input, const bool caseTag=false)
Generic output stream using a standard (STL) stream.
dict_pointer dictPtr() const noexcept
dict_reference dict() const
const dictionary & topDict() const
An 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
static int writeOptionalEntries
bool good() const noexcept
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
virtual const fileName & name() const =0
errorManipArg< error, int > exit(error &err, const int errNo=1)
static word envExecutable()
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
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)
const dimensionedScalar e
autoPtr< dictionary > clone() const
@ REGEX
Regular expression.
fileName search(const word &file, const fileName &directory)
static fileName concat(const std::string &s1, const std::string &s2, const char delim='/')
bool substituteScopedKeyword(const word &keyword, bool mergeEntry=false)
const dictionary & optionalSubDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
word name(const expressions::valueTypeCode typeCode)
entry * add(entry *entryPtr, bool mergeEntry=false)
#define FatalIOErrorInFunction(ios)
SHA1Digest digest() const
#define IOWarningInFunction(ios)
label nRemainingTokens() const noexcept
bool isDict() const noexcept
defineTypeNameAndDebug(combustionModel, 0)
wordList sortedToc() const
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
registerInfoSwitch("writeOptionalEntries", int, Foam::dictionary::writeOptionalEntries)