
On 03/01/08 04:58, Roland Schwarz wrote:
Larry Evans wrote:
A long time ago, I had one and was intending *eventually* to add it to iostreams, but never got around to it. It's in:
http://svn.boost.org/trac/boost/browser/sandbox-branches/cppljevans/boost/io...
Thank you. Al though google revealed some postings about margin_ostream it failed to get me to the sources.
The above http reference should show the sources. I must be misunderstanding you :(. I haven't used svn to download it recently, but I guess using a command similar to that shown here: http://svn.boost.org/trac/boost/wiki/BoostSubversion , except with the appropriate directory substituted for trunk, would work.
I am not sure however you noticed the difference to my implementation:
I am storing state _in_ the stream, i.e. in ios base member and thus allowing out << indent_in << "blah blah\n"; out << "still indented\n";
And a function void foo(ostream& os)
that gets passed down my indent_filter'ed stream still knowns the indentation status.
Ah! That sounds better than marg_ostream. It uses, IIRC, some sort or wrapper around an ostream to do its work. This looks better to me (than marg_ostream).
The margin_ostream implements indent operation only the stream object. Does is also have manipulators?
Will margin_ostream also work when downcasted to a plain ostream?
No. indent.hpp is beginning to sound better and better. One application I had for marg_ostream (actually for an earlier version back in mid-late 90's) was indenting fortran code with the additional notation in the margins showing the arrows reflecting the goto's. marg_ostream has a string member function containing the margin contents which, AFAICT, can be used for this type of notation. I think it's a minor feature but still could be useful. How could indent.hpp be adapted to do this or would there have to be some derivation from some class to provide this feature. For example, another use would be putting line numbers in the 1st few characters of the margin so that the output appears something like that shown in the svn browser here: http://svn.boost.org/trac/boost/browser/sandbox-branches/cppljevans/boost/io... I'll be trying out indent.hpp after I'm done with the proto review. Thanks for the contribution. -regards, Larry