|
Boost : |
From: John Maddock (john_at_[hidden])
Date: 2005-04-23 04:43:17
> OTOH, since the first release I've felt the weakest elements of the
> library
> have been the handling of local times and i/o. It took a long time for me
> to
> see 'the light' on i/o. The first implementations of streaming facets
> were
> just too clunky and were too hard for users to use and extend. And the
> bottom
> line is that every project/person/standard has their own format for
> date-time
> i/o -- it's impossible to standardize what users want here. Luckily last
> summer Martin Andrian showed me the light with a partial implementation of
> a
> 'format string' based i/o facet (basically you can write:
> date_facet->format("%Y-%b-%d") to reset the format of a date in a stream).
> This approach solved a long standing issue on my standardization todo
> list -->
> how does i/o fit in with the existing format string concepts in the
> standard
> lib. Not to mention that it is almost infinately flexible in terms of how
> the
> various types can be streamed. This code will be the standard i/o facet
> in
> the 1.33 release.
Jeff, do you mind if I throw a wildcard in here?
Why not drop facets altogether and use a stream format manipulator instead:
std::cout << set_date_format("%Y-%b-%d") << mydate << std::endl;
The format would be stored in the iostreams iword/pword (that's what they're
for).
You could still have a facet if you really wanted uses to change the
*algorithm* used for io, but I guess what I'm trying to say is that:
algorithms go in facets.
configuration data goes in the iostream object itself.
Just my 2c worth,
Hope this doesn't cloud things up to much!
John.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk