Examples

The Iostreams Library includes six example programs demonstrating the use of filtering streams. The first five depend only on Boost header files. The last depends on the Boost Regular Expression Library, which must be built separately (see here for details.) The examples compile and run correctly on all the platforms listed in Portability.

Tab-expanding OutputFilter.
Line-wrapping OutputFilter.
Presidential OutputFilter.
Uncommenting InputFilter.
Usenet InputFilter.
Regex OutputFilter.

Tab-expanding OutputFilter

This example uses an OutputFilter to replace each tab character in a code excerpt with an appropritate number of spaces. It is based on an example by James Kanze (see [Kanze]):

Line-wrapping OutputFilter

This example uses an OutputFilter to wrap text so that each line is no longer than a specified maximum value. No attention is paid to word boundaries. It is based on an example by James Kanze (see [Kanze]):

Presidential OutputFilter

This is an example of an OutputFilter which might be useful to U.S. government officials.

Uncommenting InputFilter

This example uses an InputFilter to remove shell-style comments. It is based on an example by James Kanze (see [Kanze]):

Usenet InputFilter

This example uses an InputFilter to expand common usenet abbreviations (see The Jargon File):

Regex OutputFilter

This example uses a regex_filter to remove C and C++-style comments from a code excerpt. Although somewhat more sophisticated than the Uncommenting InputFilter, above, the Filter in this example is not adequate for use in production code since it is not sensitive to quotation marks or line continuations.