Go to the documentation of this file.
56 "writeOptionalEntries",
64 Foam::fileName Foam::dictionary::relativeName(
const bool caseTag)
const
107 hashedEntries_.insert(
e.keyword(), &
e);
109 if (
e.keyword().isPattern())
111 patterns_.insert(&
e);
129 hashedEntries_.insert(
e.keyword(), &
e);
131 if (
e.keyword().isPattern())
133 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;
298 <<
"file: " << this->
name()
318 <<
"Entry '" << keyword
319 <<
"' had no tokens in stream" <<
nl <<
nl
326 <<
"--> FOAM FATAL IO ERROR:" <<
nl
327 <<
"Entry '" << keyword
328 <<
"' had no tokens in stream" <<
nl <<
nl;
331 <<
"file: " << this->
name()
341 void Foam::dictionary::raiseBadInput(
const word& keyword)
const
352 <<
"Entry '" << keyword <<
"' with invalid input in dictionary "
364 return csearch(keyword, matchOpt).good();
374 return search(keyword, matchOpt).ptr();
384 return csearch(keyword, matchOpt).ptr();
394 return csearchScoped(keyword, matchOpt).ptr();
409 <<
"Entry '" << keyword <<
"' not found in dictionary "
424 return lookupEntry(keyword, matchOpt).stream();
434 if (keyword.size() < 2)
440 const word varName(keyword.substr(1),
false);
448 for (
const entry&
e : finder.dict())
466 if (keyword.size() < 2)
472 const word varName(keyword.substr(1),
false);
480 for (
const entry&
e : finder.dict())
498 return csearch(keyword, matchOpt).isDict();
508 return search(keyword, matchOpt).dictPtr();
518 return csearch(keyword, matchOpt).dictPtr();
533 <<
"Entry '" << keyword <<
"' not found in dictionary "
538 return finder.
dict();
553 <<
"Entry '" << keyword <<
"' not found in dictionary "
558 return finder.
dict();
581 <<
"Entry '" << keyword
582 <<
"' is not a sub-dictionary in dictionary "
587 ptr = this->set(keyword,
dictionary())->dictPtr();
592 <<
"Failed to insert sub-dictionary '" << keyword
593 <<
"' in dictionary "
614 return finder.
dict();
620 <<
"Entry '" << keyword
621 <<
"' is not a sub-dictionary in dictionary "
629 <<
"Entry '" << keyword
630 <<
"' found but not a sub-dictionary in dictionary "
650 return finder.
dict();
656 <<
"Entry '" << keyword
657 <<
"' found but not a sub-dictionary in dictionary "
670 for (
const entry&
e : *
this)
672 list[
n++] =
e.keyword();
681 return hashedEntries_.sortedToc();
690 for (
const entry&
e : *
this)
692 if (
e.keyword().isPattern() ? patterns : !patterns)
694 list[
n++] =
e.keyword();
710 auto iter = hashedEntries_.find(entryPtr->
keyword());
712 if (mergeEntry && iter.good())
715 if (iter()->isDict() && entryPtr->
isDict())
725 parent_type::replace(iter(), entryPtr);
727 hashedEntries_.erase(iter);
729 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
736 patterns_.insert(entryPtr);
745 <<
"Problem replacing entry "<< entryPtr->
keyword()
746 <<
" in dictionary " <<
name() <<
endl;
748 parent_type::remove(entryPtr);
755 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
764 patterns_.insert(entryPtr);
773 <<
"Attempt to add entry " << entryPtr->
keyword()
774 <<
" which already exists in dictionary " <<
name() <<
endl;
783 return add(
e.clone(*this).ptr(), mergeEntry);
855 finder.
dict().clear();
858 return add(entryPtr,
true);
864 return set(
e.clone(*this).ptr());
879 <<
"Attempted merge to self, for dictionary "
884 bool changed =
false;
888 auto fnd = hashedEntries_.find(
e.keyword());
894 if (fnd()->isDict() &&
e.isDict())
896 if (fnd()->dict().merge(
e.dict()))
903 add(
e.clone(*this).ptr(),
true);
910 add(
e.clone(*this).ptr());
922 hashedEntries_.clear();
934 parent_type::transfer(
dict);
935 hashedEntries_.transfer(
dict.hashedEntries_);
936 patterns_.transfer(
dict.patterns_);
937 regexps_.transfer(
dict.regexps_);
956 for (
const entry&
e : rhs)
958 add(
e.clone(*this).ptr());
968 <<
"Attempted addition to self, for dictionary "
973 for (
const entry&
e : rhs)
975 add(
e.clone(*this).ptr());
985 <<
"Attempted |= merging to self, for dictionary "
990 for (
const entry&
e : rhs)
994 add(
e.clone(*this).ptr());
1005 <<
"Attempted addition to self, for dictionary "
1010 for (
const entry&
e : rhs)
1012 set(
e.clone(*this).ptr());
A keyword and a list of tokens is an 'entry'.
dictionary * findDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find and return a sub-dictionary pointer if present.
static autoPtr< T > New(Args &&... args)
Construct autoPtr of T with forwarding arguments.
A keyword and a list of tokens is a 'dictionaryEntry'.
A keyword and a list of tokens comprise a primitiveEntry. A primitiveEntry can be read,...
A class for handling words, derived from Foam::string.
dict_pointer dictPtr() const
Pointer to the found entry as a dictionary or nullptr otherwise.
A class for handling file names.
const keyType & keyword() const
Return keyword.
static fileName envGlobalPath()
Global case (directory) from environment variable.
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
bool isPattern() const
The keyType is treated as a pattern, not as literal string.
void checkITstream(const ITstream &is, const word &keyword) const
dictionary()
Construct top-level dictionary null.
label nRemainingTokens() const
Return the number of remaining tokens.
void operator|=(const dictionary &rhs)
Conditionally include entries from the given dictionary.
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.
const entry & lookupEntry(const word &keyword, enum keyType::option matchOpt) const
Search for an entry (const access) with the given keyword.
fileName relative(const fileName &parent, const bool caseTag=false) const
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.
const fileName & name() const
The dictionary name.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
virtual bool isDict() const
Return true if this entry is a dictionary.
An input stream of tokens.
word name(const complex &c)
Return string representation of complex.
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.
bool good() const
True if entry was found.
dict_reference dict() const
Reference the found entry as a dictionary.
const dictionary & topDict() const
Return the top of the tree.
void resize(const label newSize)
Adjust allocated size of list.
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)
static tokenList parse(const UList< char > &input, streamFormat format=ASCII)
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.
dictionary subOrEmptyDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX, const bool mandatory=false) const
virtual const fileName & name() const =0
Return the dictionary name.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool isDict(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Check if entry is found and is a sub-dictionary.
Foam::string str() const
Get the string - as Foam::string rather than std::string.
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
const entry * findScoped(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for a scoped entry (const access) with the given keyword.
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.
void operator=(const dictionary &rhs)
Copy assignment.
entry * findEntry(const word &keyword, enum keyType::option matchOpt=keyType::REGEX)
Find for an entry (non-const access) with the given keyword.
label k
Boltzmann constant.
const dimensionedScalar e
Elementary charge.
autoPtr< dictionary > clone() const
Construct and return clone.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
fileName search(const word &file, const fileName &directory)
Recursively search the given directory for the file.
bool isDict() const
True if found entry is a dictionary.
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.
label lineNumber() const
Const access to the current stream line number.
entry * add(entry *entryPtr, bool mergeEntry=false)
Add a new entry.
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.
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.
defineTypeNameAndDebug(combustionModel, 0)
void clear()
Clear the dictionary.
wordList sortedToc() const
Return the sorted table of contents.
reference ref() const
A reference to the entry (Error if not found)
static bool isAbsolute(const std::string &str)
Return true if string starts with a '/'.
registerInfoSwitch("writeOptionalEntries", int, Foam::dictionary::writeOptionalEntries)
option
Enumeration for the data type and search/match modes (bitmask)
SHA1Digest digest()
Return SHA1::Digest for the data processed until now.