Remove unused primitiveEntry::insert() private method.
Improve constructors. - Use (const UList<token>&) instead of (const List<token>&) - Add (const Xfer< List<token> >&) constructor.
This commit is contained in:
parent
fb2bd52972
commit
23f5e5917a
@ -92,7 +92,7 @@ public:
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
//- Construct as copy for the given parentDict
|
||||
//- Construct as copy for the given parent dictionary
|
||||
dictionaryEntry
|
||||
(
|
||||
const dictionary& parentDict,
|
||||
|
@ -79,7 +79,7 @@ void Foam::dictionaryEntry::write(Ostream& os) const
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * Ostream operator * * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * Ostream operator * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::Ostream& Foam::operator<<(Ostream& os, const dictionaryEntry& de)
|
||||
{
|
||||
|
@ -26,33 +26,92 @@ License
|
||||
|
||||
#include "primitiveEntry.H"
|
||||
#include "dictionary.H"
|
||||
#include "OSspecific.H"
|
||||
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::primitiveEntry::append(const UList<token>& varTokens)
|
||||
{
|
||||
forAll(varTokens, i)
|
||||
{
|
||||
newElmt(tokenIndex()++) = varTokens[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::primitiveEntry::expandVariable
|
||||
(
|
||||
const word& w,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
word varName = w(1, w.size()-1);
|
||||
|
||||
// lookup the variable name in the given dictionary....
|
||||
// Note: allow wildcards to match? For now disabled since following
|
||||
// would expand internalField to wildcard match and not expected
|
||||
// internalField:
|
||||
// internalField XXX;
|
||||
// boundaryField { ".*" {YYY;} movingWall {value $internalField;}
|
||||
const entry* ePtr = dict.lookupEntryPtr(varName, true, false);
|
||||
|
||||
// ...if defined append its tokens into this
|
||||
if (ePtr)
|
||||
{
|
||||
append(ePtr->stream());
|
||||
}
|
||||
else
|
||||
{
|
||||
// not in the dictionary - try an environment variable
|
||||
string envStr = getEnv(varName);
|
||||
|
||||
if (envStr.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
append(tokenList(IStringStream('(' + envStr + ')')()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& tokens)
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& key, const ITstream& is)
|
||||
:
|
||||
entry(key),
|
||||
ITstream(tokens)
|
||||
ITstream(is)
|
||||
{
|
||||
name() += "::" + keyword();
|
||||
}
|
||||
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const token& t)
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& key, const token& t)
|
||||
:
|
||||
entry(keyword),
|
||||
ITstream(keyword, tokenList(1, t))
|
||||
entry(key),
|
||||
ITstream(key, tokenList(1, t))
|
||||
{}
|
||||
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry
|
||||
(
|
||||
const keyType& keyword,
|
||||
const tokenList& tokens
|
||||
const keyType& key,
|
||||
const UList<token>& tokens
|
||||
)
|
||||
:
|
||||
entry(keyword),
|
||||
ITstream(keyword, tokens)
|
||||
entry(key),
|
||||
ITstream(key, tokens)
|
||||
{}
|
||||
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry
|
||||
(
|
||||
const keyType& key,
|
||||
const Xfer< List<token> >& tokens
|
||||
)
|
||||
:
|
||||
entry(key),
|
||||
ITstream(key, tokens)
|
||||
{}
|
||||
|
||||
|
||||
@ -118,43 +177,4 @@ Foam::dictionary& Foam::primitiveEntry::dict()
|
||||
}
|
||||
|
||||
|
||||
void Foam::primitiveEntry::insert
|
||||
(
|
||||
const tokenList& varTokens,
|
||||
const label posI
|
||||
)
|
||||
{
|
||||
tokenList& tokens = *this;
|
||||
|
||||
if (varTokens.empty())
|
||||
{
|
||||
label end = tokens.size() - 1;
|
||||
|
||||
for (label j = posI; j < end; j++)
|
||||
{
|
||||
tokens[j] = tokens[j+1];
|
||||
}
|
||||
|
||||
tokens.setSize(tokens.size() - 1);
|
||||
}
|
||||
else if (varTokens.size() > 1)
|
||||
{
|
||||
tokens.setSize(tokens.size() + varTokens.size() - 1);
|
||||
|
||||
label end = tokens.size() - 1;
|
||||
label offset = varTokens.size() - 1;
|
||||
|
||||
for (label j = end; j > posI; j--)
|
||||
{
|
||||
tokens[j] = tokens[j-offset];
|
||||
}
|
||||
}
|
||||
|
||||
forAll(varTokens, j)
|
||||
{
|
||||
tokens[posI + j] = varTokens[j];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
@ -68,6 +68,9 @@ class primitiveEntry
|
||||
{
|
||||
// Private member functions
|
||||
|
||||
//- Append the given tokens starting at the current tokenIndex
|
||||
void append(const UList<token>&);
|
||||
|
||||
//- Append the given token to this entry
|
||||
void append
|
||||
(
|
||||
@ -76,9 +79,6 @@ class primitiveEntry
|
||||
Istream&
|
||||
);
|
||||
|
||||
//- Append the given tokens starting at the current tokenIndex
|
||||
void append(const tokenList&);
|
||||
|
||||
//- Expand the given variable (keyword starts with $)
|
||||
bool expandVariable(const word&, const dictionary&);
|
||||
|
||||
@ -93,9 +93,6 @@ class primitiveEntry
|
||||
//- Read the complete entry from the given stream
|
||||
void readEntry(const dictionary&, Istream&);
|
||||
|
||||
//- Insert the given tokens at token posI
|
||||
void insert(const tokenList&, const label posI);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@ -110,11 +107,14 @@ public:
|
||||
//- Construct from keyword and a ITstream
|
||||
primitiveEntry(const keyType&, const ITstream&);
|
||||
|
||||
//- Construct from keyword and a token
|
||||
//- Construct from keyword and a single token
|
||||
primitiveEntry(const keyType&, const token&);
|
||||
|
||||
//- Construct from keyword and a tokenList
|
||||
primitiveEntry(const keyType&, const tokenList&);
|
||||
//- Construct from keyword and a list of tokens
|
||||
primitiveEntry(const keyType&, const UList<token>&);
|
||||
|
||||
//- Construct from keyword and by transferring a list of tokens
|
||||
primitiveEntry(const keyType&, const Xfer< List<token> >&);
|
||||
|
||||
//- Construct from keyword and a T
|
||||
template<class T>
|
||||
@ -166,7 +166,7 @@ public:
|
||||
//- Read tokens from the given stream
|
||||
bool read(const dictionary&, Istream&);
|
||||
|
||||
// Write
|
||||
//- Write
|
||||
void write(Ostream&) const;
|
||||
|
||||
//- Return info proxy.
|
||||
|
@ -28,10 +28,9 @@ Description
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "primitiveEntry.H"
|
||||
#include "OSspecific.H"
|
||||
#include "functionEntry.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::primitiveEntry::append
|
||||
(
|
||||
@ -63,55 +62,6 @@ void Foam::primitiveEntry::append
|
||||
}
|
||||
|
||||
|
||||
void Foam::primitiveEntry::append(const tokenList& varTokens)
|
||||
{
|
||||
forAll(varTokens, i)
|
||||
{
|
||||
newElmt(tokenIndex()++) = varTokens[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::primitiveEntry::expandVariable
|
||||
(
|
||||
const word& w,
|
||||
const dictionary& dict
|
||||
)
|
||||
{
|
||||
word varName = w(1, w.size()-1);
|
||||
|
||||
// lookup the variable name in the given dictionary....
|
||||
// Note: allow wildcards to match? For now disabled since following
|
||||
// would expand internalField to wildcard match and not expected
|
||||
// internalField:
|
||||
// internalField XXX;
|
||||
// boundaryField { ".*" {YYY;} movingWall {value $internalField;}
|
||||
const entry* ePtr = dict.lookupEntryPtr(varName, true, false);
|
||||
|
||||
// ...if defined insert its tokens into this
|
||||
if (ePtr != NULL)
|
||||
{
|
||||
append(ePtr->stream());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// if not in the dictionary see if it is an environment
|
||||
// variable
|
||||
|
||||
string enVarString = getEnv(varName);
|
||||
|
||||
if (enVarString.size())
|
||||
{
|
||||
append(tokenList(IStringStream('(' + enVarString + ')')()));
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool Foam::primitiveEntry::expandFunction
|
||||
(
|
||||
const word& keyword,
|
||||
@ -221,6 +171,8 @@ void Foam::primitiveEntry::readEntry(const dictionary& dict, Istream& is)
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::primitiveEntry::primitiveEntry
|
||||
(
|
||||
const keyType& key,
|
||||
|
@ -30,13 +30,13 @@ License
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& keyword, const T& t)
|
||||
Foam::primitiveEntry::primitiveEntry(const keyType& key, const T& t)
|
||||
:
|
||||
entry(keyword),
|
||||
ITstream(keyword, tokenList(10))
|
||||
entry(key),
|
||||
ITstream(key, tokenList(10))
|
||||
{
|
||||
OStringStream os;
|
||||
os << t << token::END_STATEMENT;
|
||||
os << t << token::END_STATEMENT;
|
||||
readEntry(dictionary::null, IStringStream(os.str())());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user