50 const Foam::entry* Foam::dictionary::lookupScopedSubEntryPtr
60 if (emarkPos == string::npos || emarkPos == 0)
66 if (slashPos == string::npos)
74 word firstWord = keyword.substr(0, slashPos);
79 return lookupScopedSubEntryPtr
81 keyword.substr(slashPos),
86 else if (firstWord ==
"..")
92 <<
"No parent of current dictionary"
93 <<
" when searching for "
94 << keyword.substr(slashPos, keyword.size() - slashPos)
98 return parent_.lookupScopedSubEntryPtr
100 keyword.substr(slashPos),
107 const entry* entPtr = lookupScopedSubEntryPtr
114 if (entPtr && entPtr->isDict())
116 return entPtr->dict().lookupScopedSubEntryPtr
118 keyword.substr(slashPos, keyword.size() - slashPos),
135 fileName fName = keyword.substr(0, emarkPos);
137 if (!fName.isAbsolute())
145 <<
"Attempt to re-read current dictionary " << fName
151 const word localKeyword = keyword.substr
154 keyword.size() - emarkPos - 1
157 includedDictionary
dict(fName, *
this);
169 <<
"keyword " << localKeyword
170 <<
" is undefined in dictionary "
175 return entryPtr->
clone(*this).ptr();
180 bool Foam::dictionary::findInPatterns
182 const bool patternMatch,
185 DLList<autoPtr<regExp>>::const_iterator& reLink
188 if (patternEntries_.size())
190 while (wcLink != patternEntries_.end())
195 ? reLink()->match(Keyword)
196 : wcLink()->keyword() == Keyword
211 bool Foam::dictionary::findInPatterns
213 const bool patternMatch,
216 DLList<autoPtr<regExp>>::iterator& reLink
219 if (patternEntries_.size())
221 while (wcLink != patternEntries_.end())
226 ? reLink()->match(Keyword)
227 : wcLink()->keyword() == Keyword
242 void Foam::dictionary::assertNoConvertUnits
244 const char* typeName,
246 const unitConversion& defaultUnits,
250 if (!defaultUnits.standard())
253 <<
"Unit conversions are not supported when reading "
260 T Foam::dictionary::readTypeAndConvertUnits
263 const unitConversion& defaultUnits,
268 unitConversion
units(defaultUnits);
269 const bool haveUnits =
units.readIfPresent(keyword, *
this, is);
272 T value = pTraits<T>(is);
275 if (!haveUnits && !is.eof())
277 units.readIfPresent(keyword, *
this, is);
281 units.makeStandard(value);
287 #define IMPLEMENT_SPECIALISED_READ_TYPE(T, nullArg) \
290 Foam::T Foam::dictionary::readType \
292 const word& keyword, \
293 const unitConversion& defaultUnits, \
297 return readTypeAndConvertUnits<T>(keyword, defaultUnits, is); \
301 Foam::T Foam::dictionary::readType \
303 const word& keyword, \
307 return readTypeAndConvertUnits<T>(keyword, unitAny, is); \
310 #define IMPLEMENT_SPECIALISED_READ_PAIR_TYPE(T, nullArg) \
311 IMPLEMENT_SPECIALISED_READ_TYPE(Pair<Foam::T>, nullArg)
313 #define IMPLEMENT_SPECIALISED_READ_LIST_TYPE(T, nullArg) \
314 IMPLEMENT_SPECIALISED_READ_TYPE(List<Foam::T>, nullArg)
320 #undef IMPLEMENT_SPECIALISED_READ_TYPE
321 #undef IMPLEMENT_SPECIALISED_READ_PAIR_TYPE
322 #undef IMPLEMENT_SPECIALISED_READ_LIST_TYPE
350 parentDict.
name().size()
372 hashedEntries_.insert(iter().keyword(), &iter());
374 if (iter().keyword().isPattern())
376 patternEntries_.insert(&iter());
377 patternRegexps_.insert
395 hashedEntries_.insert(iter().keyword(), &iter());
397 if (iter().keyword().isPattern())
399 patternEntries_.insert(&iter());
400 patternRegexps_.insert
441 if (&
p !=
this && !
p.
name().empty())
456 if (&
p !=
this && !
p.
name().empty())
458 const word pKeyword =
p.topDictKeyword();
459 const char pSeparator =
'/';
463 :
word(pKeyword + pSeparator + dictName());
476 return first()->startLineNumber();
489 return filePtr_->lineNumber();
495 return last()->endLineNumber();
545 if (hashedEntries_.found(keyword))
551 if (patternMatch && patternEntries_.size())
554 patternEntries_.begin();
556 patternRegexps_.begin();
559 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
567 return parent_.found(keyword, recursive, patternMatch);
586 if (iter == hashedEntries_.end())
588 if (patternMatch && patternEntries_.size())
591 patternEntries_.begin();
593 patternRegexps_.begin();
596 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
604 return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
625 if (iter == hashedEntries_.end())
627 if (patternMatch && patternEntries_.size())
630 patternEntries_.begin();
632 patternRegexps_.begin();
635 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
643 return const_cast<dictionary&
>(parent_).lookupEntryPtr
667 const entry* result =
nullptr;
669 forAll(keywords, keywordi)
671 const entry* entryPtr =
672 lookupEntryPtr(keywords[keywordi], recursive, patternMatch);
679 <<
"Duplicate backwards compatible keywords \""
681 <<
"\" are defined in dictionary " <<
name() <<
endl
682 <<
"The preferred keyword for this entry is \""
683 << keywords[0] <<
"\"" <<
endl;
703 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
705 if (entryPtr ==
nullptr)
708 <<
"keyword " << keyword <<
" is undefined in dictionary "
724 const entry* entryPtr =
725 lookupEntryPtrBackwardsCompatible(keywords, recursive, patternMatch);
727 if (entryPtr ==
nullptr)
730 return lookupEntry(keywords[0], recursive, patternMatch);
746 return lookupEntry(keyword, recursive, patternMatch).stream();
757 return lookupEntryBackwardsCompatible
774 if (keyword[0] ==
'!')
780 dictPtr = &dictPtr->parent_;
784 return dictPtr->lookupScopedSubEntryPtr
786 keyword.substr(1, keyword.size() - 1),
793 return lookupScopedSubEntryPtr
806 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
810 return entryPtr->
isDict();
821 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
825 return &entryPtr->
dict();
836 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
840 return &entryPtr->
dict();
851 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
853 if (entryPtr ==
nullptr)
856 <<
"keyword " << keyword <<
" is undefined in dictionary "
860 return entryPtr->
dict();
866 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
868 if (entryPtr ==
nullptr)
871 <<
"keyword " << keyword <<
" is undefined in dictionary "
875 return entryPtr->
dict();
884 const entry* entryPtr =
885 lookupEntryPtrBackwardsCompatible(keywords,
false,
true);
887 if (entryPtr ==
nullptr)
890 return subDict(keywords[0]);
894 return entryPtr->
dict();
905 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
907 if (entryPtr ==
nullptr)
912 <<
"keyword " << keyword <<
" is undefined in dictionary "
921 return entryPtr->
dict();
931 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
935 return entryPtr->
dict();
952 const entry* entPtr = lookupScopedEntryPtr
958 if (!entPtr || !entPtr->
isDict())
961 <<
"keyword " << keyword
962 <<
" is undefined in dictionary "
963 <<
name() <<
" or is not a dictionary"
965 <<
"Valid keywords are " << keys()
968 return entPtr->
dict();
977 const_cast<const dictionary*
>(
this)->scopedDict(keyword)
989 keys[nKeys++] = iter().keyword();
998 return hashedEntries_.sortedToc();
1009 if (iter().keyword().isPattern() ? patterns : !patterns)
1011 keys[nKeys++] = iter().keyword();
1027 if (mergeEntry && iter != hashedEntries_.end())
1030 if (iter()->isDict() && entryPtr->
isDict())
1032 iter()->dict().merge(entryPtr->
dict());
1042 hashedEntries_.erase(iter);
1044 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1050 patternEntries_.insert(entryPtr);
1051 patternRegexps_.insert
1062 <<
"problem replacing entry "<< entryPtr->
keyword()
1063 <<
" in dictionary " <<
name() <<
endl;
1072 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
1079 patternEntries_.insert(entryPtr);
1080 patternRegexps_.insert
1101 <<
"attempt to add entry "<< entryPtr->
keyword()
1102 <<
" which already exists in dictionary " <<
name()
1114 add(
e.clone(*this).ptr(), mergeEntry);
1158 void Foam::dictionary::set(
entry* entryPtr)
1160 entry* existingPtr = lookupEntryPtr(entryPtr->
keyword(),
false,
true);
1163 if (existingPtr && existingPtr->
isDict())
1167 add(entryPtr,
true);
1173 set(
e.clone(*this).ptr());
1187 if (iter != hashedEntries_.end())
1191 patternEntries_.begin();
1193 patternRegexps_.begin();
1196 if (findInPatterns(
false, Keyword, wcLink, reLink))
1198 patternEntries_.remove(wcLink);
1199 patternRegexps_.remove(reLink);
1204 hashedEntries_.erase(iter);
1219 remove(Keywords[i]);
1232 if (oldKeyword == newKeyword)
1240 if (iter == hashedEntries_.end())
1245 if (iter()->keyword().isPattern())
1248 <<
"Old keyword "<< oldKeyword
1250 <<
"Pattern replacement not yet implemented."
1258 if (iter2 != hashedEntries_.end())
1262 if (iter2()->keyword().isPattern())
1266 patternEntries_.begin();
1268 patternRegexps_.begin();
1271 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
1273 patternEntries_.remove(wcLink);
1274 patternRegexps_.remove(reLink);
1280 hashedEntries_.erase(iter2);
1288 ) <<
"cannot rename keyword "<< oldKeyword
1289 <<
" to existing keyword " << newKeyword
1290 <<
" in dictionary " <<
name() <<
endl;
1296 iter()->keyword() = newKeyword;
1297 iter()->name() =
name() +
'/' + string::validate<word>(newKeyword);
1298 hashedEntries_.erase(oldKeyword);
1299 hashedEntries_.insert(newKeyword, iter());
1303 patternEntries_.insert(iter());
1304 patternRegexps_.insert
1320 <<
"attempted merge to self for dictionary " <<
name()
1324 bool changed =
false;
1330 if (fnd != hashedEntries_.end())
1334 if (fnd()->isDict() && iter().isDict())
1336 if (fnd()->
dict().merge(iter().
dict()))
1343 add(iter().
clone(*this).ptr(),
true);
1362 hashedEntries_.clear();
1363 patternEntries_.clear();
1364 patternRegexps_.clear();
1375 hashedEntries_.transfer(
dict.hashedEntries_);
1376 patternEntries_.transfer(
dict.patternEntries_);
1377 patternRegexps_.transfer(
dict.patternRegexps_);
1385 return lookup(keyword);
1395 <<
"attempted assignment to self for dictionary " <<
name()
1418 <<
"attempted addition assignment to self for dictionary " <<
name()
1435 <<
"attempted assignment to self for dictionary " <<
name()
1441 if (!
found(iter().keyword()))
1455 <<
"attempted assignment to self for dictionary " <<
name()
1461 set(iter().
clone(*this).ptr());
1502 const string& argString = argStringLine.
first();
1505 funcName = argString;
1508 bool namedArg =
false;
1516 word::const_iterator iter = argString.begin();
1517 iter != argString.end();
1531 funcName = argString(start, i - start);
1536 else if (
c ==
',' ||
c ==
')')
1547 argString(start, i - start),
1559 wordRe(argString(start, i - start)),
1578 argName = argString(start, i - start);
1579 string::stripInvalid<variable>(argName);
1588 string::stripInvalid<word>(funcName);
1599 const string& argString = argStringLine.
first();
1603 bool namedArg =
false;
1611 word::const_iterator iter = argString.begin();
1612 iter != argString.end();
1626 else if (
c ==
',' || std::next(iter) == argString.end())
1628 if (std::next(iter) == argString.end())
1647 argString(start, i - start),
1659 wordRe(argString(start, i - start)),
1669 argName = argString(start, i - start);
1670 string::stripInvalid<variable>(argName);
1688 if (i != string::npos)
1692 scopedName.substr(0, i),
1693 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.
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.
static int writeOptionalEntries
If true write optional keywords and values.
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,.
tokenList tokens() const
Return the dictionary as a list of tokens.
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.
virtual 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.
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.
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 IMPLEMENT_SPECIALISED_READ_PAIR_TYPE(T, nullArg)
#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.
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)
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.
Ostream & endl(Ostream &os)
Add newline and flush stream.
errorManip< error > abort(error &err)
void T(LagrangianPatchField< Type > &f, const LagrangianPatchField< Type > &f1)
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.
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
FOR_ALL_FIELD_TYPES(makeFieldSourceTypedef)
void add(LagrangianPatchField< typename typeOfSum< Type1, Type2 >::type > &f, const LagrangianPatchField< Type1 > &f1, const LagrangianPatchField< Type2 > &f2)
LList< DLListBase, T > DLList
List< token > tokenList
List of tokens, used for a IOdictionary entry.
Foam::argList args(argc, argv)