49 const Foam::entry* Foam::dictionary::lookupDotScopedSubEntryPtr
58 if (dotPos == string::npos)
72 string::const_iterator iter = keyword.begin() + begVar;
74 while (iter != keyword.end() && *iter ==
'.')
83 <<
"No parent of current dictionary"
84 <<
" when searching for "
85 << keyword.substr(begVar, keyword.size() - begVar)
88 dictPtr = &dictPtr->parent_;
91 return dictPtr->lookupScopedSubEntryPtr
93 keyword.substr(endVar),
101 word firstWord = keyword.substr(0, dotPos);
103 const entry* entPtr = lookupDotScopedSubEntryPtr
126 keyword.substr(0, nextDotPos),
130 if (nextDotPos == string::npos)
136 if (subEntPtr && subEntPtr->isDict())
138 return subEntPtr->dict().lookupDotScopedSubEntryPtr
143 keyword.size() - nextDotPos
150 nextDotPos = keyword.find(
'.', nextDotPos + 1);
154 if (entPtr->isDict())
156 return entPtr->dict().lookupDotScopedSubEntryPtr
158 keyword.substr(dotPos, keyword.size() - dotPos),
172 const Foam::entry* Foam::dictionary::lookupSlashScopedSubEntryPtr
181 if (slashPos == string::npos)
184 return lookupEntryPtr(keyword, recursive, patternMatch);
189 word firstWord = keyword.substr(0, slashPos);
192 if (firstWord ==
".")
194 return lookupScopedSubEntryPtr
196 keyword.substr(slashPos),
201 else if (firstWord ==
"..")
207 <<
"No parent of current dictionary"
208 <<
" when searching for "
209 << keyword.substr(slashPos, keyword.size() - slashPos)
213 return parent_.lookupScopedSubEntryPtr
215 keyword.substr(slashPos),
222 const entry* entPtr = lookupScopedSubEntryPtr
243 const entry* subEntPtr = lookupEntryPtr
245 keyword.substr(0, nextSlashPos),
250 if (nextSlashPos == string::npos)
258 if (subEntPtr && subEntPtr->isDict())
260 return subEntPtr->dict().lookupScopedSubEntryPtr
265 keyword.size() - nextSlashPos
272 nextSlashPos = keyword.find(
'/', nextSlashPos);
276 if (entPtr->isDict())
278 return entPtr->dict().lookupScopedSubEntryPtr
280 keyword.substr(slashPos, keyword.size() - slashPos),
294 const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
303 return lookupDotScopedSubEntryPtr(keyword, recursive, patternMatch);
310 if (emarkPos == string::npos || emarkPos == 0)
314 return lookupSlashScopedSubEntryPtr
326 fileName fName = keyword.substr(0, emarkPos);
328 if (!fName.isAbsolute())
330 fName = topDict().name().path()/fName;
333 if (fName == topDict().
name())
336 <<
"Attempt to re-read current dictionary " << fName
342 const word localKeyword = keyword.substr
345 keyword.size() - emarkPos - 1
348 includedDictionary
dict(fName, *
this);
360 <<
"keyword " << localKeyword
361 <<
" is undefined in dictionary "
366 return entryPtr->
clone(*this).ptr();
372 bool Foam::dictionary::findInPatterns
374 const bool patternMatch,
377 DLList<autoPtr<regExp>>::const_iterator& reLink
380 if (patternEntries_.size())
382 while (wcLink != patternEntries_.end())
387 ? reLink()->match(Keyword)
388 : wcLink()->keyword() == Keyword
403 bool Foam::dictionary::findInPatterns
405 const bool patternMatch,
408 DLList<autoPtr<regExp>>::iterator& reLink
411 if (patternEntries_.size())
413 while (wcLink != patternEntries_.end())
418 ? reLink()->match(Keyword)
419 : wcLink()->keyword() == Keyword
461 hashedEntries_.insert(iter().keyword(), &iter());
463 if (iter().keyword().isPattern())
465 patternEntries_.insert(&iter());
466 patternRegexps_.insert
486 hashedEntries_.insert(iter().keyword(), &iter());
488 if (iter().keyword().isPattern())
490 patternEntries_.insert(&iter());
491 patternRegexps_.insert
507 hashedEntries_(move(
dict.hashedEntries_)),
508 parent_(
dict.parent_),
509 patternEntries_(move(
dict.patternEntries_)),
510 patternRegexps_(move(
dict.patternRegexps_))
536 hashedEntries_(move(
dict.hashedEntries_)),
538 patternEntries_(move(
dict.patternEntries_)),
539 patternRegexps_(move(
dict.patternRegexps_))
568 if (&
p !=
this && !
p.
name().empty())
583 if (&
p !=
this && !
p.
name().empty())
585 const word pKeyword =
p.topDictKeyword();
590 :
word(pKeyword + pSeparator + dictName());
603 return first()->startLineNumber();
616 return last()->endLineNumber();
665 if (hashedEntries_.found(keyword))
671 if (patternMatch && patternEntries_.size())
674 patternEntries_.begin();
676 patternRegexps_.begin();
679 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
687 return parent_.found(keyword, recursive, patternMatch);
706 if (iter == hashedEntries_.end())
708 if (patternMatch && patternEntries_.size())
711 patternEntries_.begin();
713 patternRegexps_.begin();
716 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
724 return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
745 if (iter == hashedEntries_.end())
747 if (patternMatch && patternEntries_.size())
750 patternEntries_.begin();
752 patternRegexps_.begin();
755 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
763 return const_cast<dictionary&
>(parent_).lookupEntryPtr
787 const entry* result =
nullptr;
789 forAll(keywords, keywordi)
791 const entry* entryPtr =
792 lookupEntryPtr(keywords[keywordi], recursive, patternMatch);
799 <<
"Duplicate backwards compatible keywords \""
801 <<
"\" are defined in dictionary " <<
name() <<
endl
802 <<
"The preferred keyword for this entry is \""
803 << keywords[0] <<
"\"" <<
endl;
823 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
825 if (entryPtr ==
nullptr)
828 <<
"keyword " << keyword <<
" is undefined in dictionary "
844 const entry* entryPtr =
845 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
847 if (entryPtr ==
nullptr)
850 return lookupEntry(keywords[0], recursive, patternMatch);
866 return lookupEntry(keyword, recursive, patternMatch).stream();
877 return lookupEntryBackwardsCompatible
905 dictPtr = &dictPtr->parent_;
909 return dictPtr->lookupScopedSubEntryPtr
911 keyword.substr(1, keyword.size() - 1),
918 return lookupScopedSubEntryPtr
930 word varName = keyword(1, keyword.size() - 1);
933 const entry* ePtr = lookupScopedEntryPtr(varName,
true,
true);
955 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
959 return entryPtr->
isDict();
970 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
974 return &entryPtr->
dict();
985 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
989 return &entryPtr->
dict();
1000 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
1002 if (entryPtr ==
nullptr)
1005 <<
"keyword " << keyword <<
" is undefined in dictionary "
1009 return entryPtr->
dict();
1015 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
1017 if (entryPtr ==
nullptr)
1020 <<
"keyword " << keyword <<
" is undefined in dictionary "
1024 return entryPtr->
dict();
1033 const entry* entryPtr =
1034 lookupEntryPtrBackwardsCompatible(keywords,
false,
true);
1036 if (entryPtr ==
nullptr)
1039 return subDict(keywords[0]);
1043 return entryPtr->
dict();
1050 const word& keyword,
1054 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
1056 if (entryPtr ==
nullptr)
1061 <<
"keyword " << keyword <<
" is undefined in dictionary "
1070 return entryPtr->
dict();
1080 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
1084 return entryPtr->
dict();
1101 const entry* entPtr = lookupScopedEntryPtr
1107 if (!entPtr || !entPtr->
isDict())
1110 <<
"keyword " << keyword
1111 <<
" is undefined in dictionary "
1112 <<
name() <<
" or is not a dictionary"
1114 <<
"Valid keywords are " << keys()
1117 return entPtr->
dict();
1126 const_cast<const dictionary*
>(
this)->scopedDict(keyword)
1138 keys[nKeys++] = iter().keyword();
1147 return hashedEntries_.sortedToc();
1158 if (iter().keyword().isPattern() ? patterns : !patterns)
1160 keys[nKeys++] = iter().keyword();
1176 if (mergeEntry && iter != hashedEntries_.end())
1179 if (iter()->isDict() && entryPtr->
isDict())
1181 iter()->dict().merge(entryPtr->
dict());
1191 hashedEntries_.erase(iter);
1193 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1199 patternEntries_.insert(entryPtr);
1200 patternRegexps_.insert
1211 <<
"problem replacing entry "<< entryPtr->
keyword()
1212 <<
" in dictionary " <<
name() <<
endl;
1221 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1228 patternEntries_.insert(entryPtr);
1229 patternRegexps_.insert
1250 <<
"attempt to add entry "<< entryPtr->
keyword()
1251 <<
" which already exists in dictionary " <<
name()
1263 add(
e.clone(*this).ptr(), mergeEntry);
1309 entry* existingPtr = lookupEntryPtr(entryPtr->
keyword(),
false,
true);
1312 if (existingPtr && existingPtr->
isDict())
1316 add(entryPtr,
true);
1322 set(
e.clone(*this).ptr());
1336 if (iter != hashedEntries_.end())
1340 patternEntries_.begin();
1342 patternRegexps_.begin();
1345 if (findInPatterns(
false, Keyword, wcLink, reLink))
1347 patternEntries_.remove(wcLink);
1348 patternRegexps_.remove(reLink);
1353 hashedEntries_.erase(iter);
1372 if (oldKeyword == newKeyword)
1380 if (iter == hashedEntries_.end())
1385 if (iter()->keyword().isPattern())
1388 <<
"Old keyword "<< oldKeyword
1390 <<
"Pattern replacement not yet implemented."
1398 if (iter2 != hashedEntries_.end())
1402 if (iter2()->keyword().isPattern())
1406 patternEntries_.begin();
1408 patternRegexps_.begin();
1411 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
1413 patternEntries_.remove(wcLink);
1414 patternRegexps_.remove(reLink);
1420 hashedEntries_.erase(iter2);
1428 ) <<
"cannot rename keyword "<< oldKeyword
1429 <<
" to existing keyword " << newKeyword
1430 <<
" in dictionary " <<
name() <<
endl;
1436 iter()->keyword() = newKeyword;
1437 iter()->name() =
name() +
'/' + newKeyword;
1438 hashedEntries_.erase(oldKeyword);
1439 hashedEntries_.insert(newKeyword, iter());
1443 patternEntries_.insert(iter());
1444 patternRegexps_.insert
1460 <<
"attempted merge to self for dictionary " <<
name()
1464 bool changed =
false;
1470 if (fnd != hashedEntries_.end())
1474 if (fnd()->isDict() && iter().isDict())
1476 if (fnd()->
dict().merge(iter().
dict()))
1483 add(iter().
clone(*this).ptr(),
true);
1502 hashedEntries_.clear();
1503 patternEntries_.clear();
1504 patternRegexps_.clear();
1515 hashedEntries_.transfer(
dict.hashedEntries_);
1516 patternEntries_.transfer(
dict.patternEntries_);
1517 patternRegexps_.transfer(
dict.patternRegexps_);
1525 return lookup(keyword);
1535 <<
"attempted assignment to self for dictionary " <<
name()
1558 <<
"attempted assignment to self for dictionary " <<
name()
1564 hashedEntries_ = move(rhs.hashedEntries_);
1565 patternEntries_ = move(rhs.patternEntries_);
1566 patternRegexps_ = move(rhs.patternRegexps_);
1576 <<
"attempted addition assignment to self for dictionary " <<
name()
1593 <<
"attempted assignment to self for dictionary " <<
name()
1599 if (!
found(iter().keyword()))
1613 <<
"attempted assignment to self for dictionary " <<
name()
1619 set(iter().
clone(*this).ptr());
1654 const string& argString,
1660 funcName = argString;
1663 bool namedArg =
false;
1671 word::const_iterator iter = argString.begin();
1672 iter != argString.end();
1682 funcName = argString(start, i - start);
1687 else if (
c ==
',' ||
c ==
')')
1698 argString(start, i - start)
1705 args.append(
wordRe(argString(start, i - start)));
1721 argName = argString(start, i - start);
1722 string::stripInvalid<variable>(argName);
1731 string::stripInvalid<word>(funcName);
1737 const string& argString,
1743 bool namedArg =
false;
1751 word::const_iterator iter = argString.begin();
1752 iter != argString.end();
1762 else if (
c ==
',' || std::next(iter) == argString.end())
1764 if (std::next(iter) == argString.end())
1783 argString(start, i - start)
1790 args.append(
wordRe(argString(start, i - start)));
1797 argName = argString(start, i - start);
1798 string::stripInvalid<variable>(argName);
1819 if (i != string::npos)
1823 scopedName.substr(0, i),
1824 scopedName.substr(i+1, string::npos)
graph_traits< Graph >::vertices_size_type size_type
#define forAll(list, i)
Loop across all elements in list.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
A 1D vector of objects of type <T> that resizes itself as necessary to accept the new objects.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
An STL-conforming const_iterator.
An STL-conforming iterator.
Template class for intrusive linked lists.
void transfer(ILList< LListBase, T > &)
Transfer the contents of the argument into this List.
void clear()
Clear the contents of the list.
void operator=(const ILList< LListBase, T > &)
Assignment operator.
const word & name() const
Return name.
virtual Istream & read(token &)
Return next token from stream.
Input from memory buffer stream.
An STL-conforming const_iterator.
An STL-conforming iterator.
Template class for non-intrusive linked lists.
friend class const_iterator
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
void setSize(const label)
Reset size of List.
A Foam::OSstream for calculating SHA-1 digests.
SHA1Digest digest()
Return the SHA-1 digest for the data processed until now.
Output to memory buffer stream.
string str() const
Return the string.
An ordered pair of two objects of type <T> with first() and second() elements.
A 2-tuple for storing two objects of different types.
An STL-conforming const_iterator.
An STL-conforming iterator.
T * remove(T *p)
Remove and return element.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
A keyword and a list of tokens is a 'dictionaryEntry'.
void operator=(const dictionaryName &name)
const fileName & name() const
Return the dictionary name.
A list of keyword definitions, which are a keyword followed by any number of values (e....
bool substituteScopedKeyword(const word &keyword)
Substitute the given scoped keyword prepended by '$' with the.
static bool writeOptionalEntries
If true write optional keywords and values.
const dictionary & topDict() const
Return the top of the tree.
ITstream & operator[](const word &) const
Find and return entry.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
dictionary()
Construct top-level dictionary null.
autoPtr< dictionary > clone() const
Construct and return clone.
void operator<<=(const dictionary &)
Unconditionally include entries from the given dictionary.
void transfer(dictionary &)
Transfer the contents of the argument and annul the argument.
const dictionary & subDictBackwardsCompatible(const wordList &) const
Find and return a sub-dictionary, trying a list of keywords in.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool forceOverwrite=false)
Change the keyword for an entry,.
tokenList tokens() const
Return the dictionary as a list of tokens.
void set(entry *)
Assign a new entry, overwrite any existing entry.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
friend class entry
Declare friendship with the entry class for IO.
void operator+=(const dictionary &)
Include entries from the given dictionary.
const dictionary & optionalSubDict(const word &) const
Find and return a sub-dictionary if found.
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present,.
word topDictKeyword() const
Return the scoped keyword with which this dictionary can be.
bool remove(const word &)
Remove an entry specified by keyword.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
const entry & lookupEntryBackwardsCompatible(const wordList &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present, trying a list.
label endLineNumber() const
Return line number of last token in dictionary.
wordList sortedToc() const
Return the sorted table of contents.
const entry * lookupEntryPtrBackwardsCompatible(const wordList &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present, trying a list.
void operator|=(const dictionary &)
Conditionally include entries from the given dictionary.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
void clear()
Clear the dictionary.
virtual ~dictionary()
Destructor.
ITstream & lookupBackwardsCompatible(const wordList &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream, trying a list of keywords.
const dictionary * subDictPtr(const word &) const
Find and return a sub-dictionary pointer if present.
void operator=(const dictionary &)
wordList toc() const
Return the table of contents.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
const dictionary & scopedDict(const word &) const
Find and return a sub-dictionary by scoped lookup.
label startLineNumber() const
Return line number of first token in dictionary.
static const dictionary null
Null dictionary.
bool merge(const dictionary &)
Merge entries from the given dictionary.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
A keyword and a list of tokens is an 'entry'.
virtual bool isDict() const
Return true if this entry is a dictionary.
const keyType & keyword() const
Return keyword.
virtual const fileName & name() const =0
Return the dictionary name.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
virtual autoPtr< entry > clone(const dictionary &parentDict) const =0
Construct on freestore as copy with reference to the.
static int disableFunctionEntries
A class for handling file names.
static const fileName null
An empty fileName.
static bool dot()
Return true if the inputSyntax is dot.
static char scopeChar()
Return true if the inputSyntax is slash.
static bool slash()
Return true if the inputSyntax is slash.
A class for handling keywords in dictionaries.
bool isPattern() const
Should be treated as a match rather than a literal string.
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
Wrapper around POSIX extended regular expressions.
A class for handling character strings derived from std::string.
A token holds items read from Istream.
A wordRe is a word, but can also have a regular expression for matching words.
A class for handling words, derived from string.
static const word null
An empty word.
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
gmvFile<< "tracers "<< particles.size()<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
const dimensionedScalar c
Speed of light in a vacuum.
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
errorManipArg< error, int > exit(error &err, const int errNo=1)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & endl(Ostream &os)
Add newline and flush stream.
word name(const bool)
Return a word representation of a bool.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
errorManip< error > abort(error &err)
void dictArgList(const string &argString, word &configName, wordReList &args, List< Tuple2< word, string >> &namedArgs)
Parse dictionary substitution argument list.
labelList first(const UList< labelPair > &p)
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
defineTypeNameAndDebug(combustionModel, 0)
LList< DLListBase, T > DLList
List< token > tokenList
List of tokens, used for a IOdictionary entry.
Foam::argList args(argc, argv)