Format Lite

Disclaimer

Not a Boost library.

Overview

Format Lite is a lightweight, easy-to-learn framework for formatting data structures such as standard library containers and Boost tuples. It provides a reasonable degree of customizability with an emphasis on human-readable output formats useful for testing and debugging.

A future version of Format Lite could be a candidate for incorporation into C++0x, to compensate for the lack of standard iostreams inserters and extractors for standard library containers, and to make existing inserters and extractors — such as those provided in <complex> — more flexible.

Format lite provides three function templates:

Headers

<boost/iostreams/format_lite.hpp>

Portability

The implementation of Format Lite uses class template partial specialization, template template parameters and SFINAE. It is therefore supported only by reasonably conformant compilers.

Format Lite contains nine regression tests and a Jamfile in the directory <libs/format_lite/test>. The tests have been run on the following platforms:

PlatformPassed
Microsoft Visual C++ 7.1100%
GCC 3.2 (MinGW)100%
Intel 8.0 for Windows100%

Acknowledgments


[1]The latter two function templates are defined in namespace std. This results in undefined behavior according to 17.4.3.1 of the C++ standard, but helps to keep the library simple and easy to learn and is essential if Format Lite is to serve as the basis for a standard library proposal. While the behavior is strictly-speaking undefined, in practice these operators behave as intended.

One way to avoid introducing declarations into namespace std would be to add a fourth user-level function boost::io::format and to replace invocations of the form out << x and in >> x with out << boost::io::format(x) and in >> boost::io::format(x). This is the approach taken by Reece Dunne's recently reviewed Output Formatters library.


Sha'arei Tefila, an Orthodox Shul (Synagogue) in Salt Lake City, Utah Chabad Lubavitch of Utah