mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: variables: have separate token type
This commit is contained in:
@ -266,7 +266,7 @@ Foam::Istream& Foam::ISstream::read(token& t)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
t = sPtr;
|
t = sPtr;
|
||||||
t.type() = token::STRING;
|
t.type() = token::VARIABLE;
|
||||||
}
|
}
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -77,6 +77,7 @@ public:
|
|||||||
|
|
||||||
PUNCTUATION,
|
PUNCTUATION,
|
||||||
WORD,
|
WORD,
|
||||||
|
VARIABLE,
|
||||||
STRING,
|
STRING,
|
||||||
VERBATIMSTRING,
|
VERBATIMSTRING,
|
||||||
LABEL,
|
LABEL,
|
||||||
@ -331,6 +332,8 @@ public:
|
|||||||
inline bool isWord() const;
|
inline bool isWord() const;
|
||||||
inline const word& wordToken() const;
|
inline const word& wordToken() const;
|
||||||
|
|
||||||
|
inline bool isVariable() const;
|
||||||
|
|
||||||
inline bool isString() const;
|
inline bool isString() const;
|
||||||
inline const string& stringToken() const;
|
inline const string& stringToken() const;
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -39,7 +39,7 @@ inline void token::clear()
|
|||||||
{
|
{
|
||||||
delete wordTokenPtr_;
|
delete wordTokenPtr_;
|
||||||
}
|
}
|
||||||
else if (type_ == STRING || type_ == VERBATIMSTRING)
|
else if (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING)
|
||||||
{
|
{
|
||||||
delete stringTokenPtr_;
|
delete stringTokenPtr_;
|
||||||
}
|
}
|
||||||
@ -88,6 +88,7 @@ inline token::token(const token& t)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STRING:
|
case STRING:
|
||||||
|
case VARIABLE:
|
||||||
case VERBATIMSTRING:
|
case VERBATIMSTRING:
|
||||||
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
||||||
break;
|
break;
|
||||||
@ -235,14 +236,19 @@ inline const word& token::wordToken() const
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool token::isVariable() const
|
||||||
|
{
|
||||||
|
return (type_ == VARIABLE);
|
||||||
|
}
|
||||||
|
|
||||||
inline bool token::isString() const
|
inline bool token::isString() const
|
||||||
{
|
{
|
||||||
return (type_ == STRING || type_ == VERBATIMSTRING);
|
return (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline const string& token::stringToken() const
|
inline const string& token::stringToken() const
|
||||||
{
|
{
|
||||||
if (type_ == STRING || type_ == VERBATIMSTRING)
|
if (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING)
|
||||||
{
|
{
|
||||||
return *stringTokenPtr_;
|
return *stringTokenPtr_;
|
||||||
}
|
}
|
||||||
@ -411,6 +417,7 @@ inline void token::operator=(const token& t)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STRING:
|
case STRING:
|
||||||
|
case VARIABLE:
|
||||||
case VERBATIMSTRING:
|
case VERBATIMSTRING:
|
||||||
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
stringTokenPtr_ = new string(*t.stringTokenPtr_);
|
||||||
break;
|
break;
|
||||||
@ -518,6 +525,7 @@ inline bool token::operator==(const token& t) const
|
|||||||
return *wordTokenPtr_ == *t.wordTokenPtr_;
|
return *wordTokenPtr_ == *t.wordTokenPtr_;
|
||||||
|
|
||||||
case STRING:
|
case STRING:
|
||||||
|
case VARIABLE:
|
||||||
case VERBATIMSTRING:
|
case VERBATIMSTRING:
|
||||||
return *stringTokenPtr_ == *t.stringTokenPtr_;
|
return *stringTokenPtr_ == *t.stringTokenPtr_;
|
||||||
|
|
||||||
@ -552,7 +560,11 @@ inline bool token::operator==(const word& w) const
|
|||||||
|
|
||||||
inline bool token::operator==(const string& s) const
|
inline bool token::operator==(const string& s) const
|
||||||
{
|
{
|
||||||
return ((type_ == STRING || type_ == VERBATIMSTRING) && stringToken() == s);
|
return
|
||||||
|
(
|
||||||
|
(type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING)
|
||||||
|
&& stringToken() == s
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool token::operator==(const label l) const
|
inline bool token::operator==(const label l) const
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
========= |
|
========= |
|
||||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
\\ / O peration |
|
\\ / O peration |
|
||||||
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
|
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
@ -74,6 +74,11 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const token& t)
|
|||||||
os << *t.stringTokenPtr_;
|
os << *t.stringTokenPtr_;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case token::VARIABLE:
|
||||||
|
// Write variable as word so without ""
|
||||||
|
os.writeQuoted(*t.stringTokenPtr_, false);
|
||||||
|
break;
|
||||||
|
|
||||||
case token::LABEL:
|
case token::LABEL:
|
||||||
os << t.labelToken_;
|
os << t.labelToken_;
|
||||||
break;
|
break;
|
||||||
@ -157,6 +162,10 @@ ostream& Foam::operator<<(ostream& os, const InfoProxy<token>& ip)
|
|||||||
os << " the string " << t.stringToken();
|
os << " the string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case token::VARIABLE:
|
||||||
|
os << " the variable " << t.stringToken();
|
||||||
|
break;
|
||||||
|
|
||||||
case token::VERBATIMSTRING:
|
case token::VERBATIMSTRING:
|
||||||
os << " the verbatim string " << t.stringToken();
|
os << " the verbatim string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
@ -231,6 +240,10 @@ Ostream& operator<<(Ostream& os, const InfoProxy<token>& ip)
|
|||||||
os << " the string " << t.stringToken();
|
os << " the string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case token::VARIABLE:
|
||||||
|
os << " the variable " << t.stringToken();
|
||||||
|
break;
|
||||||
|
|
||||||
case token::VERBATIMSTRING:
|
case token::VERBATIMSTRING:
|
||||||
os << " the verbatim string " << t.stringToken();
|
os << " the verbatim string " << t.stringToken();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@ -55,7 +55,7 @@ void Foam::primitiveEntry::append
|
|||||||
newElmt(tokenIndex()++) = currToken;
|
newElmt(tokenIndex()++) = currToken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (currToken.isString())
|
else if (currToken.isVariable())
|
||||||
{
|
{
|
||||||
const string& w = currToken.stringToken();
|
const string& w = currToken.stringToken();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user