Boost logo

Boost :

Subject: Re: [boost] manipulators for filtering_stream s
From: Larry Evans (cppljevans_at_[hidden])
Date: 2009-01-21 18:26:18


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.

[snip]

> 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.
>
> The margin_ostream implements indent operation only the stream object.
> Does is also have manipulators?

No.

>
> Will margin_ostream also work when downcasted to a plain ostream?
>

No.

However, I've looked further at indent.hpp and the storing of the
pointer to the filter in the ios_base using ios_base::pword. What's
the advantage of using ios_base::pword to store the pointer to
something that's already available via basic_ios<...>::rd_buf and then
filtering_streambuf<...>::component<T>(int):

 
http://www.boost.org/doc/libs/1_37_0/libs/iostreams/doc/classes/filtering_streambuf.html

This design is implemented in boost vault under the "Input - Output"
directory in indent_scoped_ostreambuf.zip.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk