Boost logo

Boost :

From: Karl Nelson (kenelson_at_[hidden])
Date: 2002-01-30 18:39:02


Okay, given the wide ranging discussion on formatting, I have
resubmitted my original format operator. (Thus placing the
code where my mouth is.)

  http://groups.yahoo.com/group/boost/files/format3/

It is a KISS design, it supports no functions beyond that
of streams other than truncation. It avoids feature creep.
If you want latex in C++ don't look here!

It uses open group printf format but can potentially
have an expanded format. It is not 100% printf compatible
because of course some features in printf have no corresponding
match in C++ streams. It has been improved (from my original)
to use wide charactors and traits.

Because most people have no liked use of an operator like << and %,
I have switched to a printf style for up to 9 arguments. Ie.

  cout << format("%s, %s %d, %d:%.2d\n", weekday, month, day, hour, min);

And of course arbitrary numbers

  cout << format("%s, %s %d, %d:%.2d\n")(weekday)(month)(day)(hour)(min);

It supports reordering... (for German translation say)

  cout << format( "%1$s, %3$d. %2$s, %4$d:%5$.2d\n",
      weekday, month, day, hour, min);

Documentation to be added after initial feedback.
test_format.cc demonstrates all of its basic use.

Some preformance improvements yet to come.

Feedback welcome!

--Karl


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