59 "writeOptionalEntries",
95 parent_type(
dict, *this),
101 hashedEntries_.insert(
e.keyword(), &
e);
103 if (
e.keyword().isPattern())
105 patterns_.prepend(&
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_.prepend(&
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 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())
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* dictPtr = finder.dictPtr();
518 <<
"Entry '" << keyword
519 <<
"' is not a sub-dictionary in dictionary " 520 << relativeName() <<
nl 524 dictPtr = 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));
548 const dictionary* dictPtr = finder.dictPtr();
559 <<
"Entry '" << keyword
560 <<
"' is not a sub-dictionary in dictionary " 561 << relativeName() <<
nl 568 <<
"Entry '" << keyword
569 <<
"' found but not a sub-dictionary in dictionary " 570 << relativeName() <<
endl;
584 const const_searcher finder(csearch(keyword, matchOpt));
597 <<
"Entry '" << keyword
598 <<
"' found but not a sub-dictionary in dictionary " 611 for (
const entry&
e : *
this)
613 list[
n++] =
e.keyword();
622 return hashedEntries_.sortedToc();
631 for (
const entry&
e : *
this)
633 if (
e.keyword().isPattern() ? patterns : !patterns)
635 list[
n++] =
e.keyword();
651 auto iter = hashedEntries_.find(entryPtr->keyword());
653 if (mergeEntry && iter.good())
656 if (iter()->isDict() && entryPtr->isDict())
666 parent_type::replace(iter(), entryPtr);
668 hashedEntries_.erase(iter);
670 if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
675 if (entryPtr->keyword().isPattern())
677 patterns_.prepend(entryPtr);
686 <<
"Problem replacing entry "<< entryPtr->keyword()
687 <<
" in dictionary " << relativeName() <<
endl;
689 parent_type::remove(entryPtr);
696 if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
703 if (entryPtr->keyword().isPattern())
705 patterns_.prepend(entryPtr);
714 <<
"Attempt to add entry " << entryPtr->keyword()
715 <<
" which already exists in dictionary " 725 return add(
e.clone(*this).ptr(), mergeEntry);
794 dictionary* dictPtr = finder.dictPtr();
802 return add(entryPtr,
true);
808 return set(
e.clone(*this).ptr());
823 <<
"Attempted merge to self, for dictionary " 824 << relativeName() <<
nl 828 bool changed =
false;
830 for (
const entry&
e :
dict)
832 auto fnd = hashedEntries_.find(
e.keyword());
838 if (fnd()->isDict() &&
e.isDict())
840 if (fnd()->dict().merge(
e.dict()))
847 add(
e.clone(*this).ptr(),
true);
854 add(
e.clone(*this).ptr());
866 hashedEntries_.clear();
878 parent_type::transfer(
dict);
879 hashedEntries_.transfer(
dict.hashedEntries_);
880 patterns_.transfer(
dict.patterns_);
881 regexps_.transfer(
dict.regexps_);
902 add(
e.clone(*this).ptr());
912 <<
"Attempted addition to self, for dictionary " 913 << relativeName() <<
nl 919 add(
e.clone(*this).ptr());
929 <<
"Attempted |= merging to self, for dictionary " 930 << relativeName() <<
nl 934 for (
const entry&
e : rhs)
938 add(
e.clone(*this).ptr());
949 <<
"Attempted addition to self, for dictionary " 950 << relativeName() <<
nl 954 for (
const entry&
e : rhs)
956 set(
e.clone(*this).ptr());
965 const dictionary& dict1,
966 const dictionary& dict2
977 const dictionary& dict1,
978 const dictionary& dict2
981 dictionary result(dict1);
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. ...
Generic output stream using a standard (STL) 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.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
label k
Boltzmann constant.
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.
static tokenList parse(const UList< char > &input, IOstreamOption streamOpt=IOstreamOption())
Create token list by parsing the input character sequence until no good tokens remain.
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 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 word envExecutable()
Name of the executable from environment variable.
List< word > wordList
A List of words.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
#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 ...