mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: cleanup Ostream to ease usage (issue #254)
- Include newline in beginBlock/endBlock, since this corresponds to
the standard usage. The beginBlock now takes keyType instead of word.
- Provide Ostream::writeEntry method to reduce clutter and simplify
writing of entries.
Before
======
os << indent << "name" << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl;
os.writeKeyword("key1") << val1 << token::END_STATEMENT << nl;
os.writeKeyword("key2") << val2 << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << nl;
After
=====
os.beginBlock("name");
os.writeEntry("key1", val1);
os.writeEntry("key2", val2);
os.endBlock();
- For completeness, support inline use of various Ostream methods.
For example,
os << beginBlock;
os.writeEntry("key1", val1);
os.writeEntry("key2", val2);
os << endBlock;
- For those who wish to write in long form, can also use endEntry inline:
os.beginBlock("name");
os.writeKeyword("key1") << val2 << endEntry;
os.writeKeyword("key2") << val2 << endEntry;
os.endBlock();
The endEntry encapsulates a semi-colon, newline combination.
This commit is contained in:
@ -78,16 +78,17 @@ template<class Type>
|
||||
void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const
|
||||
{
|
||||
Function1<Type>::writeData(os);
|
||||
os << token::END_STATEMENT << nl;
|
||||
os.endEntry();
|
||||
|
||||
os.beginBlock(word(this->name() + "Coeffs")) << nl;
|
||||
os.beginBlock(word(this->name() + "Coeffs"));
|
||||
|
||||
// Note: for TableBase write the dictionary entries it needs but not
|
||||
// the values themselves
|
||||
TableBase<Type>::writeEntries(os);
|
||||
os.writeKeyword("fileName")<< fName_ << token::END_STATEMENT << nl;
|
||||
|
||||
os.endBlock() << endl;
|
||||
os.writeEntry("fileName", fName_);
|
||||
|
||||
os.endBlock() << flush;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user