Boost logo

Boost :

From: Reece Dunn (msclrhd_at_[hidden])
Date: 2004-09-22 04:54:31

Rozental, Gennadiy wrote:
>Here some more details:
> > 1. What is your evaluation of the design?
>Library trying to solve in fact trivial problem. Would it be presented as
>trivial function
>Template<typename C>
>Foo( C const& c, std::string open, std::string close, std::string sep );
>I may understand it.

This would mean that you would duplicate code for rendreing container types.
Also, you are missing special formatting, e.g. wrapping open/close values
around elements, e.g.:

   std::cout << formatob( vec, containerfmt( wrappedfmt().format( "<e>",
"</e>" )).format( "<l>", "</l>" )); // output: <l><e>a</e><e>b</e></l>

the indentation functionality that Volodya has expressed an interest in, and
position-based output, e.g.:

   [0] John, [1] James, [2] Marina

Also, the library should be usable on a standard stream. This is one of the
key design aims. Can you do:

   std::cout << Foo( vec, "< ", " >", " :: " );

? This requires returning an object that has << implemented. The mechanism
for this is outlined in the standard by using *manipulators*. Thus, you
would need that class to defer processing to the Foo function if you want to
use your approach.

>As to presented design - I see it as unnecessary complicated. And in many
>cases simply incorrect.
>Library does not follow standard practice as to wide char support.

I am addressing these issues. See my other discussions for details.

>Interfaces seem confusing and error prone.
>Decoration model seems too simple to warrant so much trouble as reusable
>library. Maybe more powerful/flexible solution should be considered.

I have been reshaping the decoration model and have commented on it

> > 2. What is your evaluation of the implementation?
>In most part I either don't understand or don't like it. IMO simple task
>library trying to solve shouldn't require that much code. Simple
>base solution should've done the trick.

This does not allow for flexibility to add indenting, wrapped data, etc.

> > 4. What is your evaluation of the potential usefulness of the library?
>Now to the most important: why would I ever want to use library like this?
>We have already:
>In what scenario I would use this library?

But you can't do:

   std::vector< int > vec;
   std::cout << vec; // oops! no operator << defined for vectors.

>I most definitely wouldn't want to repeat all this formatting every time I
>need to output my vector.

If you want [ a, b, c, d ] style output, you don't. The extra machinery is
used to customize this. Also, you can save a format object, e.g.:

   // old style
   containerfmt_t< char, pairfmt_t< char > >
      myformat = containerfmt( pairfmt().format( " = " )).format( "<< ", "
>>" );

   std::cout << formatob( vec, myformat ); // << ( a = 5 ), ( b = 7 ), ...
   std::cout << formatob( lst, myformat ); // << ( i = 2.132 ), ( j =
3.14159 ), ... >>
   std::cin >> formatob( vec, myformat );

>If I write output operation rarely - I would use explicit loop -it's more
>flexible anyway.

Depends what you are outputting. If the type contains nested containers, it
can be more complex.

>I wouldn't use this library for filtering - we will have iostreams library
>for that (If I am not mistaken).

This library does not provide filtering capabilities. What I was saying is
that if you want to pretty print the data, it might be worth using
Jonathan's library.

>I wouldn't use this library for XML printing - why would I want to mention
>tag name twice?

You can use a wrapper format object:

   std::cout << formatob( vec, containerfmt( wrappedfmt().format( "<e>",
"</e>" )).format( "<l>", "</l>" )); // output: <l><e>a</e><e>b</e></l>


Want to block unwanted pop-ups? Download the free MSN Toolbar now!

Boost list run by bdawes at, gregod at, cpdaniel at, john at