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 return first()->startLineNumber();
600 return last()->endLineNumber();
649 if (hashedEntries_.found(keyword))
655 if (patternMatch && patternEntries_.size())
658 patternEntries_.begin();
660 patternRegexps_.begin();
663 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
671 return parent_.
found(keyword, recursive, patternMatch);
690 if (iter == hashedEntries_.end())
692 if (patternMatch && patternEntries_.size())
695 patternEntries_.begin();
697 patternRegexps_.begin();
700 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
729 if (iter == hashedEntries_.end())
731 if (patternMatch && patternEntries_.size())
734 patternEntries_.begin();
736 patternRegexps_.begin();
739 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
771 const entry* result =
nullptr;
773 forAll(keywords, keywordi)
775 const entry* entryPtr =
783 <<
"Duplicate backwards compatible keywords \"" 785 <<
"\" are defined in dictionary " <<
name() <<
endl 786 <<
"The preferred keyword for this entry is \"" 787 << keywords[0] <<
"\"" <<
endl;
809 if (entryPtr ==
nullptr)
812 <<
"keyword " << keyword <<
" is undefined in dictionary " 828 const entry* entryPtr =
831 if (entryPtr ==
nullptr)
834 return lookupEntry(keywords[0], recursive, patternMatch);
889 dictPtr = &dictPtr->parent_;
893 return dictPtr->lookupScopedSubEntryPtr
895 keyword.substr(1, keyword.size() - 1),
902 return lookupScopedSubEntryPtr
914 word varName = keyword(1, keyword.size() - 1);
943 return entryPtr->
isDict();
958 return &entryPtr->
dict();
973 return &entryPtr->
dict();
986 if (entryPtr ==
nullptr)
989 <<
"keyword " << keyword <<
" is undefined in dictionary " 993 return entryPtr->
dict();
1001 if (entryPtr ==
nullptr)
1004 <<
"keyword " << keyword <<
" is undefined in dictionary " 1008 return entryPtr->
dict();
1014 const word& keyword,
1020 if (entryPtr ==
nullptr)
1025 <<
"keyword " << keyword <<
" is undefined in dictionary " 1034 return entryPtr->
dict();
1048 return entryPtr->
dict();
1071 if (!entPtr || !entPtr->
isDict())
1074 <<
"keyword " << keyword
1075 <<
" is undefined in dictionary " 1076 <<
name() <<
" or is not a dictionary" 1078 <<
"Valid keywords are " <<
keys()
1081 return entPtr->
dict();
1102 keys[nKeys++] = iter().keyword();
1111 return hashedEntries_.sortedToc();
1122 if (iter().keyword().isPattern() ? patterns : !patterns)
1124 keys[nKeys++] = iter().keyword();
1140 if (mergeEntry && iter != hashedEntries_.end())
1143 if (iter()->isDict() && entryPtr->
isDict())
1145 iter()->dict().merge(entryPtr->
dict());
1155 hashedEntries_.erase(iter);
1157 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1163 patternEntries_.insert(entryPtr);
1164 patternRegexps_.insert
1175 <<
"problem replacing entry "<< entryPtr->
keyword()
1176 <<
" in dictionary " <<
name() <<
endl;
1185 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1192 patternEntries_.insert(entryPtr);
1193 patternRegexps_.insert
1214 <<
"attempt to add entry "<< entryPtr->
keyword()
1215 <<
" which already exists in dictionary " <<
name()
1227 add(e.
clone(*this).ptr(), mergeEntry);
1276 if (existingPtr && existingPtr->
isDict())
1280 add(entryPtr,
true);
1286 set(e.
clone(*this).ptr());
1300 if (iter != hashedEntries_.end())
1304 patternEntries_.begin();
1306 patternRegexps_.begin();
1309 if (findInPatterns(
false, Keyword, wcLink, reLink))
1311 patternEntries_.remove(wcLink);
1312 patternRegexps_.remove(reLink);
1317 hashedEntries_.erase(iter);
1336 if (oldKeyword == newKeyword)
1344 if (iter == hashedEntries_.end())
1349 if (iter()->keyword().isPattern())
1352 <<
"Old keyword "<< oldKeyword
1354 <<
"Pattern replacement not yet implemented." 1362 if (iter2 != hashedEntries_.end())
1366 if (iter2()->keyword().isPattern())
1370 patternEntries_.begin();
1372 patternRegexps_.begin();
1375 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
1377 patternEntries_.remove(wcLink);
1378 patternRegexps_.remove(reLink);
1384 hashedEntries_.erase(iter2);
1392 ) <<
"cannot rename keyword "<< oldKeyword
1393 <<
" to existing keyword " << newKeyword
1394 <<
" in dictionary " <<
name() <<
endl;
1400 iter()->keyword() = newKeyword;
1401 iter()->name() =
name() +
'/' + newKeyword;
1402 hashedEntries_.erase(oldKeyword);
1403 hashedEntries_.insert(newKeyword, iter());
1407 patternEntries_.insert(iter());
1408 patternRegexps_.insert
1424 <<
"attempted merge to self for dictionary " <<
name()
1428 bool changed =
false;
1434 if (fnd != hashedEntries_.end())
1438 if (fnd()->isDict() && iter().isDict())
1440 if (fnd()->dict().merge(iter().
dict()))
1447 add(iter().
clone(*this).ptr(),
true);
1466 hashedEntries_.clear();
1467 patternEntries_.clear();
1468 patternRegexps_.clear();
1479 hashedEntries_.transfer(dict.hashedEntries_);
1480 patternEntries_.transfer(dict.patternEntries_);
1481 patternRegexps_.transfer(dict.patternRegexps_);
1499 <<
"attempted assignment to self for dictionary " <<
name()
1522 <<
"attempted assignment to self for dictionary " <<
name()
1528 hashedEntries_ = move(rhs.hashedEntries_);
1529 patternEntries_ = move(rhs.patternEntries_);
1530 patternRegexps_ = move(rhs.patternRegexps_);
1540 <<
"attempted addition assignment to self for dictionary " <<
name()
1557 <<
"attempted assignment to self for dictionary " <<
name()
1563 if (!
found(iter().keyword()))
1577 <<
"attempted assignment to self for dictionary " <<
name()
1583 set(iter().clone(*this).ptr());
1618 const string& funcArgs,
1624 funcName = funcArgs;
1627 bool namedArg =
false;
1635 word::const_iterator iter = funcArgs.begin();
1636 iter != funcArgs.end();
1646 funcName = funcArgs(start, i - start);
1651 else if (c ==
',' || c ==
')')
1662 funcArgs(start, i - start)
1685 argName = funcArgs(start, i - start);
1686 string::stripInvalid<variable>(argName);
1695 string::stripInvalid<word>(funcName);
1701 const string& funcArgs,
1707 bool namedArg =
false;
1715 word::const_iterator iter = funcArgs.begin();
1716 iter != funcArgs.end();
1726 else if (c ==
',' || std::next(iter) == funcArgs.end())
1728 if (std::next(iter) == funcArgs.end())
1747 funcArgs(start, i - start)
1761 argName = funcArgs(start, i - start);
1762 string::stripInvalid<variable>(argName);
1783 if (i != string::npos)
1787 scopedName.substr(0, i),
1788 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.
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.
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...
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.
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.
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 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.
static const dictionary null
Null dictionary.
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)
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.
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.
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.