Go to the documentation of this file.
51 const bool patternMatch,
57 if (patternEntries_.size())
59 while (wcLink != patternEntries_.
end())
64 ? reLink()->match(Keyword)
65 : wcLink()->keyword() == Keyword
82 const bool patternMatch,
88 if (patternEntries_.size())
90 while (wcLink != patternEntries_.
end())
95 ? reLink()->match(Keyword)
96 : wcLink()->keyword() == Keyword
138 hashedEntries_.insert(iter().keyword(), &iter());
140 if (iter().keyword().isPattern())
142 patternEntries_.insert(&iter());
143 patternRegexps_.insert
163 hashedEntries_.insert(iter().keyword(), &iter());
165 if (iter().keyword().isPattern())
167 patternEntries_.insert(&iter());
168 patternRegexps_.insert
233 if (&
p !=
this && !
p.name().empty())
248 return first()->startLineNumber();
261 return last()->endLineNumber();
310 if (hashedEntries_.found(keyword))
316 if (patternMatch && patternEntries_.size())
319 patternEntries_.
begin();
321 patternRegexps_.
begin();
324 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
332 return parent_.found(keyword, recursive, patternMatch);
351 if (iter == hashedEntries_.end())
353 if (patternMatch && patternEntries_.size())
356 patternEntries_.
begin();
358 patternRegexps_.
begin();
361 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
369 return parent_.lookupEntryPtr(keyword, recursive, patternMatch);
390 if (iter == hashedEntries_.end())
392 if (patternMatch && patternEntries_.size())
395 patternEntries_.
begin();
397 patternRegexps_.
begin();
400 if (findInPatterns(patternMatch, keyword, wcLink, reLink))
408 return const_cast<dictionary&
>(parent_).lookupEntryPtr
432 const entry* entryPtr = lookupEntryPtr(keyword, recursive, patternMatch);
434 if (entryPtr == NULL)
439 ) <<
"keyword " << keyword <<
" is undefined in dictionary "
455 return lookupEntry(keyword, recursive, patternMatch).stream();
466 if (keyword[0] ==
':')
478 keyword.substr(1, keyword.size()-1),
487 if (dotPos == string::npos)
490 return lookupEntryPtr(keyword, recursive, patternMatch);
501 string::const_iterator iter = keyword.begin() + begVar;
505 iter != keyword.end()
518 ) <<
"No parent of current dictionary"
519 <<
" when searching for "
520 << keyword.substr(begVar, keyword.size()-begVar)
528 keyword.substr(endVar),
536 word firstWord = keyword.substr(0, dotPos);
538 const entry* entPtr = lookupScopedEntryPtr
550 ) <<
"keyword " << firstWord
551 <<
" is undefined in dictionary "
553 <<
"Valid keywords are " << keys()
561 keyword.substr(dotPos, keyword.size()-dotPos),
578 word varName = keyword(1, keyword.size()-1);
581 const entry* ePtr = lookupScopedEntryPtr(varName,
true,
true);
603 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
607 return entryPtr->
isDict();
618 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
622 return &entryPtr->
dict();
633 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
635 if (entryPtr == NULL)
640 ) <<
"keyword " << keyword <<
" is undefined in dictionary "
644 return entryPtr->
dict();
650 entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
652 if (entryPtr == NULL)
657 ) <<
"keyword " << keyword <<
" is undefined in dictionary "
661 return entryPtr->
dict();
671 const entry* entryPtr = lookupEntryPtr(keyword,
false,
true);
673 if (entryPtr == NULL)
680 ) <<
"keyword " << keyword <<
" is undefined in dictionary "
683 return entryPtr->
dict();
692 return entryPtr->
dict();
704 keys[nKeys++] = iter().keyword();
718 if (iter().keyword().isPattern() ? patterns : !patterns)
720 keys[nKeys++] = iter().keyword();
736 if (mergeEntry && iter != hashedEntries_.end())
739 if (iter()->isDict() && entryPtr->
isDict())
741 iter()->dict().merge(entryPtr->
dict());
751 hashedEntries_.erase(iter);
753 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
759 patternEntries_.insert(entryPtr);
760 patternRegexps_.insert
771 <<
"problem replacing entry "<< entryPtr->
keyword()
772 <<
" in dictionary " <<
name() <<
endl;
781 if (hashedEntries_.insert(entryPtr->
keyword(), entryPtr))
788 patternEntries_.insert(entryPtr);
789 patternRegexps_.insert
800 <<
"attempt to add entry "<< entryPtr->
keyword()
801 <<
" which already exists in dictionary " <<
name()
812 add(
e.clone(*this).ptr(), mergeEntry);
858 entry* existingPtr = lookupEntryPtr(entryPtr->
keyword(),
false,
true);
861 if (existingPtr && existingPtr->
isDict())
871 set(
e.clone(*this).ptr());
885 if (iter != hashedEntries_.end())
889 patternEntries_.
begin();
891 patternRegexps_.
begin();
894 if (findInPatterns(
false, Keyword, wcLink, reLink))
896 patternEntries_.remove(wcLink);
897 patternRegexps_.remove(reLink);
902 hashedEntries_.erase(iter);
921 if (oldKeyword == newKeyword)
929 if (iter == hashedEntries_.end())
934 if (iter()->keyword().isPattern())
939 ) <<
"Old keyword "<< oldKeyword
941 <<
"Pattern replacement not yet implemented."
949 if (iter2 != hashedEntries_.end())
953 if (iter2()->keyword().isPattern())
957 patternEntries_.
begin();
959 patternRegexps_.
begin();
962 if (findInPatterns(
false, iter2()->keyword(), wcLink, reLink))
964 patternEntries_.remove(wcLink);
965 patternRegexps_.remove(reLink);
971 hashedEntries_.erase(iter2);
979 ) <<
"cannot rename keyword "<< oldKeyword
980 <<
" to existing keyword " << newKeyword
981 <<
" in dictionary " <<
name() <<
endl;
987 iter()->keyword() = newKeyword;
988 iter()->name() =
name() +
'.' + newKeyword;
989 hashedEntries_.erase(oldKeyword);
990 hashedEntries_.insert(newKeyword, iter());
994 patternEntries_.insert(iter());
995 patternRegexps_.insert
1011 <<
"attempted merge to self for dictionary " <<
name()
1015 bool changed =
false;
1021 if (fnd != hashedEntries_.end())
1025 if (fnd()->isDict() && iter().isDict())
1034 add(iter().clone(*this).ptr(),
true);
1041 add(iter().clone(*this).ptr());
1053 hashedEntries_.clear();
1054 patternEntries_.clear();
1055 patternRegexps_.clear();
1092 <<
"attempted assignment to self for dictionary " <<
name()
1104 add(iter().clone(*this).ptr());
1115 <<
"attempted addition assignment to self for dictionary " <<
name()
1121 add(iter().clone(*this).ptr());
1132 <<
"attempted assignment to self for dictionary " <<
name()
1138 if (!
found(iter().keyword()))
1140 add(iter().clone(*this).ptr());
1152 <<
"attempted assignment to self for dictionary " <<
name()
1158 set(iter().clone(*this).ptr());
A keyword and a list of tokens is an 'entry'.
const dictionary & parent_
Parent dictionary.
A keyword and a list of tokens is a 'dictionaryEntry'.
const entry & lookupEntry(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream if present otherwise error.
Xfer< List< T > > xfer()
Transfer contents to the Xfer container as a plain List.
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
A keyword and a list of tokens is a 'primitiveEntry'. An primitiveEntry can be read,...
A class for handling words, derived from string.
#define forAllIter(Container, container, iter)
Iterate across all elements in the container object of type.
A class for handling file names.
An STL-conforming iterator.
const keyType & keyword() const
Return keyword.
Non-intrusive doubly-linked list.
ITstream & operator[](const word &) const
Find and return entry.
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.
bool isPattern() const
Should be treated as a match rather than a literal string.
dictionary()
Construct top-level dictionary null.
int infoSwitch(const char *name, const int defaultValue=0)
Lookup info switch or add default value.
An STL-conforming const_iterator.
void operator<<=(const dictionary &)
Unconditionally include entries from the given dictionary.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
bool remove(const word &)
Remove an entry specified by keyword.
void operator=(const dictionary &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
A token holds items read from Istream.
A class for handling character strings derived from std::string.
A simple container for copying or transferring objects of type <T>.
bool isDict(const word &) const
Check if entry is a sub-dictionary.
string str() const
Return the string.
Wrapper around POSIX extended regular expressions.
forAllConstIter(PtrDictionary< phaseModel >, mixture.phases(), phase)
void transfer(ILList< LListBase, T > &)
Transfer the contents of the argument into this List.
List< keyType > keys(bool patterns=false) const
Return the list of available keys or patterns.
bool changeKeyword(const keyType &oldKeyword, const keyType &newKeyword, bool forceOverwrite=false)
Change the keyword for an entry,.
A class for handling keywords in dictionaries.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
virtual bool isDict() const
Return true if this entry is a dictionary.
HashTable< entry * > hashedEntries_
HashTable of the entries held on the DL-list for quick lookup.
virtual ~dictionary()
Destructor.
label startLineNumber() const
Return line number of first token in dictionary.
label endLineNumber() const
Return line number of last token in dictionary.
bool merge(const dictionary &)
Merge entries from the given dictionary.
graph_traits< Graph >::vertices_size_type size_type
void clear()
Clear the contents of the list.
const dictionary & topDict() const
Return the top of the tree.
The output stream for calculating SHA1 digests.
const entry * lookupScopedEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
A list of keyword definitions, which are a keyword followed by any number of values (e....
DLList< autoPtr< regExp > > patternRegexps_
Patterns as precompiled regular expressions.
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
DLList< entry * > patternEntries_
Entries of matching patterns.
Input from memory buffer stream.
errorManip< error > abort(error &err)
const double e
Elementary charge.
virtual const dictionary & dict() const =0
Return dictionary if this entry is a dictionary.
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.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
virtual const fileName & name() const =0
Return the dictionary name.
DynamicList< T, SizeInc, SizeMult, SizeDiv > & append(const T &)
Append an element at the end of the list.
errorManipArg< error, int > exit(error &err, const int errNo=1)
bool substituteScopedKeyword(const word &keyword)
Substitute the given scoped keyword prepended by '$' with the.
List< token > tokenList
List of tokens, used for a IOdictionary entry.
static bool writeOptionalEntries
If true write optional keywords and values.
void setSize(const label)
Reset size of List.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
void operator+=(const dictionary &)
Include entries from the given dictionary.
void operator|=(const dictionary &)
Conditionally include entries from the given dictionary.
const entry * lookupEntryPtr(const word &, bool recursive, bool patternMatch) const
Find and return an entry data stream pointer if present.
Xfer< T > xferMove(T &)
Construct by transferring the contents of the arg.
virtual Istream & read(token &)
Return next token from stream.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Output to memory buffer stream.
void transfer(dictionary &)
Transfer the contents of the argument and annul the argument.
label k
Boltzmann constant.
autoPtr< dictionary > clone() const
Construct and return clone.
dictionary subOrEmptyDict(const word &, const bool mustRead=false) const
Find and return a sub-dictionary as a copy, or.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &df)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
tokenList tokens() const
Return the dictionary as a list of tokens.
wordList toc() const
Return the table of contents.
SHA1Digest digest() const
Return the SHA1 digest of the dictionary contents.
#define IOWarningInFunction(ios)
Report an IO warning using Foam::Warning.
Foam::SHA1Digest digest()
Return SHA1::Digest for the data processed until now.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
defineTypeNameAndDebug(combustionModel, 0)
void clear()
Clear the dictionary.
bool merge(dictionary &, const dictionary &, const bool, const HashTable< wordList, word > &)
word name(const complex &)
Return a string representation of a complex.
Xfer< dictionary > xfer()
Transfer contents to the Xfer container.
bool findInPatterns(const bool patternMatch, const word &Keyword, DLList< entry * >::const_iterator &wcLink, DLList< autoPtr< regExp > >::const_iterator &reLink) const
Search patterns table for exact match or regular expression match.
static const dictionary null
Null dictionary.
const dictionary * subDictPtr(const word &) const
Find and return a sub-dictionary pointer if present.
bool add(entry *, bool mergeEntry=false)
Add a new entry.
stressControl lookup("compactNormalStress") >> compactNormalStress
void set(entry *)
Assign a new entry, overwrite any existing entry.