dimensionedType: Add support for optional read and re-read of name and dimensions

Supports

rho   1;
rho   [1 -3 0 0 0] 1;
rho   rho [1 -3 0 0 0] 1;
This commit is contained in:
Henry 2012-04-16 15:51:20 +01:00
parent 9ba839942e
commit 15ce7dcf0a

View File

@ -131,6 +131,16 @@ dimensioned<Type>::dimensioned
token nextToken(is);
is.putBack(nextToken);
// Check if the original format is used in which the name is provided
// and reset the name to that read
if (nextToken.isWord())
{
is >> name_;
is >> nextToken;
is.putBack(nextToken);
}
// If the dimensions are provided compare with the argument
if (nextToken == token::BEGIN_SQR)
{
dimensionSet dims(is);
@ -391,8 +401,26 @@ dimensioned<Type> min
template <class Type>
Istream& operator>>(Istream& is, dimensioned<Type>& dt)
{
// do a stream read op for a Type and a dimensions()et
is >> dt.name_ >> dt.dimensions_ >> dt.value_;
token nextToken(is);
is.putBack(nextToken);
// Check if the original format is used in which the name is provided
// and reset the name to that read
if (nextToken.isWord())
{
is >> dt.name_;
is >> nextToken;
is.putBack(nextToken);
}
// If the dimensions are provided reset the dimensions to those read
if (nextToken == token::BEGIN_SQR)
{
is >> dt.dimensions_;
}
// Read the value
is >> dt.value_;
// Check state of Istream
is.check("Istream& operator>>(Istream&, dimensioned<Type>&)");