49 const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
59 if (emarkPos == string::npos || emarkPos == 0)
65 if (slashPos == string::npos)
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())
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::findInPatterns
212 const bool patternMatch,
215 DLList<autoPtr<regExp>>::iterator& reLink
218 if (patternEntries_.size())
220 while (wcLink != patternEntries_.end())
225 ? reLink()->match(Keyword)
226 : wcLink()->keyword() == Keyword
241 void Foam::dictionary::assertNoConvertUnits
243 const char* typeName,
245 const unitConversion& defaultUnits,
249 if (!defaultUnits.standard())
252 <<
"Unit conversions are not supported when reading "
259 T Foam::dictionary::readTypeAndConvertUnits
262 const unitConversion& defaultUnits,
267 unitConversion
units(defaultUnits);
268 const bool haveUnits =
units.readIfPresent(keyword, *
this, is);
271 T value = pTraits<T>(is);
274 if (!haveUnits && !is.eof())
276 units.readIfPresent(keyword, *
this, is);
280 units.makeStandard(value);
286 #define IMPLEMENT_SPECIALISED_READ_TYPE(T, nullArg) \
289 Foam::T Foam::dictionary::readType \
291 const word& keyword, \
292 const unitConversion& defaultUnits, \
296 return readTypeAndConvertUnits<T>(keyword, defaultUnits, is); \
300 Foam::T Foam::dictionary::readType \
302 const word& keyword, \
306 return readTypeAndConvertUnits<T>(keyword, unitAny, is); \
309 #define IMPLEMENT_SPECIALISED_READ_LIST_TYPE(T, nullArg) \
310 IMPLEMENT_SPECIALISED_READ_TYPE(List<Foam::T>, nullArg)
315 #undef IMPLEMENT_SPECIALISED_READ_TYPE
345 hashedEntries_.insert(iter().keyword(), &iter());
347 if (iter().keyword().isPattern())
349 patternEntries_.insert(&iter());
350 patternRegexps_.insert
370 hashedEntries_.insert(iter().keyword(), &iter());
372 if (iter().keyword().isPattern())
374 patternEntries_.insert(&iter());
375 patternRegexps_.insert
418 if (&
p !=
this && !
p.
name().empty())
433 if (&
p !=
this && !
p.
name().empty())
435 const word pKeyword =
p.topDictKeyword();
436 const char pSeparator =
'/';
440 :
word(pKeyword + pSeparator + dictName());
453 return first()->startLineNumber();
466 return last()->endLineNumber();
515 if (hashedEntries_.found(keyword))
521 if (patternMatch && patternEntries_.size())
524 patternEntries_.begin();
526 patternRegexps_.begin();
529 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
537 return parent_.found(keyword, recursive, patternMatch);
556 if (iter == hashedEntries_.end())
558 if (patternMatch && patternEntries_.size())
561 patternEntries_.begin();
563 patternRegexps_.begin();
566 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
574 return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
595 if (iter == hashedEntries_.end())
597 if (patternMatch && patternEntries_.size())
600 patternEntries_.begin();
602 patternRegexps_.begin();
605 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
613 return const_cast<dictionary&
>(parent_).lookupEntryPtr
637 const entry* result =
nullptr;
639 forAll(keywords, keywordi)
641 const entry* entryPtr =
642 lookupEntryPtr(keywords[keywordi], recursive, patternMatch);
649 <<
"Duplicate backwards compatible keywords \""
651 <<
"\" are defined in dictionary " <<
name() <<
endl
652 <<
"The preferred keyword for this entry is \""
653 << keywords[0] <<
"\"" <<
endl;
673 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
675 if (entryPtr ==
nullptr)
678 <<
"keyword " << keyword <<
" is undefined in dictionary "
694 const entry* entryPtr =
695 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
697 if (entryPtr ==
nullptr)
700 return lookupEntry(keywords[0], recursive, patternMatch);
716 return lookupEntry(keyword, recursive, patternMatch).stream();
727 return lookupEntryBackwardsCompatible
744 if (keyword[0] ==
'!')
750 dictPtr = &dictPtr->parent_;
754 return dictPtr->lookupScopedSubEntryPtr
756 keyword.substr(1, keyword.size() - 1),
763 return lookupScopedSubEntryPtr
775 word varName = keyword(1, keyword.size() - 1);
778 const entry* ePtr = lookupScopedEntryPtr(varName,
true,
true);
800 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
804 return entryPtr->
isDict();
815 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
819 return &entryPtr->
dict();
830 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
834 return &entryPtr->
dict();
845 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
847 if (entryPtr ==
nullptr)
850 <<
"keyword " << keyword <<
" is undefined in dictionary "
854 return entryPtr->
dict();
860 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
862 if (entryPtr ==
nullptr)
865 <<
"keyword " << keyword <<
" is undefined in dictionary "
869 return entryPtr->
dict();
878 const entry* entryPtr =
879 lookupEntryPtrBackwardsCompatible(keywords,
false,
true);
881 if (entryPtr ==
nullptr)
884 return subDict(keywords[0]);
888 return entryPtr->
dict();
899 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
901 if (entryPtr ==
nullptr)
906 <<
"keyword " << keyword <<
" is undefined in dictionary "
915 return entryPtr->
dict();
925 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
929 return entryPtr->
dict();
946 const entry* entPtr = lookupScopedEntryPtr
952 if (!entPtr || !entPtr->
isDict())
955 <<
"keyword " << keyword
956 <<
" is undefined in dictionary "
957 <<
name() <<
" or is not a dictionary"
959 <<
"Valid keywords are " << keys()
962 return entPtr->
dict();
971 const_cast<const dictionary*
>(
this)->scopedDict(keyword)
983 keys[nKeys++] = iter().keyword();
992 return hashedEntries_.sortedToc();
1003 if (iter().keyword().isPattern() ? patterns : !patterns)
1005 keys[nKeys++] = iter().keyword();
1021 if (mergeEntry && iter != hashedEntries_.end())
1024 if (iter()->isDict() && entryPtr->
isDict())
1026 iter()->dict().merge(entryPtr->
dict());
1036 hashedEntries_.erase(iter);
1038 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1044 patternEntries_.insert(entryPtr);
1045 patternRegexps_.insert
1056 <<
"problem replacing entry "<< entryPtr->
keyword()
1057 <<
" in dictionary " <<
name() <<
endl;
1066 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1073 patternEntries_.insert(entryPtr);
1074 patternRegexps_.insert
1095 <<
"attempt to add entry "<< entryPtr->
keyword()
1096 <<
" which already exists in dictionary " <<
name()
1108 add(
e.clone(*this).ptr(), mergeEntry);
1154 entry* existingPtr = lookupEntryPtr(entryPtr->
keyword(),
false,
true);
1157 if (existingPtr && existingPtr->
isDict())
1161 add(entryPtr,
true);
1167 set(
e.clone(*this).ptr());
1181 if (iter != hashedEntries_.end())
1185 patternEntries_.begin();
1187 patternRegexps_.begin();
1190 if (findInPatterns(
false, Keyword, wcLink, reLink))
1192 patternEntries_.remove(wcLink);
1193 patternRegexps_.remove(reLink);
1198 hashedEntries_.erase(iter);
1217 if (oldKeyword == newKeyword)
1225 if (iter == hashedEntries_.end())
1230 if (iter()->keyword().isPattern())
1233 <<
"Old keyword "<< oldKeyword
1235 <<
"Pattern replacement not yet implemented."
1243 if (iter2 != hashedEntries_.end())
1247 if (iter2()->keyword().isPattern())
1251 patternEntries_.begin();
1253 patternRegexps_.begin();
1256 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
1258 patternEntries_.remove(wcLink);
1259 patternRegexps_.remove(reLink);
1265 hashedEntries_.erase(iter2);
1273 ) <<
"cannot rename keyword "<< oldKeyword
1274 <<
" to existing keyword " << newKeyword
1275 <<
" in dictionary " <<
name() <<
endl;
1281 iter()->keyword() = newKeyword;
1282 iter()->name() =
name() +
'/' + newKeyword;
1283 hashedEntries_.erase(oldKeyword);
1284 hashedEntries_.insert(newKeyword, iter());
1288 patternEntries_.insert(iter());
1289 patternRegexps_.insert
1305 <<
"attempted merge to self for dictionary " <<
name()
1309 bool changed =
false;
1315 if (fnd != hashedEntries_.end())
1319 if (fnd()->isDict() && iter().isDict())
1321 if (fnd()->
dict().merge(iter().
dict()))
1328 add(iter().
clone(*this).ptr(),
true);
1347 hashedEntries_.clear();
1348 patternEntries_.clear();
1349 patternRegexps_.clear();
1360 hashedEntries_.transfer(
dict.hashedEntries_);
1361 patternEntries_.transfer(
dict.patternEntries_);
1362 patternRegexps_.transfer(
dict.patternRegexps_);
1370 return lookup(keyword);
1380 <<
"attempted assignment to self for dictionary " <<
name()
1403 <<
"attempted addition assignment to self for dictionary " <<
name()
1420 <<
"attempted assignment to self for dictionary " <<
name()
1426 if (!
found(iter().keyword()))
1440 <<
"attempted assignment to self for dictionary " <<
name()
1446 set(iter().
clone(*this).ptr());
1481 const string& argString,
1487 funcName = argString;
1490 bool namedArg =
false;
1498 word::const_iterator iter = argString.begin();
1499 iter != argString.end();
1509 funcName = argString(start, i - start);
1514 else if (
c ==
',' ||
c ==
')')
1525 argString(start, i - start)
1532 args.append(
wordRe(argString(start, i - start)));
1548 argName = argString(start, i - start);
1549 string::stripInvalid<variable>(argName);
1558 string::stripInvalid<word>(funcName);
1564 const string& argString,
1570 bool namedArg =
false;
1578 word::const_iterator iter = argString.begin();
1579 iter != argString.end();
1589 else if (
c ==
',' || std::next(iter) == argString.end())
1591 if (std::next(iter) == argString.end())
1610 argString(start, i - start)
1617 args.append(
wordRe(argString(start, i - start)));
1624 argName = argString(start, i - start);
1625 string::stripInvalid<variable>(argName);
1643 if (i != string::npos)
1647 scopedName.substr(0, i),
1648 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.
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.
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'.
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.
fileName path() const
Return directory path name (part before 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,...
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 IMPLEMENT_SPECIALISED_READ_TYPE(T, nullArg)
#define IMPLEMENT_SPECIALISED_READ_LIST_TYPE(T, nullArg)
#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)
const HashTable< unitConversion > & units()
Get the table of unit conversions.
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)
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
LList< DLListBase, T > DLList
List< token > tokenList
List of tokens, used for a IOdictionary entry.
Foam::argList args(argc, argv)