53 const Foam::entry* Foam::dictionary::lookupDotScopedSubEntryPtr
62 if (dotPos == string::npos)
65 return lookupEntryPtr(keyword, recursive, patternMatch);
73 const dictionary* dictPtr =
this;
76 string::const_iterator iter = keyword.begin() + begVar;
78 while (iter != keyword.end() && *iter ==
'.')
87 <<
"No parent of current dictionary" 88 <<
" when searching for " 89 << keyword.substr(begVar, keyword.size() - begVar)
92 dictPtr = &dictPtr->parent_;
95 return dictPtr->lookupScopedSubEntryPtr
97 keyword.substr(endVar),
105 word firstWord = keyword.substr(0, dotPos);
107 const entry* entPtr = lookupDotScopedSubEntryPtr
128 const entry* subEntPtr = lookupEntryPtr
130 keyword.substr(0, nextDotPos),
134 if (nextDotPos == string::npos)
140 if (subEntPtr && subEntPtr->isDict())
142 return subEntPtr->dict().lookupDotScopedSubEntryPtr
147 keyword.size() - nextDotPos
154 nextDotPos = keyword.find(
'.', nextDotPos + 1);
158 if (entPtr->isDict())
160 return entPtr->dict().lookupDotScopedSubEntryPtr
162 keyword.substr(dotPos, keyword.size() - dotPos),
176 const Foam::entry* Foam::dictionary::lookupSlashScopedSubEntryPtr
185 if (slashPos == string::npos)
188 return lookupEntryPtr(keyword, recursive, patternMatch);
193 word firstWord = keyword.substr(0, slashPos);
196 if (firstWord ==
".")
198 return lookupScopedSubEntryPtr
200 keyword.substr(slashPos),
205 else if (firstWord ==
"..")
211 <<
"No parent of current dictionary" 212 <<
" when searching for " 213 << keyword.substr(slashPos, keyword.size() - slashPos)
217 return parent_.lookupScopedSubEntryPtr
219 keyword.substr(slashPos),
226 const entry* entPtr = lookupScopedSubEntryPtr
247 const entry* subEntPtr = lookupEntryPtr
249 keyword.substr(0, nextSlashPos),
254 if (nextSlashPos == string::npos)
262 if (subEntPtr && subEntPtr->isDict())
264 return subEntPtr->dict().lookupScopedSubEntryPtr
269 keyword.size() - nextSlashPos
276 nextSlashPos = keyword.find(
'/', nextSlashPos);
280 if (entPtr->isDict())
282 return entPtr->dict().lookupScopedSubEntryPtr
284 keyword.substr(slashPos, keyword.size() - slashPos),
298 const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
307 return lookupDotScopedSubEntryPtr(keyword, recursive, patternMatch);
314 if (emarkPos == string::npos || emarkPos == 0)
318 return lookupSlashScopedSubEntryPtr
330 fileName fName = keyword.substr(0, emarkPos);
332 if (!fName.isAbsolute())
334 fName = topDict().name().path()/fName;
337 if (fName == topDict().
name())
340 <<
"Attempt to re-read current dictionary " << fName
346 const word localKeyword = keyword.substr
349 keyword.size() - emarkPos - 1
352 includedDictionary
dict(fName, *
this);
364 <<
"keyword " << localKeyword
365 <<
" is undefined in dictionary " 370 return entryPtr->
clone(*this).ptr();
376 bool Foam::dictionary::findInPatterns
378 const bool patternMatch,
381 DLList<autoPtr<regExp>>::const_iterator& reLink
384 if (patternEntries_.size())
386 while (wcLink != patternEntries_.end())
391 ? reLink()->match(Keyword)
392 : wcLink()->keyword() == Keyword
407 bool Foam::dictionary::findInPatterns
409 const bool patternMatch,
412 DLList<autoPtr<regExp>>::iterator& reLink
415 if (patternEntries_.size())
417 while (wcLink != patternEntries_.end())
422 ? reLink()->match(Keyword)
423 : wcLink()->keyword() == Keyword
465 hashedEntries_.insert(iter().keyword(), &iter());
467 if (iter().keyword().isPattern())
469 patternEntries_.insert(&iter());
470 patternRegexps_.insert
490 hashedEntries_.insert(iter().keyword(), &iter());
492 if (iter().keyword().isPattern())
494 patternEntries_.insert(&iter());
495 patternRegexps_.insert
511 hashedEntries_(move(dict.hashedEntries_)),
512 parent_(dict.parent_),
513 patternEntries_(move(dict.patternEntries_)),
514 patternRegexps_(move(dict.patternRegexps_))
540 hashedEntries_(move(dict.hashedEntries_)),
542 patternEntries_(move(dict.patternEntries_)),
543 patternRegexps_(move(dict.patternRegexps_))
572 if (&p !=
this && !p.
name().empty())
587 if (&p !=
this && !p.
name().empty())
607 return first()->startLineNumber();
620 return last()->endLineNumber();
669 if (hashedEntries_.found(keyword))
675 if (patternMatch && patternEntries_.size())
678 patternEntries_.begin();
680 patternRegexps_.begin();
683 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
691 return parent_.
found(keyword, recursive, patternMatch);
710 if (iter == hashedEntries_.end())
712 if (patternMatch && patternEntries_.size())
715 patternEntries_.begin();
717 patternRegexps_.begin();
720 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
749 if (iter == hashedEntries_.end())
751 if (patternMatch && patternEntries_.size())
754 patternEntries_.begin();
756 patternRegexps_.begin();
759 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
791 const entry* result =
nullptr;
793 forAll(keywords, keywordi)
795 const entry* entryPtr =
803 <<
"Duplicate backwards compatible keywords \"" 805 <<
"\" are defined in dictionary " <<
name() <<
endl 806 <<
"The preferred keyword for this entry is \"" 807 << keywords[0] <<
"\"" <<
endl;
829 if (entryPtr ==
nullptr)
832 <<
"keyword " << keyword <<
" is undefined in dictionary " 848 const entry* entryPtr =
851 if (entryPtr ==
nullptr)
854 return lookupEntry(keywords[0], recursive, patternMatch);
909 dictPtr = &dictPtr->parent_;
913 return dictPtr->lookupScopedSubEntryPtr
915 keyword.substr(1, keyword.size() - 1),
922 return lookupScopedSubEntryPtr
934 word varName = keyword(1, keyword.size() - 1);
963 return entryPtr->
isDict();
978 return &entryPtr->
dict();
993 return &entryPtr->
dict();
1006 if (entryPtr ==
nullptr)
1009 <<
"keyword " << keyword <<
" is undefined in dictionary " 1013 return entryPtr->
dict();
1021 if (entryPtr ==
nullptr)
1024 <<
"keyword " << keyword <<
" is undefined in dictionary " 1028 return entryPtr->
dict();
1034 const word& keyword,
1040 if (entryPtr ==
nullptr)
1045 <<
"keyword " << keyword <<
" is undefined in dictionary " 1054 return entryPtr->
dict();
1068 return entryPtr->
dict();
1091 if (!entPtr || !entPtr->
isDict())
1094 <<
"keyword " << keyword
1095 <<
" is undefined in dictionary " 1096 <<
name() <<
" or is not a dictionary" 1098 <<
"Valid keywords are " <<
keys()
1101 return entPtr->
dict();
1122 keys[nKeys++] = iter().keyword();
1131 return hashedEntries_.sortedToc();
1142 if (iter().keyword().isPattern() ? patterns : !patterns)
1144 keys[nKeys++] = iter().keyword();
1160 if (mergeEntry && iter != hashedEntries_.end())
1163 if (iter()->isDict() && entryPtr->
isDict())
1165 iter()->dict().merge(entryPtr->
dict());
1175 hashedEntries_.erase(iter);
1177 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1183 patternEntries_.insert(entryPtr);
1184 patternRegexps_.insert
1195 <<
"problem replacing entry "<< entryPtr->
keyword()
1196 <<
" in dictionary " <<
name() <<
endl;
1205 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1212 patternEntries_.insert(entryPtr);
1213 patternRegexps_.insert
1234 <<
"attempt to add entry "<< entryPtr->
keyword()
1235 <<
" which already exists in dictionary " <<
name()
1247 add(e.
clone(*this).ptr(), mergeEntry);
1296 if (existingPtr && existingPtr->
isDict())
1300 add(entryPtr,
true);
1306 set(e.
clone(*this).ptr());
1320 if (iter != hashedEntries_.end())
1324 patternEntries_.begin();
1326 patternRegexps_.begin();
1329 if (findInPatterns(
false, Keyword, wcLink, reLink))
1331 patternEntries_.remove(wcLink);
1332 patternRegexps_.remove(reLink);
1337 hashedEntries_.erase(iter);
1356 if (oldKeyword == newKeyword)
1364 if (iter == hashedEntries_.end())
1369 if (iter()->keyword().isPattern())
1372 <<
"Old keyword "<< oldKeyword
1374 <<
"Pattern replacement not yet implemented." 1382 if (iter2 != hashedEntries_.end())
1386 if (iter2()->keyword().isPattern())
1390 patternEntries_.begin();
1392 patternRegexps_.begin();
1395 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
1397 patternEntries_.remove(wcLink);
1398 patternRegexps_.remove(reLink);
1404 hashedEntries_.erase(iter2);
1412 ) <<
"cannot rename keyword "<< oldKeyword
1413 <<
" to existing keyword " << newKeyword
1414 <<
" in dictionary " <<
name() <<
endl;
1420 iter()->keyword() = newKeyword;
1421 iter()->name() =
name() +
'/' + newKeyword;
1422 hashedEntries_.erase(oldKeyword);
1423 hashedEntries_.insert(newKeyword, iter());
1427 patternEntries_.insert(iter());
1428 patternRegexps_.insert
1444 <<
"attempted merge to self for dictionary " <<
name()
1448 bool changed =
false;
1454 if (fnd != hashedEntries_.end())
1458 if (fnd()->isDict() && iter().isDict())
1460 if (fnd()->dict().merge(iter().
dict()))
1467 add(iter().
clone(*this).ptr(),
true);
1486 hashedEntries_.clear();
1487 patternEntries_.clear();
1488 patternRegexps_.clear();
1499 hashedEntries_.transfer(dict.hashedEntries_);
1500 patternEntries_.transfer(dict.patternEntries_);
1501 patternRegexps_.transfer(dict.patternRegexps_);
1519 <<
"attempted assignment to self for dictionary " <<
name()
1542 <<
"attempted assignment to self for dictionary " <<
name()
1548 hashedEntries_ = move(rhs.hashedEntries_);
1549 patternEntries_ = move(rhs.patternEntries_);
1550 patternRegexps_ = move(rhs.patternRegexps_);
1560 <<
"attempted addition assignment to self for dictionary " <<
name()
1577 <<
"attempted assignment to self for dictionary " <<
name()
1583 if (!
found(iter().keyword()))
1597 <<
"attempted assignment to self for dictionary " <<
name()
1603 set(iter().clone(*this).ptr());
1638 const string& funcArgs,
1644 funcName = funcArgs;
1647 bool namedArg =
false;
1655 word::const_iterator iter = funcArgs.begin();
1656 iter != funcArgs.end();
1666 funcName = funcArgs(start, i - start);
1671 else if (c ==
',' || c ==
')')
1682 funcArgs(start, i - start)
1705 argName = funcArgs(start, i - start);
1706 string::stripInvalid<variable>(argName);
1715 string::stripInvalid<word>(funcName);
1721 const string& funcArgs,
1727 bool namedArg =
false;
1735 word::const_iterator iter = funcArgs.begin();
1736 iter != funcArgs.end();
1746 else if (c ==
',' || std::next(iter) == funcArgs.end())
1748 if (std::next(iter) == funcArgs.end())
1767 funcArgs(start, i - start)
1781 argName = funcArgs(start, i - start);
1782 string::stripInvalid<variable>(argName);
1803 if (i != string::npos)
1807 scopedName.substr(0, i),
1808 scopedName.substr(i+1, string::npos)
static bool slash()
Return true if the inputSyntax is slash.
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.
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.
#define forAll(list, i)
Loop across all elements in list.
bool remove(const word &)
Remove an entry specified by keyword.
const entry & lookupEntryBackwardsCompatible(const wordList &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present, trying a list.
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.
const dictionary & scopedDict(const word &) const
Find and return a sub-dictionary by scoped lookup.
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...
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A 2-tuple for storing two objects of different types.
const entry * lookupEntryPtrBackwardsCompatible(const wordList &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present, trying a list.
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.
An STL-conforming const_iterator.
A token holds items read from Istream.
static const fileName null
An empty fileName.
static bool dot()
Return true if the inputSyntax is dot.
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.
static bool writeOptionalEntries
If true write optional keywords and values.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
A Foam::OSstream for calculating SHA-1 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.
const dimensionedScalar c
Speed of light in a vacuum.
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 word dictName() const
Return the local dictionary name (final part of scoped name)
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,.
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
void operator<<=(const dictionary &)
Unconditionally include entries from the given dictionary.
static int disableFunctionEntries
An ordered pair of two objects of type <T> with first() and second() elements.
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.
A class for handling words, derived from string.
const dictionary & parent() const
Return the parent dictionary.
void clear()
Clear the contents of the list.
void append(const T &)
Append an element at the end of the list.
word topDictKeyword() const
Return the scoped keyword with which this dictionary can be.
static const dictionary null
Null dictionary.
An STL-conforming iterator.
const dictionary & topDict() const
Return the top of the tree.
static const word null
An empty word.
T * remove(T *p)
Remove and return element.
graph_traits< Graph >::vertices_size_type size_type
errorManip< error > abort(error &err)
A wordRe is a word, but can also have a regular expression for matching words.
static char scopeChar()
Return true if the inputSyntax is slash.
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)
word name(const complex &)
Return a string representation of a complex.
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.
void operator=(const dictionaryName &name)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Input from memory buffer stream.
string str() const
Return the string.
SHA1Digest digest()
Return the SHA-1 digest for the data processed until now.
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.
void operator=(const ILList< LListBase, T > &)
Assignment operator.
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.
void dictArgList(const string &funcArgs, word &funcName, wordReList &args, List< Tuple2< word, string >> &namedArgs)
Parse dictionary substitution argument list.
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.
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
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.