Commit 68de0528 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: suppress keyword indentation when keyword is empty (List, Field)

- output the "uniform", "nonuniform" Field entry tags as words instead
  of raw character strings, which can help for direct tokenization or
  when sending/receiving via Pstreams.
parent dac0dd13
......@@ -266,7 +266,10 @@ void Foam::PackedList<Width>::writeEntry
Ostream& os
) const
{
os.writeKeyword(keyword);
if (keyword.size())
{
os.writeKeyword(keyword);
}
writeEntry(os);
os << token::END_STATEMENT << endl;
}
......
......@@ -103,7 +103,10 @@ void Foam::bitSet::writeEntry
Ostream& os
) const
{
os.writeKeyword(keyword);
if (keyword.size())
{
os.writeKeyword(keyword);
}
writeEntry(os);
os << token::END_STATEMENT << endl;
}
......
......@@ -39,7 +39,7 @@ void Foam::FixedList<T, N>::writeEntry(Ostream& os) const
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
if (token::compound::isCompound(tag))
{
os << tag << ' ';
os << tag << token::SPACE;
}
os << *this;
}
......@@ -54,7 +54,10 @@ void Foam::FixedList<T, N>::writeEntry
Ostream& os
) const
{
os.writeKeyword(keyword);
if (keyword.size())
{
os.writeKeyword(keyword);
}
writeEntry(os);
os << token::END_STATEMENT << endl;
}
......
......@@ -42,7 +42,7 @@ void Foam::UList<T>::writeEntry(Ostream& os) const
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
if (token::compound::isCompound(tag))
{
os << tag << ' ';
os << tag << token::SPACE;
}
os << *this;
}
......@@ -64,7 +64,10 @@ void Foam::UList<T>::writeEntry(Ostream& os) const
template<class T>
void Foam::UList<T>::writeEntry(const word& keyword, Ostream& os) const
{
os.writeKeyword(keyword);
if (keyword.size())
{
os.writeKeyword(keyword);
}
writeEntry(os);
os << token::END_STATEMENT << endl;
}
......
......@@ -630,18 +630,21 @@ Foam::tmp<Foam::Field<Type>> Foam::Field<Type>::T() const
template<class Type>
void Foam::Field<Type>::writeEntry(const word& keyword, Ostream& os) const
{
os.writeKeyword(keyword);
if (keyword.size())
{
os.writeKeyword(keyword);
}
// The contents are 'uniform' if the list is non-empty
// and all entries have identical values.
if (is_contiguous<Type>::value && List<Type>::uniform())
{
os << "uniform " << this->first();
os << word("uniform") << token::SPACE << this->first();
}
else
{
os << "nonuniform ";
os << word("nonuniform") << token::SPACE;
List<Type>::writeEntry(os);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment