mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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.
This commit is contained in:
@ -266,7 +266,10 @@ void Foam::PackedList<Width>::writeEntry
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os.writeKeyword(keyword);
|
if (keyword.size())
|
||||||
|
{
|
||||||
|
os.writeKeyword(keyword);
|
||||||
|
}
|
||||||
writeEntry(os);
|
writeEntry(os);
|
||||||
os << token::END_STATEMENT << endl;
|
os << token::END_STATEMENT << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,7 +103,10 @@ void Foam::bitSet::writeEntry
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os.writeKeyword(keyword);
|
if (keyword.size())
|
||||||
|
{
|
||||||
|
os.writeKeyword(keyword);
|
||||||
|
}
|
||||||
writeEntry(os);
|
writeEntry(os);
|
||||||
os << token::END_STATEMENT << endl;
|
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) + '>';
|
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
|
||||||
if (token::compound::isCompound(tag))
|
if (token::compound::isCompound(tag))
|
||||||
{
|
{
|
||||||
os << tag << ' ';
|
os << tag << token::SPACE;
|
||||||
}
|
}
|
||||||
os << *this;
|
os << *this;
|
||||||
}
|
}
|
||||||
@ -54,7 +54,10 @@ void Foam::FixedList<T, N>::writeEntry
|
|||||||
Ostream& os
|
Ostream& os
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
os.writeKeyword(keyword);
|
if (keyword.size())
|
||||||
|
{
|
||||||
|
os.writeKeyword(keyword);
|
||||||
|
}
|
||||||
writeEntry(os);
|
writeEntry(os);
|
||||||
os << token::END_STATEMENT << endl;
|
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) + '>';
|
const word tag = "List<" + word(pTraits<T>::typeName) + '>';
|
||||||
if (token::compound::isCompound(tag))
|
if (token::compound::isCompound(tag))
|
||||||
{
|
{
|
||||||
os << tag << ' ';
|
os << tag << token::SPACE;
|
||||||
}
|
}
|
||||||
os << *this;
|
os << *this;
|
||||||
}
|
}
|
||||||
@ -64,7 +64,10 @@ void Foam::UList<T>::writeEntry(Ostream& os) const
|
|||||||
template<class T>
|
template<class T>
|
||||||
void Foam::UList<T>::writeEntry(const word& keyword, Ostream& os) const
|
void Foam::UList<T>::writeEntry(const word& keyword, Ostream& os) const
|
||||||
{
|
{
|
||||||
os.writeKeyword(keyword);
|
if (keyword.size())
|
||||||
|
{
|
||||||
|
os.writeKeyword(keyword);
|
||||||
|
}
|
||||||
writeEntry(os);
|
writeEntry(os);
|
||||||
os << token::END_STATEMENT << endl;
|
os << token::END_STATEMENT << endl;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -630,18 +630,21 @@ Foam::tmp<Foam::Field<Type>> Foam::Field<Type>::T() const
|
|||||||
template<class Type>
|
template<class Type>
|
||||||
void Foam::Field<Type>::writeEntry(const word& keyword, Ostream& os) const
|
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
|
// The contents are 'uniform' if the list is non-empty
|
||||||
// and all entries have identical values.
|
// and all entries have identical values.
|
||||||
|
|
||||||
if (is_contiguous<Type>::value && List<Type>::uniform())
|
if (is_contiguous<Type>::value && List<Type>::uniform())
|
||||||
{
|
{
|
||||||
os << "uniform " << this->first();
|
os << word("uniform") << token::SPACE << this->first();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
os << "nonuniform ";
|
os << word("nonuniform") << token::SPACE;
|
||||||
List<Type>::writeEntry(os);
|
List<Type>::writeEntry(os);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user