Boost logo

Boost :

Subject: Re: [boost] [iostreams]ANNOUNCE:indent_filtering_ostream.zip in vault
From: Larry Evans (cppljevans_at_[hidden])
Date: 2010-01-12 14:38:51


On 01/12/10 11:29, dherring_at_[hidden] wrote:
> On Mon, 11 Jan 2010, vicente.botet wrote:
>> From: "Larry Evans" <cppljevans_at_[hidden]>
>>>
>>> The .zip file in subject is here:
>>>
>>> http://www.boostpro.com/vault/index.php?&directory=Input%20-%20Output
>>>
[snip]
> I wrote a similar utility, but made different tradeoffs. The basic
> usage looks like
>
> Indentation nl; // takes optional max depth and depth/level params
> Indentation::Indent in(nl); // could have used a reference notation
> Indentation::Outdent out(nl);
> std::ostream os;
> os << nl "class x
> << nl << '{' << in /* or nl.in */
> << nl << "int x;"
> << nl << "int y;" << out
> << nl << "};"
>
> Rationale:
> - operator++ and operator-- don't mix "as expected" with operator<<

The functions provided in the indent_filtering_ostream.hpp include:

   indent_in
   indent_out

which can be used just like your in and out. For example:

; ++mout
; mout<<"line1.1"<<std::endl
; mout<<indent_in<<"line1.1.1"<<std::endl
; test_conversion(mout)

> - distinguishes between indenting and normal newlines

I'm not sure what this means. Does it mean that to indent
a line, you have to use nl, as shown in this snippet of the code
you posted:

> << nl << "int x;"

If so, then I'm not sure that's an advantage. Could you
please elaborate on what you mean?

> - possible to maintain several indentation systems

Could you describe when this would be an advantage?

-regards,
Larry


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