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
358 <<
"Entry '" << keyword <<
"' with invalid input" <<
nl
369 return csearch(keyword, matchOpt).good();
379 return search(keyword, matchOpt).ptr();
389 return csearch(keyword, matchOpt).ptr();
399 return csearchScoped(keyword, matchOpt).ptr();
414 <<
"Entry '" << keyword <<
"' not found in dictionary "
429 return lookupEntry(keyword, matchOpt).stream();
439 if (keyword.size() < 2)
445 const word varName(keyword.substr(1),
false);
453 for (
const entry&
e : finder.dict())
471 if (keyword.size() < 2)
477 const word varName(keyword.substr(1),
false);
485 for (
const entry&
e : finder.dict())
503 return csearch(keyword, matchOpt).isDict();
513 return search(keyword, matchOpt).dictPtr();
523 return csearch(keyword, matchOpt).dictPtr();
538 <<
"Entry '" << keyword <<
"' not found in dictionary "
543 return finder.
dict();
558 <<
"Entry '" << keyword <<
"' not found in dictionary "
563 return finder.
dict();
586 <<
"Entry '" << keyword
587 <<
"' is not a sub-dictionary in dictionary "
597 <<
"Failed to insert sub-dictionary '" << keyword
598 <<
"' in dictionary "
619 return finder.
dict();
625 <<
"Entry '" << keyword
626 <<
"' is not a sub-dictionary in dictionary "
634 <<
"Entry '" << keyword
635 <<
"' found but not a sub-dictionary in dictionary "
655 return finder.
dict();
661 <<
"Entry '" << keyword
662 <<
"' found but not a sub-dictionary in dictionary "
675 for (
const entry&
e : *
this)
677 list[
n++] =
e.keyword();
686 return hashedEntries_.sortedToc();
695 for (
const entry&
e : *
this)
697 if (
e.keyword().isPattern() ? patterns : !patterns)
699 list[
n++] =
e.keyword();
715 auto iter = hashedEntries_.find(entryPtr->
keyword());
717 if (mergeEntry && iter.good())
720 if (iter()->isDict() && entryPtr->
isDict())
730 parent_type::replace(iter(), entryPtr);
732 hashedEntries_.erase(iter);
734 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
741 patterns_.insert(entryPtr);
750 <<
"Problem replacing entry "<< entryPtr->
keyword()
751 <<
" in dictionary " <<
name() <<
endl;
753 parent_type::remove(entryPtr);
760 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
769 patterns_.insert(entryPtr);
778 <<
"Attempt to add entry " << entryPtr->
keyword()
779 <<
" which already exists in dictionary " <<
name() <<
endl;
788 return add(
e.clone(*this).ptr(), mergeEntry);
860 finder.
dict().clear();
863 return add(entryPtr,
true);
869 return set(
e.clone(*this).ptr());
884 <<
"Attempted merge to self, for dictionary "
889 bool changed =
false;
893 auto fnd = hashedEntries_.find(
e.keyword());
899 if (fnd()->isDict() &&
e.isDict())
901 if (fnd()->dict().merge(
e.dict()))
908 add(
e.clone(*this).ptr(),
true);
915 add(
e.clone(*this).ptr());
927 hashedEntries_.clear();
939 parent_type::transfer(
dict);
940 hashedEntries_.transfer(
dict.hashedEntries_);
941 patterns_.transfer(
dict.patterns_);
942 regexps_.transfer(
dict.regexps_);
961 for (
const entry&
e : rhs)
963 add(
e.clone(*this).ptr());
973 <<
"Attempted addition to self, for dictionary "
978 for (
const entry&
e : rhs)
980 add(
e.clone(*this).ptr());
990 <<
"Attempted |= merging to self, for dictionary "
995 for (
const entry&
e : rhs)
999 add(
e.clone(*this).ptr());
1010 <<
"Attempted addition to self, for dictionary "
1015 for (
const entry&
e : rhs)
1017 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'.
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.
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()
Default construct, a top-level empty dictionary.
label nRemainingTokens() const
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.
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.
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.
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.
Generic output stream using a standard (STL) stream.
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.
#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.