36 const dictionary& parentDict,
41 parentDict.currentName().size()
42 ? parentDict.parent().isNull()
43 ? fileName(parentDict.currentName() +
'!' +
name)
49 const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
59 if (emarkPos == string::npos || emarkPos == 0)
65 if (slashPos == string::npos)
68 return lookupEntryPtr(keyword, recursive, patternMatch);
73 word firstWord = keyword.substr(0, slashPos);
78 return lookupScopedSubEntryPtr
80 keyword.substr(slashPos),
85 else if (firstWord ==
"..")
91 <<
"No parent of current dictionary"
92 <<
" when searching for "
93 << keyword.substr(slashPos, keyword.size() - slashPos)
97 return parent_.lookupScopedSubEntryPtr
99 keyword.substr(slashPos),
106 const entry* entPtr = lookupScopedSubEntryPtr
113 if (entPtr && entPtr->isDict())
115 return entPtr->dict().lookupScopedSubEntryPtr
117 keyword.substr(slashPos, keyword.size() - slashPos),
134 fileName fName = keyword.substr(0, emarkPos);
136 if (!fName.isAbsolute())
138 fName = topDict().name().path()/fName;
141 if (fName == topDict().
name())
144 <<
"Attempt to re-read current dictionary " << fName
150 const word localKeyword = keyword.substr
153 keyword.size() - emarkPos - 1
156 includedDictionary
dict(fName, *
this);
168 <<
"keyword " << localKeyword
169 <<
" is undefined in dictionary "
174 return entryPtr->
clone(*this).ptr();
179 bool Foam::dictionary::findInPatterns
181 const bool patternMatch,
184 DLList<autoPtr<regExp>>::const_iterator& reLink
187 if (patternEntries_.size())
189 while (wcLink != patternEntries_.end())
194 ? reLink()->match(Keyword)
195 : wcLink()->keyword() == Keyword
210 bool Foam::dictionary::haveDefaults(
const dictionary&
dict)
222 bool Foam::dictionary::findInPatterns
224 const bool patternMatch,
227 DLList<autoPtr<regExp>>::iterator& reLink
230 if (patternEntries_.size())
232 while (wcLink != patternEntries_.end())
237 ? reLink()->match(Keyword)
238 : wcLink()->keyword() == Keyword
295 hashedEntries_.insert(iter().keyword(), &iter());
297 if (iter().keyword().isPattern())
299 patternEntries_.insert(&iter());
300 patternRegexps_.insert
345 if (&
p !=
this && !
p.
name().empty())
360 if (&
p !=
this && !
p.
name().empty())
362 const word pKeyword =
p.topDictKeyword();
363 const char pSeparator =
'/';
367 :
word(pKeyword + pSeparator + dictName());
385 if (
name().find(fName.c_str(), 0, fName.size()) != string::npos)
405 return first()->startLineNumber();
418 return filePtr_->lineNumber();
424 return last()->endLineNumber();
474 if (hashedEntries_.found(keyword))
480 if (patternMatch && patternEntries_.size())
483 patternEntries_.begin();
485 patternRegexps_.begin();
488 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
496 return parent_.found(keyword, recursive, patternMatch);
515 if (iter == hashedEntries_.end())
517 if (patternMatch && patternEntries_.size())
520 patternEntries_.begin();
522 patternRegexps_.begin();
525 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
533 return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
554 if (iter == hashedEntries_.end())
556 if (patternMatch && patternEntries_.size())
559 patternEntries_.begin();
561 patternRegexps_.begin();
564 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
572 return const_cast<dictionary&
>(parent_).lookupEntryPtr
596 const entry* result =
nullptr;
598 forAll(keywords, keywordi)
600 const entry* entryPtr =
601 lookupEntryPtr(keywords[keywordi], recursive, patternMatch);
608 <<
"Duplicate backwards compatible keywords \""
610 <<
"\" are defined in dictionary " <<
name() <<
endl
611 <<
"The preferred keyword for this entry is \""
612 << keywords[0] <<
"\"" <<
endl;
632 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
634 if (entryPtr ==
nullptr)
637 <<
"keyword " << keyword <<
" is undefined in dictionary "
653 const entry* entryPtr =
654 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
656 if (entryPtr ==
nullptr)
659 return lookupEntry(keywords[0], recursive, patternMatch);
675 return lookupEntry(keyword, recursive, patternMatch).stream();
686 return lookupEntryBackwardsCompatible
703 if (keyword[0] ==
'!')
709 dictPtr = &dictPtr->parent_;
713 return dictPtr->lookupScopedSubEntryPtr
715 keyword.substr(1, keyword.size() - 1),
722 return lookupScopedSubEntryPtr
735 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
739 return entryPtr->
isDict();
750 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
754 return &entryPtr->
dict();
765 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
769 return &entryPtr->
dict();
780 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
782 if (entryPtr ==
nullptr)
785 <<
"keyword " << keyword <<
" is undefined in dictionary "
789 return entryPtr->
dict();
795 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
797 if (entryPtr ==
nullptr)
800 <<
"keyword " << keyword <<
" is undefined in dictionary "
804 return entryPtr->
dict();
813 const entry* entryPtr =
814 lookupEntryPtrBackwardsCompatible(keywords,
false,
true);
816 if (entryPtr ==
nullptr)
819 return subDict(keywords[0]);
823 return entryPtr->
dict();
834 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
836 if (entryPtr ==
nullptr)
841 <<
"keyword " << keyword <<
" is undefined in dictionary "
850 return entryPtr->
dict();
860 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
864 return entryPtr->
dict();
878 const entry* entryPtr = lookupEntryPtr(
typeName,
false,
true);
882 entryPtr = lookupEntryPtr(
typeName +
"Coeffs",
false,
true);
885 if (entryPtr && entryPtr->
isDict())
887 return entryPtr->
dict();
902 const entry* entryPtr = lookupEntryPtr(
typeName,
false,
true);
906 entryPtr = lookupEntryPtr(
typeName +
"Coeffs",
false,
true);
909 if (entryPtr && entryPtr->
isDict())
911 return entryPtr->
dict();
925 const entry* entryPtr = lookupEntryPtr(
typeName,
false,
true);
929 entryPtr = lookupEntryPtr(
typeName +
"Coeffs",
false,
true);
932 if (entryPtr && entryPtr->
isDict())
934 return entryPtr->
dict();
951 const entry* entPtr = lookupScopedEntryPtr
957 if (!entPtr || !entPtr->
isDict())
960 <<
"keyword " << keyword
961 <<
" is undefined in dictionary "
962 <<
name() <<
" or is not a dictionary"
964 <<
"Valid keywords are " << keys()
967 return entPtr->
dict();
976 const_cast<const dictionary*
>(
this)->scopedDict(keyword)
988 keys[nKeys++] = iter().keyword();
997 return hashedEntries_.sortedToc();
1008 if (iter().keyword().isPattern() ? patterns : !patterns)
1010 keys[nKeys++] = iter().keyword();
1026 if (mergeEntry && iter != hashedEntries_.end())
1029 if (iter()->isDict() && entryPtr->
isDict())
1031 iter()->dict().merge(entryPtr->
dict());
1041 hashedEntries_.erase(iter);
1043 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1045 entryPtr->
name() = pathName(*
this, entryPtr->
keyword());
1049 patternEntries_.insert(entryPtr);
1050 patternRegexps_.insert
1061 <<
"problem replacing entry "<< entryPtr->
keyword()
1062 <<
" in dictionary " <<
name() <<
endl;
1071 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1073 entryPtr->
name() = pathName(*
this, entryPtr->
keyword());
1078 patternEntries_.insert(entryPtr);
1079 patternRegexps_.insert
1092 entryPtr->
name() = pathName(*
this, entryPtr->
keyword());
1100 <<
"attempt to add entry "<< entryPtr->
keyword()
1101 <<
" which already exists in dictionary " <<
name()
1113 add(
e.clone(*this).ptr(), mergeEntry);
1157 void Foam::dictionary::set(
entry* entryPtr)
1159 entry* existingPtr = lookupEntryPtr(entryPtr->
keyword(),
false,
true);
1162 if (existingPtr && existingPtr->
isDict())
1166 add(entryPtr,
true);
1172 set(
e.clone(*this).ptr());
1186 if (iter != hashedEntries_.end())
1190 patternEntries_.begin();
1192 patternRegexps_.begin();
1195 if (findInPatterns(
false, Keyword, wcLink, reLink))
1197 patternEntries_.remove(wcLink);
1198 patternRegexps_.remove(reLink);
1203 hashedEntries_.erase(iter);
1218 remove(Keywords[i]);
1231 if (oldKeyword == newKeyword)
1239 if (iter == hashedEntries_.end())
1244 if (iter()->keyword().isPattern())
1247 <<
"Old keyword "<< oldKeyword
1249 <<
"Pattern replacement not yet implemented."
1257 if (iter2 != hashedEntries_.end())
1261 if (iter2()->keyword().isPattern())
1265 patternEntries_.begin();
1267 patternRegexps_.begin();
1270 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
1272 patternEntries_.remove(wcLink);
1273 patternRegexps_.remove(reLink);
1279 hashedEntries_.erase(iter2);
1287 ) <<
"cannot rename keyword "<< oldKeyword
1288 <<
" to existing keyword " << newKeyword
1289 <<
" in dictionary " <<
name() <<
endl;
1295 iter()->keyword() = newKeyword;
1296 iter()->name() =
name() +
'/' + string::validate<word>(newKeyword);
1297 hashedEntries_.erase(oldKeyword);
1298 hashedEntries_.insert(newKeyword, iter());
1302 patternEntries_.insert(iter());
1303 patternRegexps_.insert
1319 <<
"attempted merge to self for dictionary " <<
name()
1323 bool changed =
false;
1329 if (fnd != hashedEntries_.end())
1333 if (fnd()->isDict() && iter().isDict())
1335 if (fnd()->
dict().merge(iter().
dict()))
1342 add(iter().
clone(*this).ptr(),
true);
1361 hashedEntries_.clear();
1362 patternEntries_.clear();
1363 patternRegexps_.clear();
1374 hashedEntries_.transfer(
dict.hashedEntries_);
1375 patternEntries_.transfer(
dict.patternEntries_);
1376 patternRegexps_.transfer(
dict.patternRegexps_);
1394 <<
"attempted assignment to self for dictionary " <<
name()
1417 <<
"attempted addition assignment to self for dictionary " <<
name()
1434 <<
"attempted assignment to self for dictionary " <<
name()
1440 if (!
found(iter().keyword()))
1454 <<
"attempted assignment to self for dictionary " <<
name()
1460 set(iter().
clone(*this).ptr());
1501 const string& argString = argStringLine.
first();
1504 funcName = argString;
1507 bool namedArg =
false;
1515 word::const_iterator iter = argString.begin();
1516 iter != argString.end();
1530 funcName = argString(start, i - start);
1535 else if (
c ==
',' ||
c ==
')')
1546 argString(start, i - start),
1558 wordRe(argString(start, i - start)),
1577 argName = argString(start, i - start);
1578 string::stripInvalid<variable>(argName);
1587 string::stripInvalid<word>(funcName);
1598 const string& argString = argStringLine.
first();
1602 bool namedArg =
false;
1610 word::const_iterator iter = argString.begin();
1611 iter != argString.end();
1625 else if (
c ==
',' || std::next(iter) == argString.end())
1627 if (std::next(iter) == argString.end())
1646 argString(start, i - start),
1658 wordRe(argString(start, i - start)),
1668 argName = argString(start, i - start);
1669 string::stripInvalid<variable>(argName);
1687 if (i != string::npos)
1691 scopedName.substr(0, i),
1692 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.
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.
const word & name() const
Return name.
bool bad() const
Return true if stream is corrupted.
virtual Istream & read(token &)
Return next token from stream.
Input from memory buffer stream.
bool eof() const
Return true if end of input seen.
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.
A 2-tuple for storing two objects of different types.
const Type2 & second() const
Return second.
const Type1 & first() const
Return first.
A 3-tuple for storing three 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'.
const fileName & name() const
Return the dictionary name.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
const dictionary & topDict() const
Return the top of the tree.
ITstream & operator[](const word &) const
Find and return entry.
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.
const dictionary & subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary.
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,.
const dictionary & typeDict(const word &typeName) const
Find and return a type sub-dictionary.
tokenList tokens() const
Return the dictionary as a list of tokens.
const fileName & currentName() const
Return the dictionary name, or the name of the file if the.
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.
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.
virtual label endLineNumber() const
Return line number of last token in dictionary.
wordList sortedToc() const
Return the sorted table of contents.
const dictionary & typeOrEmptyDict(const word &typeName) const
Find and return a type sub-dictionary.
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.
virtual 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.
const dictionary & optionalTypeDict(const word &typeName) const
Find and return an optional type sub-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.
word name() const
Return file name (part beyond last /)
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,...
static bool haveDefaults(const dictionary &dict)
Return if a dictionary exists to add defaults to for a given.
static dictionary & defaults(const dictionary &dict)
Return the dictionary to add defaults to for a given dictionary.
Wrapper around POSIX extended regular expressions.
A class for handling character strings derived from std::string.
A token holds items read from Istream.
Template function which returns the un-mangled name of a given type. Useful for types which do not ha...
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(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().x()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().y()<< " ";}gmvFile<< nl;forAllConstIter(lagrangian::Cloud< passiveParticle >, particles, iter){ gmvFile<< iter().position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.name(), lagrangian::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.
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
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)
void dictArgList(const Tuple2< string, label > &argString, word &configName, List< Tuple2< wordRe, label >> &args, List< Tuple3< word, string, label >> &namedArgs)
Parse dictionary substitution argument 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.
void add(GeometricField< typename typeOfSum< Type1, Type2 >::type, GeoMesh, PrimitiveField1 > &gf, const GeometricField< Type1, GeoMesh, PrimitiveField2 > &gf1, const GeometricField< Type2, GeoMesh, PrimitiveField3 > &gf2)
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
labelList first(const UList< labelPair > &p)
Pair< word > dictAndKeyword(const word &scopedName)
Extracts dict name and keyword.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
LList< DLListBase, T > DLList
List< token > tokenList
List of tokens, used for a IOdictionary entry.
Foam::argList args(argc, argv)