40 bool dictionary::writeOptionalEntries
49 bool Foam::dictionary::findInPatterns
51 const bool patternMatch,
54 DLList<autoPtr<regExp>>::const_iterator& reLink
57 if (patternEntries_.size())
59 while (wcLink != patternEntries_.end())
64 ? reLink()->match(Keyword)
65 : wcLink()->keyword() == Keyword
80 bool Foam::dictionary::findInPatterns
82 const bool patternMatch,
85 DLList<autoPtr<regExp>>::iterator& reLink
88 if (patternEntries_.size())
90 while (wcLink != patternEntries_.end())
95 ? reLink()->match(Keyword)
96 : wcLink()->keyword() == Keyword
138 hashedEntries_.insert(iter().keyword(), &iter());
140 if (iter().keyword().isPattern())
142 patternEntries_.insert(&iter());
143 patternRegexps_.insert
159 parent_(dictionary::null)
163 hashedEntries_.insert(iter().keyword(), &iter());
165 if (iter().keyword().isPattern())
167 patternEntries_.insert(&iter());
168 patternRegexps_.insert
182 parent_(dictionary::null)
209 parent_(dictionary::null)
235 if (&p !=
this && !p.
name().empty())
312 if (hashedEntries_.found(keyword))
318 if (patternMatch && patternEntries_.size())
321 patternEntries_.begin();
323 patternRegexps_.begin();
326 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
332 if (recursive && &parent_ != &dictionary::null)
334 return parent_.
found(keyword, recursive, patternMatch);
353 if (iter == hashedEntries_.end())
355 if (patternMatch && patternEntries_.size())
358 patternEntries_.begin();
360 patternRegexps_.begin();
363 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
369 if (recursive && &parent_ != &dictionary::null)
392 if (iter == hashedEntries_.end())
394 if (patternMatch && patternEntries_.size())
397 patternEntries_.begin();
399 patternRegexps_.begin();
402 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
408 if (recursive && &parent_ != &dictionary::null)
436 if (entryPtr == NULL)
441 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 468 if (keyword[0] ==
':')
472 while (&dictPtr->parent_ != &dictionary::null)
474 dictPtr = &dictPtr->parent_;
480 keyword.substr(1, keyword.size()-1),
489 if (dotPos == string::npos)
503 string::const_iterator iter = keyword.begin() + begVar;
507 iter != keyword.end()
515 if (&dictPtr->parent_ == &dictionary::null)
520 ) <<
"No parent of current dictionary" 521 <<
" when searching for " 522 << keyword.substr(begVar, keyword.size()-begVar)
525 dictPtr = &dictPtr->parent_;
530 keyword.substr(endVar),
538 word firstWord = keyword.substr(0, dotPos);
552 ) <<
"keyword " << firstWord
553 <<
" is undefined in dictionary " 555 <<
"Valid keywords are " <<
keys()
563 keyword.substr(dotPos, keyword.size()-dotPos),
580 word varName = keyword(1, keyword.size()-1);
609 return entryPtr->
isDict();
624 return &entryPtr->
dict();
637 if (entryPtr == NULL)
642 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 646 return entryPtr->
dict();
654 if (entryPtr == NULL)
659 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 663 return entryPtr->
dict();
675 if (entryPtr == NULL)
682 ) <<
"keyword " << keyword <<
" is undefined in dictionary " 685 return entryPtr->
dict();
694 return entryPtr->
dict();
706 keys[nKeys++] = iter().keyword();
715 return hashedEntries_.sortedToc();
726 if (iter().keyword().isPattern() ? patterns : !patterns)
728 keys[nKeys++] = iter().keyword();
744 if (mergeEntry && iter != hashedEntries_.end())
747 if (iter()->isDict() && entryPtr->
isDict())
749 iter()->dict().merge(entryPtr->
dict());
759 hashedEntries_.erase(iter);
761 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
767 patternEntries_.insert(entryPtr);
768 patternRegexps_.insert
779 <<
"problem replacing entry "<< entryPtr->
keyword()
780 <<
" in dictionary " <<
name() <<
endl;
789 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
796 patternEntries_.insert(entryPtr);
797 patternRegexps_.insert
808 <<
"attempt to add entry "<< entryPtr->
keyword()
809 <<
" which already exists in dictionary " <<
name()
820 add(e.
clone(*this).ptr(), mergeEntry);
869 if (existingPtr && existingPtr->
isDict())
879 set(e.
clone(*this).ptr());
893 if (iter != hashedEntries_.end())
897 patternEntries_.begin();
899 patternRegexps_.begin();
902 if (findInPatterns(
false, Keyword, wcLink, reLink))
904 patternEntries_.remove(wcLink);
905 patternRegexps_.remove(reLink);
910 hashedEntries_.erase(iter);
929 if (oldKeyword == newKeyword)
937 if (iter == hashedEntries_.end())
942 if (iter()->keyword().isPattern())
947 ) <<
"Old keyword "<< oldKeyword
949 <<
"Pattern replacement not yet implemented." 957 if (iter2 != hashedEntries_.end())
961 if (iter2()->keyword().isPattern())
965 patternEntries_.begin();
967 patternRegexps_.begin();
970 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
972 patternEntries_.remove(wcLink);
973 patternRegexps_.remove(reLink);
979 hashedEntries_.erase(iter2);
987 ) <<
"cannot rename keyword "<< oldKeyword
988 <<
" to existing keyword " << newKeyword
989 <<
" in dictionary " <<
name() <<
endl;
995 iter()->keyword() = newKeyword;
996 iter()->name() =
name() +
'.' + newKeyword;
997 hashedEntries_.erase(oldKeyword);
998 hashedEntries_.insert(newKeyword, iter());
1002 patternEntries_.insert(iter());
1003 patternRegexps_.insert
1019 <<
"attempted merge to self for dictionary " <<
name()
1023 bool changed =
false;
1029 if (fnd != hashedEntries_.end())
1033 if (fnd()->isDict() && iter().isDict())
1035 if (fnd()->dict().merge(iter().
dict()))
1042 add(iter().
clone(*this).ptr(),
true);
1061 hashedEntries_.clear();
1062 patternEntries_.clear();
1063 patternRegexps_.clear();
1074 hashedEntries_.transfer(dict.hashedEntries_);
1075 patternEntries_.transfer(dict.patternEntries_);
1076 patternRegexps_.transfer(dict.patternRegexps_);
1100 <<
"attempted assignment to self for dictionary " <<
name()
1123 <<
"attempted addition assignment to self for dictionary " <<
name()
1140 <<
"attempted assignment to self for dictionary " <<
name()
1146 if (!
found(iter().keyword()))
1160 <<
"attempted assignment to self for dictionary " <<
name()
1166 set(iter().clone(*this).ptr());
A class for handling keywords in dictionaries.
A simple container for copying or transferring objects of type <T>.
string str() const
Return the string.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
wordList toc() const
Return the table of contents.
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.
void operator=(const dictionary &)
An STL-conforming const_iterator.
Wrapper around POSIX extended regular expressions.
errorManipArg< error, int > exit(error &err, const int errNo=1)
void operator+=(const dictionary &)
Include entries from the given dictionary.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
const double e
Elementary charge.
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< DLListBase, 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...
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
#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.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
virtual label startLineNumber() const =0
Return line number of first token in dictionary.
A token holds items read from Istream.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
Ostream & endl(Ostream &os)
Add newline and flush stream.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
const fileName & name() const
Return the dictionary name.
link * replace(link *oldLink, link *newLink)
Replace oldLink with newLink and return element.
The output stream for calculating SHA1 digests.
label size() const
Return number of elements in list.
entry * last()
Return the last entry.
label endLineNumber() const
Return line number of last token in dictionary.
A keyword and a list of tokens is a 'dictionaryEntry'.
void transfer(dictionary &)
Transfer the contents of the argument and annul the argument.
tokenList tokens() const
Return the dictionary as a list of tokens.
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
autoPtr< dictionary > clone() const
Construct and return clone.
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,.
ITstream & operator[](const word &) const
Find and return entry.
wordList sortedToc() const
Return the sorted table of contents.
void operator<<=(const dictionary &)
Unconditionally include entries from the given dictionary.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects...
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
A class for handling words, derived from string.
const keyType & keyword() const
Return keyword.
void clear()
Clear the contents of the list.
label startLineNumber() const
Return line number of first token in dictionary.
An STL-conforming const_iterator.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
An STL-conforming iterator.
Non-intrusive doubly-linked list.
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.
void append(link *)
Add at tail of list.
defineTypeNameAndDebug(combustionModel, 0)
virtual label endLineNumber() const =0
Return line number of last token in dictionary.
friend class const_iterator
void setSize(const label)
Reset size of List.
void operator|=(const dictionary &)
Conditionally include entries from the given dictionary.
const dictionary * subDictPtr(const word &) const
Find and return a sub-dictionary pointer if present.
void write(Ostream &, const bool subDict=true) const
Write dictionary, normally with sub-dictionary formatting.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Input from memory buffer stream.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
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.
const dictionary & parent() const
Return the parent 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...
entry * first()
Return the first entry.
void clear()
Clear the dictionary.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
virtual ITstream & stream() const =0
Return token stream if this entry is a primitive entry.
const dictionary & topDict() const
Return the top of the tree.
A class for handling character strings derived from std::string.
Output to memory buffer stream.
virtual bool isDict() const
Return true if this entry is a dictionary.
bool isPattern() const
Should be treated as a match rather than a literal string.
Foam::SHA1Digest digest()
Return SHA1::Digest for the data processed until now.
A keyword and a list of tokens is an 'entry'.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.