mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
wildcards in dictionaries
This commit is contained in:
@ -100,13 +100,23 @@ int main(int argc, char *argv[])
|
||||
|
||||
if (dict.found(entryNames[0]))
|
||||
{
|
||||
const entry* entPtr = &dict.lookupEntry(entryNames[0]);
|
||||
const entry* entPtr = &dict.lookupEntry
|
||||
(
|
||||
entryNames[0],
|
||||
false,
|
||||
true // wildcards
|
||||
);
|
||||
|
||||
for (int i=1; i<entryNames.size(); i++)
|
||||
{
|
||||
if (entPtr->dict().found(entryNames[i]))
|
||||
{
|
||||
entPtr = &entPtr->dict().lookupEntry(entryNames[i]);
|
||||
entPtr = &entPtr->dict().lookupEntry
|
||||
(
|
||||
entryNames[i],
|
||||
false,
|
||||
true // wildcards
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -37,7 +37,7 @@ inline Foam::word Foam::vtkPV3Foam::getFirstWord(const char* str)
|
||||
{
|
||||
++n;
|
||||
}
|
||||
return word(str, n);
|
||||
return word(str, n, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -164,7 +164,16 @@ int main(int argc, char *argv[])
|
||||
forAll(dictList, i)
|
||||
{
|
||||
doneKeys[i] = dictList[i].keyword();
|
||||
dictList.set(i, fieldDict.lookupEntry(doneKeys[i]).clone());
|
||||
dictList.set
|
||||
(
|
||||
i,
|
||||
fieldDict.lookupEntry
|
||||
(
|
||||
doneKeys[i],
|
||||
false,
|
||||
true
|
||||
).clone()
|
||||
);
|
||||
fieldDict.remove(doneKeys[i]);
|
||||
}
|
||||
// Add remaining entries
|
||||
|
||||
@ -39,6 +39,7 @@ $(strings)/word/word.C
|
||||
$(strings)/word/wordIO.C
|
||||
$(strings)/fileName/fileName.C
|
||||
$(strings)/fileName/fileNameIO.C
|
||||
$(strings)/keyType/keyTypeIO.C
|
||||
|
||||
primitives/random/Random.C
|
||||
|
||||
|
||||
@ -22,15 +22,31 @@ License
|
||||
along with OpenFOAM; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "word.H"
|
||||
#include "Ostream.H"
|
||||
#include "token.H"
|
||||
#include "keyType.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
//- Write keyType
|
||||
Foam::Ostream& Foam::Ostream::write(const keyType& s)
|
||||
{
|
||||
// Write as word?
|
||||
if (s.isWildCard())
|
||||
{
|
||||
return write(static_cast<const string&>(s));
|
||||
}
|
||||
else
|
||||
{
|
||||
return write(static_cast<const word&>(s));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//- Decrememt the indent level
|
||||
void Foam::Ostream::decrIndent()
|
||||
{
|
||||
@ -47,7 +63,7 @@ void Foam::Ostream::decrIndent()
|
||||
|
||||
|
||||
// Write the keyword to the Ostream followed by appropriate indentation
|
||||
Foam::Ostream& Foam::Ostream::writeKeyword(const Foam::word& keyword)
|
||||
Foam::Ostream& Foam::Ostream::writeKeyword(const Foam::keyType& keyword)
|
||||
{
|
||||
indent();
|
||||
write(keyword);
|
||||
|
||||
@ -35,6 +35,7 @@ Description
|
||||
#define Ostream_H
|
||||
|
||||
#include "IOstream.H"
|
||||
#include "keyType.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -105,6 +106,9 @@ public:
|
||||
//- Write word
|
||||
virtual Ostream& write(const word&) = 0;
|
||||
|
||||
//- Write keyType
|
||||
virtual Ostream& write(const keyType&);
|
||||
|
||||
//- Write string
|
||||
virtual Ostream& write(const string&) = 0;
|
||||
|
||||
@ -146,7 +150,7 @@ public:
|
||||
|
||||
//- Write the keyword to the Ostream followed by
|
||||
// appropriate indentation
|
||||
Ostream& writeKeyword(const word& keyword);
|
||||
Ostream& writeKeyword(const keyType& keyword);
|
||||
|
||||
|
||||
// Stream state functions
|
||||
|
||||
@ -34,6 +34,72 @@ defineTypeNameAndDebug(Foam::dictionary, 0);
|
||||
|
||||
const Foam::dictionary Foam::dictionary::null;
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
bool Foam::dictionary::findInWildcards
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::const_iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::const_iterator& reLink
|
||||
) const
|
||||
{
|
||||
if (wildCardEntries_.size() > 0)
|
||||
{
|
||||
//wcLink = wildCardEntries_.begin();
|
||||
//reLink = wildCardRegexps_.end();
|
||||
|
||||
while (wcLink != wildCardEntries_.end())
|
||||
{
|
||||
if (!wildCardMatch && wcLink()->keyword() == Keyword)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (wildCardMatch && reLink()->matches(Keyword))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
++reLink;
|
||||
++wcLink;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dictionary::findInWildcards
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::iterator& reLink
|
||||
)
|
||||
{
|
||||
if (wildCardEntries_.size() > 0)
|
||||
{
|
||||
while (wcLink != wildCardEntries_.end())
|
||||
{
|
||||
if (!wildCardMatch && wcLink()->keyword() == Keyword)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (wildCardMatch && reLink()->matches(Keyword))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
++reLink;
|
||||
++wcLink;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::dictionary::dictionary()
|
||||
@ -60,6 +126,18 @@ Foam::dictionary::dictionary
|
||||
)
|
||||
{
|
||||
hashedEntries_.insert(iter().keyword(), &iter());
|
||||
|
||||
if (iter().keyword().isWildCard())
|
||||
{
|
||||
wildCardEntries_.insert(&iter());
|
||||
wildCardRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(iter().keyword())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,6 +159,18 @@ Foam::dictionary::dictionary
|
||||
)
|
||||
{
|
||||
hashedEntries_.insert(iter().keyword(), &iter());
|
||||
|
||||
if (iter().keyword().isWildCard())
|
||||
{
|
||||
wildCardEntries_.insert(&iter());
|
||||
wildCardRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(iter().keyword())
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -133,13 +223,29 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if (recursive && &parent_ != &dictionary::null)
|
||||
{
|
||||
return parent_.found(keyword, recursive);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
if (wildCardEntries_.size() > 0)
|
||||
{
|
||||
DLList<entry*>::const_iterator wcLink = wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::const_iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
|
||||
// Find in wildcards using regular expressions only
|
||||
if (findInWildcards(true, keyword, wcLink, reLink))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive && &parent_ != &dictionary::null)
|
||||
{
|
||||
return parent_.found(keyword, recursive);
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -147,16 +253,31 @@ bool Foam::dictionary::found(const word& keyword, bool recursive) const
|
||||
const Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
) const
|
||||
{
|
||||
HashTable<entry*>::const_iterator iter = hashedEntries_.find(keyword);
|
||||
|
||||
if (iter == hashedEntries_.end())
|
||||
{
|
||||
if (wildCardMatch && wildCardEntries_.size() > 0)
|
||||
{
|
||||
DLList<entry*>::const_iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::const_iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
|
||||
// Find in wildcards using regular expressions only
|
||||
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
|
||||
{
|
||||
return wcLink();
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive && &parent_ != &dictionary::null)
|
||||
{
|
||||
return parent_.lookupEntryPtr(keyword, recursive);
|
||||
return parent_.lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -171,19 +292,34 @@ const Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
)
|
||||
{
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find(keyword);
|
||||
|
||||
if (iter == hashedEntries_.end())
|
||||
{
|
||||
if (wildCardMatch && wildCardEntries_.size() > 0)
|
||||
{
|
||||
DLList<entry*>::iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
// Find in wildcards using regular expressions only
|
||||
if (findInWildcards(wildCardMatch, keyword, wcLink, reLink))
|
||||
{
|
||||
return wcLink();
|
||||
}
|
||||
}
|
||||
|
||||
if (recursive && &parent_ != &dictionary::null)
|
||||
{
|
||||
return const_cast<dictionary&>(parent_).lookupEntryPtr
|
||||
(
|
||||
keyword,
|
||||
recursive
|
||||
recursive,
|
||||
wildCardMatch
|
||||
);
|
||||
}
|
||||
else
|
||||
@ -199,16 +335,17 @@ Foam::entry* Foam::dictionary::lookupEntryPtr
|
||||
const Foam::entry& Foam::dictionary::lookupEntry
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
(
|
||||
"dictionary::lookupEntry(const word& keyword) const",
|
||||
"dictionary::lookupEntry(const word&, bool, bool) const",
|
||||
*this
|
||||
) << "keyword " << keyword << " is undefined in dictionary "
|
||||
<< name()
|
||||
@ -222,16 +359,18 @@ const Foam::entry& Foam::dictionary::lookupEntry
|
||||
Foam::ITstream& Foam::dictionary::lookup
|
||||
(
|
||||
const word& keyword,
|
||||
bool recursive
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
) const
|
||||
{
|
||||
return lookupEntry(keyword, recursive).stream();
|
||||
return lookupEntry(keyword, recursive, wildCardMatch).stream();
|
||||
}
|
||||
|
||||
|
||||
bool Foam::dictionary::isDict(const word& keyword) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword);
|
||||
// Find non-recursive with wildcards
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, false, true);
|
||||
|
||||
if (entryPtr)
|
||||
{
|
||||
@ -246,7 +385,7 @@ bool Foam::dictionary::isDict(const word& keyword) const
|
||||
|
||||
const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, false, true);
|
||||
|
||||
if (entryPtr)
|
||||
{
|
||||
@ -261,7 +400,8 @@ const Foam::dictionary* Foam::dictionary::subDictPtr(const word& keyword) const
|
||||
|
||||
const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, false, true);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
@ -278,7 +418,8 @@ const Foam::dictionary& Foam::dictionary::subDict(const word& keyword) const
|
||||
|
||||
Foam::dictionary& Foam::dictionary::subDict(const word& keyword)
|
||||
{
|
||||
entry* entryPtr = lookupEntryPtr(keyword);
|
||||
entry* entryPtr = lookupEntryPtr(keyword, false, true);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
FatalIOErrorIn
|
||||
@ -314,7 +455,10 @@ Foam::wordList Foam::dictionary::toc() const
|
||||
|
||||
bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
||||
{
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find(entryPtr->keyword());
|
||||
HashTable<entry*>::iterator iter = hashedEntries_.find
|
||||
(
|
||||
entryPtr->keyword()
|
||||
);
|
||||
|
||||
if (mergeEntry && iter != hashedEntries_.end())
|
||||
{
|
||||
@ -336,6 +480,19 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
||||
if (hashedEntries_.insert(entryPtr->keyword(), entryPtr))
|
||||
{
|
||||
entryPtr->name() = name_ + "::" + entryPtr->keyword();
|
||||
|
||||
if (entryPtr->keyword().isWildCard())
|
||||
{
|
||||
wildCardEntries_.insert(entryPtr);
|
||||
wildCardRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(entryPtr->keyword())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -356,6 +513,18 @@ bool Foam::dictionary::add(entry* entryPtr, bool mergeEntry)
|
||||
entryPtr->name() = name_ + "::" + entryPtr->keyword();
|
||||
IDLList<entry>::append(entryPtr);
|
||||
|
||||
if (entryPtr->keyword().isWildCard())
|
||||
{
|
||||
wildCardEntries_.insert(entryPtr);
|
||||
wildCardRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(entryPtr->keyword())
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else
|
||||
@ -376,27 +545,37 @@ void Foam::dictionary::add(const entry& e, bool mergeEntry)
|
||||
add(e.clone(*this).ptr(), mergeEntry);
|
||||
}
|
||||
|
||||
void Foam::dictionary::add(const word& k, const word& w, bool overwrite)
|
||||
void Foam::dictionary::add(const keyType& k, const word& w, bool overwrite)
|
||||
{
|
||||
add(new primitiveEntry(k, token(w)), overwrite);
|
||||
}
|
||||
|
||||
void Foam::dictionary::add(const word& k, const Foam::string& s, bool overwrite)
|
||||
void Foam::dictionary::add
|
||||
(
|
||||
const keyType& k,
|
||||
const Foam::string& s,
|
||||
bool overwrite
|
||||
)
|
||||
{
|
||||
add(new primitiveEntry(k, token(s)), overwrite);
|
||||
}
|
||||
|
||||
void Foam::dictionary::add(const word& k, const label l, bool overwrite)
|
||||
void Foam::dictionary::add(const keyType& k, const label l, bool overwrite)
|
||||
{
|
||||
add(new primitiveEntry(k, token(l)), overwrite);
|
||||
}
|
||||
|
||||
void Foam::dictionary::add(const word& k, const scalar s, bool overwrite)
|
||||
void Foam::dictionary::add(const keyType& k, const scalar s, bool overwrite)
|
||||
{
|
||||
add(new primitiveEntry(k, token(s)), overwrite);
|
||||
}
|
||||
|
||||
void Foam::dictionary::add(const word& k, const dictionary& d, bool mergeEntry)
|
||||
void Foam::dictionary::add
|
||||
(
|
||||
const keyType& k,
|
||||
const dictionary& d,
|
||||
bool mergeEntry
|
||||
)
|
||||
{
|
||||
add(new dictionaryEntry(k, *this, d), mergeEntry);
|
||||
}
|
||||
@ -404,7 +583,7 @@ void Foam::dictionary::add(const word& k, const dictionary& d, bool mergeEntry)
|
||||
|
||||
void Foam::dictionary::set(entry* entryPtr)
|
||||
{
|
||||
entry* existingPtr = lookupEntryPtr(entryPtr->keyword());
|
||||
entry* existingPtr = lookupEntryPtr(entryPtr->keyword(), false, true);
|
||||
|
||||
// clear dictionary so merge acts like overwrite
|
||||
if (existingPtr && existingPtr->isDict())
|
||||
@ -420,7 +599,7 @@ void Foam::dictionary::set(const entry& e)
|
||||
set(e.clone(*this).ptr());
|
||||
}
|
||||
|
||||
void Foam::dictionary::set(const word& k, const dictionary& d)
|
||||
void Foam::dictionary::set(const keyType& k, const dictionary& d)
|
||||
{
|
||||
set(new dictionaryEntry(k, *this, d));
|
||||
}
|
||||
@ -432,6 +611,19 @@ bool Foam::dictionary::remove(const word& Keyword)
|
||||
|
||||
if (iter != hashedEntries_.end())
|
||||
{
|
||||
// Delete from wildcards first
|
||||
DLList<entry*>::iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
|
||||
// Find in wildcards using exact match only
|
||||
if (findInWildcards(false, Keyword, wcLink, reLink))
|
||||
{
|
||||
wildCardEntries_.remove(wcLink);
|
||||
wildCardRegexps_.remove(reLink);
|
||||
}
|
||||
|
||||
IDLList<entry>::remove(iter());
|
||||
delete iter();
|
||||
hashedEntries_.erase(iter);
|
||||
@ -447,8 +639,8 @@ bool Foam::dictionary::remove(const word& Keyword)
|
||||
|
||||
bool Foam::dictionary::changeKeyword
|
||||
(
|
||||
const word& oldKeyword,
|
||||
const word& newKeyword,
|
||||
const keyType& oldKeyword,
|
||||
const keyType& newKeyword,
|
||||
bool forceOverwrite
|
||||
)
|
||||
{
|
||||
@ -466,6 +658,18 @@ bool Foam::dictionary::changeKeyword
|
||||
return false;
|
||||
}
|
||||
|
||||
if (iter()->keyword().isWildCard())
|
||||
{
|
||||
FatalErrorIn
|
||||
(
|
||||
"dictionary::changeKeyword(const word&, const word&, bool)"
|
||||
) << "Old keyword "<< oldKeyword
|
||||
<< " is a wildcard."
|
||||
<< "Wildcard replacement not yet implemented."
|
||||
<< exit(FatalError);
|
||||
}
|
||||
|
||||
|
||||
HashTable<entry*>::iterator iter2 = hashedEntries_.find(newKeyword);
|
||||
|
||||
// newKeyword already exists
|
||||
@ -473,14 +677,33 @@ bool Foam::dictionary::changeKeyword
|
||||
{
|
||||
if (forceOverwrite)
|
||||
{
|
||||
if (iter2()->keyword().isWildCard())
|
||||
{
|
||||
// Delete from wildcards first
|
||||
DLList<entry*>::iterator wcLink =
|
||||
wildCardEntries_.begin();
|
||||
DLList<autoPtr<regularExpression> >::iterator reLink =
|
||||
wildCardRegexps_.begin();
|
||||
|
||||
// Find in wildcards using exact match only
|
||||
if (findInWildcards(false, iter2()->keyword(), wcLink, reLink))
|
||||
{
|
||||
wildCardEntries_.remove(wcLink);
|
||||
wildCardRegexps_.remove(reLink);
|
||||
}
|
||||
}
|
||||
|
||||
IDLList<entry>::replace(iter2(), iter());
|
||||
delete iter2();
|
||||
hashedEntries_.erase(iter2);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
WarningIn("dictionary::changeKeyword(const word&, const word&)")
|
||||
<< "cannot rename keyword "<< oldKeyword
|
||||
WarningIn
|
||||
(
|
||||
"dictionary::changeKeyword(const word&, const word&, bool)"
|
||||
) << "cannot rename keyword "<< oldKeyword
|
||||
<< " to existing keyword " << newKeyword
|
||||
<< " in dictionary " << name() << endl;
|
||||
return false;
|
||||
@ -493,6 +716,18 @@ bool Foam::dictionary::changeKeyword
|
||||
hashedEntries_.erase(oldKeyword);
|
||||
hashedEntries_.insert(newKeyword, iter());
|
||||
|
||||
if (newKeyword.isWildCard())
|
||||
{
|
||||
wildCardEntries_.insert(iter());
|
||||
wildCardRegexps_.insert
|
||||
(
|
||||
autoPtr<regularExpression>
|
||||
(
|
||||
new regularExpression(newKeyword)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -579,6 +814,7 @@ void Foam::dictionary::operator=(const dictionary& dict)
|
||||
|
||||
// Create clones of the entries in the given dictionary
|
||||
// resetting the parentDict to this dictionary
|
||||
|
||||
for
|
||||
(
|
||||
IDLList<entry>::const_iterator iter = dict.begin();
|
||||
@ -586,17 +822,7 @@ void Foam::dictionary::operator=(const dictionary& dict)
|
||||
++iter
|
||||
)
|
||||
{
|
||||
IDLList<entry>::append(iter().clone(*this).ptr());
|
||||
}
|
||||
|
||||
for
|
||||
(
|
||||
IDLList<entry>::iterator iter = begin();
|
||||
iter != end();
|
||||
++iter
|
||||
)
|
||||
{
|
||||
hashedEntries_.insert(iter().keyword(), &iter());
|
||||
add(iter().clone(*this).ptr());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -27,7 +27,12 @@ Class
|
||||
|
||||
Description
|
||||
A list of keyword definitions, which are a keyword followed by any number
|
||||
of values (e.g. words and numbers).
|
||||
of values (e.g. words and numbers). The keywords can represent wildcards
|
||||
which are matched using Posix regular expressions. The general order for
|
||||
searching is
|
||||
- exact match
|
||||
- wildcard match
|
||||
- optional recursion into subdictionaries
|
||||
|
||||
The dictionary class is the base class for IOdictionary.
|
||||
It also serves as a bootstrap dictionary for the objectRegistry data
|
||||
@ -49,11 +54,13 @@ SourceFiles
|
||||
|
||||
#include "entry.H"
|
||||
#include "IDLList.H"
|
||||
#include "DLList.H"
|
||||
#include "fileName.H"
|
||||
#include "ITstream.H"
|
||||
#include "HashTable.H"
|
||||
#include "wordList.H"
|
||||
#include "className.H"
|
||||
#include "regularExpression.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -80,12 +87,40 @@ class dictionary
|
||||
//- Dictionary name
|
||||
fileName name_;
|
||||
|
||||
//- HashTable of the enries held on the DL-list for quick lookup
|
||||
//- HashTable of the entries held on the DL-list for quick lookup
|
||||
HashTable<entry*> hashedEntries_;
|
||||
|
||||
//- Parent dictionary
|
||||
const dictionary& parent_;
|
||||
|
||||
//- Wildcard entries
|
||||
DLList<entry*> wildCardEntries_;
|
||||
|
||||
//- Wildcard precompiled regex
|
||||
DLList<autoPtr<regularExpression> > wildCardRegexps_;
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Search wildcard table either for exact match or for regular
|
||||
// expression match.
|
||||
bool findInWildcards
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::const_iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::const_iterator& reLink
|
||||
) const;
|
||||
|
||||
//- Search wildcard table either for exact match or for regular
|
||||
// expression match.
|
||||
bool findInWildcards
|
||||
(
|
||||
const bool wildCardMatch,
|
||||
const word& Keyword,
|
||||
DLList<entry*>::iterator& wcLink,
|
||||
DLList<autoPtr<regularExpression> >::iterator& reLink
|
||||
);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -181,24 +216,44 @@ public:
|
||||
|
||||
//- Find and return an entry data stream pointer if present
|
||||
// otherwise return NULL.
|
||||
// If recursive search parent dictionaries
|
||||
// If recursive search parent dictionaries. If wildCardMatch
|
||||
// use wildcards.
|
||||
const entry* lookupEntryPtr
|
||||
(
|
||||
const word&, bool recursive=false
|
||||
const word&,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream pointer for manipulation
|
||||
// if present otherwise return NULL.
|
||||
// If recursive search parent dictionaries
|
||||
entry* lookupEntryPtr(const word&, bool recursive=false);
|
||||
// If recursive search parent dictionaries. If wildCardMatch
|
||||
// use wildcards.
|
||||
entry* lookupEntryPtr
|
||||
(
|
||||
const word&,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
);
|
||||
|
||||
//- Find and return an entry data stream if present otherwise error.
|
||||
// If recursive search parent dictionaries
|
||||
const entry& lookupEntry(const word&, bool recursive=false) const;
|
||||
// If recursive search parent dictionaries. If wildCardMatch
|
||||
// use wildcards.
|
||||
const entry& lookupEntry
|
||||
(
|
||||
const word&,
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
) const;
|
||||
|
||||
//- Find and return an entry data stream
|
||||
// If recursive search parent dictionaries
|
||||
ITstream& lookup(const word&, bool recursive=false) const;
|
||||
ITstream& lookup
|
||||
(
|
||||
const word&,
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
) const;
|
||||
|
||||
//- Find and return a T,
|
||||
// if not found return the given default value
|
||||
@ -208,7 +263,8 @@ public:
|
||||
(
|
||||
const word&,
|
||||
const T&,
|
||||
bool recursive=false
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
) const;
|
||||
|
||||
//- Find and return a T, if not found return the given
|
||||
@ -219,7 +275,8 @@ public:
|
||||
(
|
||||
const word&,
|
||||
const T&,
|
||||
bool recursive=false
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
);
|
||||
|
||||
//- Find an entry if present, and assign to T
|
||||
@ -229,7 +286,8 @@ public:
|
||||
(
|
||||
const word&,
|
||||
T&,
|
||||
bool recursive=false
|
||||
bool recursive=false,
|
||||
bool wildCardMatch=true
|
||||
) const;
|
||||
|
||||
//- Check if entry is a sub-dictionary
|
||||
@ -248,7 +306,6 @@ public:
|
||||
//- Return the table of contents
|
||||
wordList toc() const;
|
||||
|
||||
|
||||
// Editing
|
||||
|
||||
//- Add a new entry
|
||||
@ -263,25 +320,25 @@ public:
|
||||
|
||||
//- Add a word entry
|
||||
// optionally overwrite an existing entry
|
||||
void add(const word& keyword, const word&, bool overwrite=false);
|
||||
void add(const keyType&, const word&, bool overwrite=false);
|
||||
|
||||
//- Add a string entry
|
||||
// optionally overwrite an existing entry
|
||||
void add(const word& keyword, const string&, bool overwrite=false);
|
||||
void add(const keyType&, const string&, bool overwrite=false);
|
||||
|
||||
//- Add a label entry
|
||||
// optionally overwrite an existing entry
|
||||
void add(const word& keyword, const label, bool overwrite=false);
|
||||
void add(const keyType&, const label, bool overwrite=false);
|
||||
|
||||
//- Add a scalar entry
|
||||
// optionally overwrite an existing entry
|
||||
void add (const word& keyword, const scalar, bool overwrite=false);
|
||||
void add (const keyType&, const scalar, bool overwrite=false);
|
||||
|
||||
//- Add a dictionary entry
|
||||
// optionally merge with an existing sub-dictionary
|
||||
void add
|
||||
(
|
||||
const word& keyword,
|
||||
const keyType& keyword,
|
||||
const dictionary&,
|
||||
bool mergeEntry=false
|
||||
);
|
||||
@ -289,7 +346,7 @@ public:
|
||||
//- Add a T entry
|
||||
// optionally overwrite an existing entry
|
||||
template<class T>
|
||||
void add(const word& keyword, const T&, bool overwrite=false);
|
||||
void add(const keyType& keyword, const T&, bool overwrite=false);
|
||||
|
||||
//- Assign a new entry, overwrite any existing entry
|
||||
void set(entry*);
|
||||
@ -298,11 +355,11 @@ public:
|
||||
void set(const entry&);
|
||||
|
||||
//- Assign a dictionary entry, overwrite any existing entry
|
||||
void set(const word& keyword, const dictionary&);
|
||||
void set(const keyType& keyword, const dictionary&);
|
||||
|
||||
//- Assign a T entry, overwrite any existing entry
|
||||
template<class T>
|
||||
void set(const word& keyword, const T&);
|
||||
void set(const keyType& keyword, const T&);
|
||||
|
||||
//- Remove an entry specified by keyword
|
||||
bool remove(const word& keyword);
|
||||
@ -311,8 +368,8 @@ public:
|
||||
// optionally forcing overwrite of an existing entry
|
||||
bool changeKeyword
|
||||
(
|
||||
const word& oldKeyword,
|
||||
const word& newKeyword,
|
||||
const keyType& oldKeyword,
|
||||
const keyType& newKeyword,
|
||||
bool forceOverwrite = false
|
||||
);
|
||||
|
||||
@ -361,11 +418,13 @@ public:
|
||||
|
||||
// Global Operators
|
||||
|
||||
//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
|
||||
//- Combine dictionaries starting from the entries in dict1 and then including
|
||||
// those from dict2.
|
||||
// Warn, but do not overwrite the entries from dict1.
|
||||
dictionary operator+(const dictionary& dict1, const dictionary& dict2);
|
||||
|
||||
//- Combine dictionaries starting from the entries in dict1 and then including those from dict2.
|
||||
//- Combine dictionaries starting from the entries in dict1 and then including
|
||||
// those from dict2.
|
||||
// Do not overwrite the entries from dict1.
|
||||
dictionary operator|(const dictionary& dict1, const dictionary& dict2);
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ License
|
||||
|
||||
Foam::dictionaryEntry::dictionaryEntry
|
||||
(
|
||||
const word& key,
|
||||
const keyType& key,
|
||||
const dictionary& parentDict,
|
||||
const dictionary& dict
|
||||
)
|
||||
|
||||
@ -43,6 +43,7 @@ SourceFiles
|
||||
#ifndef dictionaryEntry_H
|
||||
#define dictionaryEntry_H
|
||||
|
||||
#include "keyType.H"
|
||||
#include "entry.H"
|
||||
#include "dictionary.H"
|
||||
#include "InfoProxy.H"
|
||||
@ -79,7 +80,7 @@ public:
|
||||
//- Construct from the keyword, parent dictionary and a Istream
|
||||
dictionaryEntry
|
||||
(
|
||||
const word& keyword,
|
||||
const keyType& keyword,
|
||||
const dictionary& parentDict,
|
||||
Istream& is
|
||||
);
|
||||
@ -87,7 +88,7 @@ public:
|
||||
//- Construct from the keyword, parent dictionary and a dictionary
|
||||
dictionaryEntry
|
||||
(
|
||||
const word& keyword,
|
||||
const keyType& keyword,
|
||||
const dictionary& parentDict,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
@ -27,7 +27,9 @@ Description
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "keyType.H"
|
||||
#include "dictionaryEntry.H"
|
||||
#include "IOstreams.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
@ -43,14 +45,14 @@ Foam::dictionaryEntry::dictionaryEntry
|
||||
is.fatalCheck
|
||||
(
|
||||
"dictionaryEntry::dictionaryEntry"
|
||||
"(Istream& is, const dictionary& parentDict)"
|
||||
"(const dictionary& parentDict, Istream& is)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::dictionaryEntry::dictionaryEntry
|
||||
(
|
||||
const word& key,
|
||||
const keyType& key,
|
||||
const dictionary& parentDict,
|
||||
Istream& is
|
||||
)
|
||||
@ -63,7 +65,7 @@ Foam::dictionaryEntry::dictionaryEntry
|
||||
is.fatalCheck
|
||||
(
|
||||
"dictionaryEntry::dictionaryEntry"
|
||||
"(const word& keyword, const dictionary& parentDict, Istream& is)"
|
||||
"(const keyType& keyword, const dictionary& parentDict, Istream& is)"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ bool Foam::dictionary::substituteKeyword(const word& keyword)
|
||||
word varName = keyword(1, keyword.size()-1);
|
||||
|
||||
// lookup the variable name in the given dictionary....
|
||||
const entry* ePtr = lookupEntryPtr(varName, true);
|
||||
const entry* ePtr = lookupEntryPtr(varName, true, true);
|
||||
|
||||
// ...if defined insert its entries into this dictionary...
|
||||
if (ePtr != NULL)
|
||||
@ -137,6 +137,8 @@ Foam::Istream& Foam::operator>>(Istream& is, dictionary& dict)
|
||||
|
||||
dict.clear();
|
||||
dict.hashedEntries_.clear();
|
||||
dict.wildCardEntries_.clear();
|
||||
dict.wildCardRegexps_.clear();
|
||||
dict.read(is);
|
||||
|
||||
return is;
|
||||
|
||||
@ -34,10 +34,11 @@ T Foam::dictionary::lookupOrDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
@ -55,10 +56,11 @@ T Foam::dictionary::lookupOrAddDefault
|
||||
(
|
||||
const word& keyword,
|
||||
const T& deflt,
|
||||
bool recursive
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
)
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive);
|
||||
const entry* entryPtr = lookupEntryPtr(keyword, recursive, wildCardMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
@ -77,10 +79,11 @@ bool Foam::dictionary::readIfPresent
|
||||
(
|
||||
const word& k,
|
||||
T& val,
|
||||
bool recursive
|
||||
bool recursive,
|
||||
bool wildCardMatch
|
||||
) const
|
||||
{
|
||||
const entry* entryPtr = lookupEntryPtr(k, recursive);
|
||||
const entry* entryPtr = lookupEntryPtr(k, recursive, wildCardMatch);
|
||||
|
||||
if (entryPtr == NULL)
|
||||
{
|
||||
@ -95,16 +98,17 @@ bool Foam::dictionary::readIfPresent
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::dictionary::add(const word& k, const T& t, bool overwrite)
|
||||
void Foam::dictionary::add(const keyType& k, const T& t, bool overwrite)
|
||||
{
|
||||
add(new primitiveEntry(k, t), overwrite);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
void Foam::dictionary::set(const word& k, const T& t)
|
||||
void Foam::dictionary::set(const keyType& k, const T& t)
|
||||
{
|
||||
set(new primitiveEntry(k, t));
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -30,7 +30,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::entry::entry(const word& keyword)
|
||||
Foam::entry::entry(const keyType& keyword)
|
||||
:
|
||||
keyword_(keyword)
|
||||
{}
|
||||
|
||||
@ -42,6 +42,7 @@ SourceFiles
|
||||
#ifndef entry_H
|
||||
#define entry_H
|
||||
|
||||
#include "keyType.H"
|
||||
#include "IDLList.H"
|
||||
#include "fileName.H"
|
||||
#include "autoPtr.H"
|
||||
@ -70,21 +71,18 @@ class entry
|
||||
// Private data
|
||||
|
||||
//- Keyword of entry
|
||||
word keyword_;
|
||||
keyType keyword_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Get the next valid keyword otherwise return false
|
||||
static bool getKeyword(word& keyword, Istream& is);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from keyword
|
||||
entry(const word& keyword);
|
||||
entry(const keyType& keyword);
|
||||
|
||||
//- Construct as copy
|
||||
entry(const entry&);
|
||||
@ -115,14 +113,17 @@ public:
|
||||
|
||||
// Member functions
|
||||
|
||||
//- Get the next valid keyword otherwise return false
|
||||
static bool getKeyword(keyType& keyword, Istream& is);
|
||||
|
||||
//- Return keyword
|
||||
const word& keyword() const
|
||||
const keyType& keyword() const
|
||||
{
|
||||
return keyword_;
|
||||
}
|
||||
|
||||
//- Return non-const access to keyword
|
||||
word& keyword()
|
||||
keyType& keyword()
|
||||
{
|
||||
return keyword_;
|
||||
}
|
||||
|
||||
@ -32,7 +32,7 @@ License
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::entry::getKeyword(word& keyword, Istream& is)
|
||||
bool Foam::entry::getKeyword(keyType& keyword, Istream& is)
|
||||
{
|
||||
token keywordToken;
|
||||
|
||||
@ -57,6 +57,12 @@ bool Foam::entry::getKeyword(word& keyword, Istream& is)
|
||||
keyword = keywordToken.wordToken();
|
||||
return true;
|
||||
}
|
||||
else if (keywordToken.isString())
|
||||
{
|
||||
// Enable wildcards
|
||||
keyword = keywordToken.stringToken();
|
||||
return true;
|
||||
}
|
||||
// If it is the end of the dictionary or file return false...
|
||||
else if (keywordToken == token::END_BLOCK || is.eof())
|
||||
{
|
||||
@ -67,7 +73,7 @@ bool Foam::entry::getKeyword(word& keyword, Istream& is)
|
||||
{
|
||||
cerr<< "--> FOAM Warning : " << std::endl
|
||||
<< " From function "
|
||||
<< "entry::getKeyword(word& keyword, Istream& is)" << std::endl
|
||||
<< "entry::getKeyword(keyType& keyword, Istream& is)" << std::endl
|
||||
<< " in file " << __FILE__
|
||||
<< " at line " << __LINE__ << std::endl
|
||||
<< " Reading " << is.name().c_str() << std::endl
|
||||
@ -84,7 +90,7 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
{
|
||||
is.fatalCheck("entry::New(const dictionary& parentDict, Istream& is)");
|
||||
|
||||
word keyword;
|
||||
keyType keyword;
|
||||
|
||||
// Get the next keyword and if invalid return false
|
||||
if (!getKeyword(keyword, is))
|
||||
@ -115,7 +121,13 @@ bool Foam::entry::New(dictionary& parentDict, Istream& is)
|
||||
// Deal with duplicate entries
|
||||
bool mergeEntry = false;
|
||||
|
||||
entry* existingPtr = parentDict.lookupEntryPtr(keyword);
|
||||
// See (using exact match) if entry already present
|
||||
entry* existingPtr = parentDict.lookupEntryPtr
|
||||
(
|
||||
keyword,
|
||||
false,
|
||||
true
|
||||
);
|
||||
if (existingPtr)
|
||||
{
|
||||
if (functionEntries::inputModeEntry::overwrite())
|
||||
@ -158,7 +170,7 @@ Foam::autoPtr<Foam::entry> Foam::entry::New(Istream& is)
|
||||
{
|
||||
is.fatalCheck("entry::New(Istream& is)");
|
||||
|
||||
word keyword;
|
||||
keyType keyword;
|
||||
|
||||
// Get the next keyword and if invalid return false
|
||||
if (!getKeyword(keyword, is))
|
||||
|
||||
@ -24,12 +24,13 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "word.H"
|
||||
#include "primitiveEntry.H"
|
||||
#include "dictionary.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry(const word& key, const ITstream& tokens)
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& tokens)
|
||||
:
|
||||
entry(key),
|
||||
ITstream(tokens)
|
||||
@ -38,7 +39,7 @@ Foam::primitiveEntry::primitiveEntry(const word& key, const ITstream& tokens)
|
||||
}
|
||||
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry(const word& keyword, const token& t)
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const token& t)
|
||||
:
|
||||
entry(keyword),
|
||||
ITstream(keyword, tokenList(1, t))
|
||||
@ -47,7 +48,7 @@ Foam::primitiveEntry::primitiveEntry(const word& keyword, const token& t)
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry
|
||||
(
|
||||
const word& keyword,
|
||||
const keyType& keyword,
|
||||
const tokenList& tokens
|
||||
)
|
||||
:
|
||||
|
||||
@ -108,23 +108,23 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct from keyword and a Istream
|
||||
primitiveEntry(const word& keyword, Istream&);
|
||||
primitiveEntry(const keyType& keyword, Istream&);
|
||||
|
||||
//- Construct from keyword, parent dictionary and a Istream
|
||||
primitiveEntry(const word& keyword, const dictionary&, Istream&);
|
||||
primitiveEntry(const keyType& keyword, const dictionary&, Istream&);
|
||||
|
||||
//- Construct from keyword and a ITstream
|
||||
primitiveEntry(const word& keyword, const ITstream&);
|
||||
primitiveEntry(const keyType& keyword, const ITstream&);
|
||||
|
||||
//- Construct from keyword and a token
|
||||
primitiveEntry(const word&, const token&);
|
||||
primitiveEntry(const keyType&, const token&);
|
||||
|
||||
//- Construct from keyword and a tokenList
|
||||
primitiveEntry(const word&, const tokenList&);
|
||||
primitiveEntry(const keyType&, const tokenList&);
|
||||
|
||||
//- Construct from keyword and a T
|
||||
template<class T>
|
||||
primitiveEntry(const word&, const T&);
|
||||
primitiveEntry(const keyType&, const T&);
|
||||
|
||||
autoPtr<entry> clone(const dictionary&) const
|
||||
{
|
||||
|
||||
@ -81,7 +81,7 @@ bool Foam::primitiveEntry::expandVariable
|
||||
word varName = w(1, w.size()-1);
|
||||
|
||||
// lookup the variable name in the given dictionary....
|
||||
const entry* ePtr = dict.lookupEntryPtr(varName, true);
|
||||
const entry* ePtr = dict.lookupEntryPtr(varName, true, true);
|
||||
|
||||
// ...if defined insert its tokens into this
|
||||
if (ePtr != NULL)
|
||||
@ -218,7 +218,7 @@ void Foam::primitiveEntry::readEntry(const dictionary& dict, Istream& is)
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry
|
||||
(
|
||||
const word& key,
|
||||
const keyType& key,
|
||||
const dictionary& dict,
|
||||
Istream& is
|
||||
)
|
||||
@ -236,7 +236,7 @@ Foam::primitiveEntry::primitiveEntry
|
||||
}
|
||||
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry(const word& key, Istream& is)
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
|
||||
:
|
||||
entry(key),
|
||||
ITstream
|
||||
|
||||
@ -30,7 +30,7 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::primitiveEntry::primitiveEntry(const word& keyword, const T& t)
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const T& t)
|
||||
:
|
||||
entry(keyword),
|
||||
ITstream(keyword, tokenList(10))
|
||||
|
||||
@ -87,16 +87,21 @@ public:
|
||||
inline word(const word&);
|
||||
|
||||
//- Construct as copy of character array
|
||||
inline word(const char*);
|
||||
inline word(const char*, const bool doStripInvalid = true);
|
||||
|
||||
//- Construct as copy with a maximum number of characters
|
||||
inline word(const char*, const size_type);
|
||||
inline word
|
||||
(
|
||||
const char*,
|
||||
const size_type,
|
||||
const bool doStripInvalid
|
||||
);
|
||||
|
||||
//- Construct as copy of string
|
||||
inline word(const string&);
|
||||
inline word(const string&, const bool doStripInvalid = true);
|
||||
|
||||
//- Construct as copy of std::string
|
||||
inline word(const std::string&);
|
||||
inline word(const std::string&, const bool doStripInvalid = true);
|
||||
|
||||
//- Construct from Istream
|
||||
word(Istream&);
|
||||
|
||||
@ -65,34 +65,51 @@ inline Foam::word::word()
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::word::word(const string& s)
|
||||
inline Foam::word::word(const string& s, const bool doStripInvalid)
|
||||
:
|
||||
string(s)
|
||||
{
|
||||
stripInvalid();
|
||||
if (doStripInvalid)
|
||||
{
|
||||
stripInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline Foam::word::word(const std::string& s)
|
||||
inline Foam::word::word(const std::string& s, const bool doStripInvalid)
|
||||
:
|
||||
string(s)
|
||||
{
|
||||
stripInvalid();
|
||||
if (doStripInvalid)
|
||||
{
|
||||
stripInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
inline Foam::word::word(const char* s)
|
||||
inline Foam::word::word(const char* s, const bool doStripInvalid)
|
||||
:
|
||||
string(s)
|
||||
{
|
||||
stripInvalid();
|
||||
if (doStripInvalid)
|
||||
{
|
||||
stripInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
inline Foam::word::word(const char* s, const size_type n)
|
||||
inline Foam::word::word
|
||||
(
|
||||
const char* s,
|
||||
const size_type n,
|
||||
const bool doStripInvalid
|
||||
)
|
||||
:
|
||||
string(s, n)
|
||||
{
|
||||
stripInvalid();
|
||||
if (doStripInvalid)
|
||||
{
|
||||
stripInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user