40 bool dictionary::writeOptionalEntries
49 const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
58 if (dotPos == string::npos)
61 return lookupEntryPtr(keyword, recursive, patternMatch);
69 const dictionary* dictPtr =
this;
72 string::const_iterator iter = keyword.begin() + begVar;
74 while (iter != keyword.end() && *iter ==
'.')
80 if (&dictPtr->parent_ == &dictionary::null)
85 ) <<
"No parent of current dictionary" 86 <<
" when searching for " 87 << keyword.substr(begVar, keyword.size()-begVar)
90 dictPtr = &dictPtr->parent_;
93 return dictPtr->lookupScopedSubEntryPtr
95 keyword.substr(endVar),
103 word firstWord = keyword.substr(0, dotPos);
105 const entry* entPtr = lookupScopedSubEntryPtr
126 const entry* subEntPtr = lookupEntryPtr
128 keyword.substr(0, nextDotPos),
132 if (nextDotPos == string::npos)
138 if (subEntPtr && subEntPtr->isDict())
140 return subEntPtr->dict().lookupScopedSubEntryPtr
145 keyword.size()-nextDotPos
152 nextDotPos = keyword.find(
'.', nextDotPos+1);
156 if (entPtr->isDict())
158 return entPtr->dict().lookupScopedSubEntryPtr
160 keyword.substr(dotPos, keyword.size()-dotPos),
174 bool Foam::dictionary::findInPatterns
176 const bool patternMatch,
179 DLList<autoPtr<regExp>>::const_iterator& reLink
182 if (patternEntries_.size())
184 while (wcLink != patternEntries_.end())
189 ? reLink()->match(Keyword)
190 : wcLink()->keyword() == Keyword
205 bool Foam::dictionary::findInPatterns
207 const bool patternMatch,
210 DLList<autoPtr<regExp>>::iterator& reLink
213 if (patternEntries_.size())
215 while (wcLink != patternEntries_.end())
220 ? reLink()->match(Keyword)
221 : wcLink()->keyword() == Keyword
263 hashedEntries_.insert(iter().keyword(), &iter());
265 if (iter().keyword().isPattern())
267 patternEntries_.insert(&iter());
268 patternRegexps_.insert
284 parent_(dictionary::null)
288 hashedEntries_.insert(iter().keyword(), &iter());
290 if (iter().keyword().isPattern())
292 patternEntries_.insert(&iter());
293 patternRegexps_.insert
307 parent_(dictionary::null)
334 parent_(dictionary::null)
360 if (&p !=
this && !p.
name().empty())
375 return first()->startLineNumber();
388 return last()->endLineNumber();
437 if (hashedEntries_.found(keyword))
443 if (patternMatch && patternEntries_.size())
446 patternEntries_.begin();
448 patternRegexps_.begin();
451 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
457 if (recursive && &parent_ != &dictionary::null)
459 return parent_.
found(keyword, recursive, patternMatch);
478 if (iter == hashedEntries_.end())
480 if (patternMatch && patternEntries_.size())
483 patternEntries_.begin();
485 patternRegexps_.begin();
488 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
494 if (recursive && &parent_ != &dictionary::null)
517 if (iter == hashedEntries_.end())
519 if (patternMatch && patternEntries_.size())
522 patternEntries_.begin();
524 patternRegexps_.begin();
527 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
533 if (recursive && &parent_ != &dictionary::null)
561 if (entryPtr ==
nullptr)
566 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 593 if (keyword[0] ==
':')
597 while (&dictPtr->parent_ != &dictionary::null)
599 dictPtr = &dictPtr->parent_;
603 return dictPtr->lookupScopedSubEntryPtr
605 keyword.substr(1, keyword.size()-1),
612 return lookupScopedSubEntryPtr
624 word varName = keyword(1, keyword.size()-1);
653 return entryPtr->
isDict();
668 return &entryPtr->
dict();
683 return &entryPtr->
dict();
696 if (entryPtr ==
nullptr)
701 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 705 return entryPtr->
dict();
713 if (entryPtr ==
nullptr)
718 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 722 return entryPtr->
dict();
734 if (entryPtr ==
nullptr)
741 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 744 return entryPtr->
dict();
753 return entryPtr->
dict();
767 return entryPtr->
dict();
783 keys[nKeys++] = iter().keyword();
792 return hashedEntries_.sortedToc();
803 if (iter().keyword().isPattern() ? patterns : !patterns)
805 keys[nKeys++] = iter().keyword();
821 if (mergeEntry && iter != hashedEntries_.end())
824 if (iter()->isDict() && entryPtr->
isDict())
826 iter()->dict().merge(entryPtr->
dict());
836 hashedEntries_.erase(iter);
838 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
844 patternEntries_.insert(entryPtr);
845 patternRegexps_.insert
856 <<
"problem replacing entry "<< entryPtr->
keyword()
857 <<
" in dictionary " <<
name() <<
endl;
866 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
873 patternEntries_.insert(entryPtr);
874 patternRegexps_.insert
885 <<
"attempt to add entry "<< entryPtr->
keyword()
886 <<
" which already exists in dictionary " <<
name()
897 add(e.
clone(*this).ptr(), mergeEntry);
946 if (existingPtr && existingPtr->
isDict())
956 set(e.
clone(*this).ptr());
970 if (iter != hashedEntries_.end())
974 patternEntries_.begin();
976 patternRegexps_.begin();
979 if (findInPatterns(
false, Keyword, wcLink, reLink))
981 patternEntries_.remove(wcLink);
982 patternRegexps_.remove(reLink);
987 hashedEntries_.erase(iter);
1006 if (oldKeyword == newKeyword)
1014 if (iter == hashedEntries_.end())
1019 if (iter()->keyword().isPattern())
1024 ) <<
"Old keyword "<< oldKeyword
1026 <<
"Pattern replacement not yet implemented." 1034 if (iter2 != hashedEntries_.end())
1038 if (iter2()->keyword().isPattern())
1042 patternEntries_.begin();
1044 patternRegexps_.begin();
1047 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
1049 patternEntries_.remove(wcLink);
1050 patternRegexps_.remove(reLink);
1056 hashedEntries_.erase(iter2);
1064 ) <<
"cannot rename keyword "<< oldKeyword
1065 <<
" to existing keyword " << newKeyword
1066 <<
" in dictionary " <<
name() <<
endl;
1072 iter()->keyword() = newKeyword;
1073 iter()->name() =
name() +
'.' + newKeyword;
1074 hashedEntries_.erase(oldKeyword);
1075 hashedEntries_.insert(newKeyword, iter());
1079 patternEntries_.insert(iter());
1080 patternRegexps_.insert
1096 <<
"attempted merge to self for dictionary " <<
name()
1100 bool changed =
false;
1106 if (fnd != hashedEntries_.end())
1110 if (fnd()->isDict() && iter().isDict())
1112 if (fnd()->dict().merge(iter().
dict()))
1119 add(iter().
clone(*this).ptr(),
true);
1138 hashedEntries_.clear();
1139 patternEntries_.clear();
1140 patternRegexps_.clear();
1151 hashedEntries_.transfer(dict.hashedEntries_);
1152 patternEntries_.transfer(dict.patternEntries_);
1153 patternRegexps_.transfer(dict.patternRegexps_);
1177 <<
"attempted assignment to self for dictionary " <<
name()
1200 <<
"attempted addition assignment to self for dictionary " <<
name()
1217 <<
"attempted assignment to self for dictionary " <<
name()
1223 if (!
found(iter().keyword()))
1237 <<
"attempted assignment to self for dictionary " <<
name()
1243 set(iter().clone(*this).ptr());
Template class for intrusive linked lists.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
A class for handling keywords in dictionaries.
A simple container for copying or transferring objects of type <T>.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
bool remove(const word &)
Remove an entry specified by keyword.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
A class for handling file names.
label endLineNumber() const
Return line number of last token in dictionary.
void operator=(const dictionary &)
tokenList tokens() const
Return the dictionary as a list of tokens.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
const keyType & keyword() const
Return keyword.
An STL-conforming const_iterator.
Wrapper around POSIX extended regular expressions.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void operator+=(const dictionary &)
Include entries from the given dictionary.
List< token > tokenList
List of tokens, used for a IOdictionary entry.
A list of keyword definitions, which are a keyword followed by any number of values (e...
void transfer(ILList< LListBase, T > &)
Transfer the contents of the argument into this List.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Template class for non-intrusive linked lists.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
dictionaryName()
Construct dictionaryName null.
static const dictionary null
Null dictionary.
An STL-conforming const_iterator.
A token holds items read from Istream.
Ostream & endl(Ostream &os)
Add newline and flush stream.
An STL-conforming iterator.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
The output stream for calculating SHA1 digests.
T * last()
Return the last entry.
A keyword and a list of tokens is a 'dictionaryEntry'.
void transfer(dictionary &)
Transfer the contents of the argument and annul the argument.
autoPtr< dictionary > clone() const
Construct and return clone.
An STL-conforming const_iterator.
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
wordList toc() const
Return the table of contents.
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read, written and printed, and the types and values of its tokens analysed.
dictionary()
Construct top-level dictionary null.
An STL-conforming iterator.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool forceOverwrite=false)
Change the keyword for an entry,.
void operator<<=(const dictionary &)
Unconditionally include entries from the given dictionary.
const fileName & name() const
Return the dictionary name.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
A class for handling words, derived from string.
const dictionary & parent() const
Return the parent dictionary.
void clear()
Clear the contents of the list.
An STL-conforming iterator.
const dictionary & topDict() const
Return the top of the tree.
T * remove(T *p)
Remove and return element.
graph_traits< Graph >::vertices_size_type size_type
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
errorManip< error > abort(error &err)
Xfer< dictionary > xfer()
Transfer contents to the Xfer container.
rAUs append(new volScalarField(IOobject::groupName("rAU", phase1.name()), 1.0/(U1Eqn.A()+byDt(max(phase1.residualAlpha() - alpha1, scalar(0)) *rho1))))
const dictionary * subDictPtr(const word &) const
Find and return a sub-dictionary pointer if present.
virtual bool isDict() const
Return true if this entry is a dictionary.
defineTypeNameAndDebug(combustionModel, 0)
LList< DLListBase, T > DLList
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
friend class const_iterator
void setSize(const label)
Reset size of List.
void operator|=(const dictionary &)
Conditionally include entries from the given dictionary.
ITstream & operator[](const word &) const
Find and return entry.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Input from memory buffer stream.
string str() const
Return the string.
virtual const fileName & name() const =0
Return the dictionary name.
virtual ~dictionary()
Destructor.
void set(entry *)
Assign a new entry, overwrite any existing entry.
bool substituteScopedKeyword(const word &keyword)
Substitute the given scoped keyword prepended by '$' with the.
bool merge(const dictionary &)
Merge entries from the given dictionary.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
const doubleScalar e
Elementary charge.
T * first()
Return the first entry.
void clear()
Clear the dictionary.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
A class for handling character strings derived from std::string.
Output to memory buffer stream.
label startLineNumber() const
Return line number of first token in dictionary.
wordList sortedToc() const
Return the sorted table of contents.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
Foam::SHA1Digest digest()
Return SHA1::Digest for the data processed until now.
A keyword and a list of tokens is an 'entry'.
bool isPattern() const
Should be treated as a match rather than a literal string.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.