User's Guide

3.1 Concepts

Overview
Device Concepts
Filter Concepts
Optional Behavior
Convenience Templates and typedefs

The fundamental building blocks of the Iostreams library are the concepts of a Source, which provides read access to a sequence of characters, a Sink, which provides write access to a sequence of characters, an InputFilter, which Filters input read from a Source, and an OutputFilter, which Filters output written to a Sink. Sources, Sinks and their refinements are called Devices. InputFilters, OutputFilter and their refinements are called Filters.

Standard streams and stream buffers are Devices; for example, input streams are Sources and output streams are Sinks.[1]

In general, a Filter or Device may provide access to an input sequence, for reading, an output sequence, for writing, or both. The relationship between the two sequences, as well as the operations that may be performed on them, depends on the Filter or Device type. The various possible relationships between input and output are referred to as modes.[2] The Iostreams library provides one Device concept and one Filter concept for each of eight modes. Source, Sink, InputFilter and OutputFilter correspond to the the modes input and output and are by far the most important of the Filter and Device concepts.

The most common Device and Filter concepts are documented individually. Readers new to the Iostreams library should familiarize themselves with the four central concepts Source, Sink, InputFilter and OutputFilter. The full sets of requirements for the Filter and Device concepts are summarized in the definitions of the concepts Device and Filter which form the roots of the concept hierarchies.

To ease the task of defining new Filter and Device types, the Iostreams library provides a number of convenience templates and typedefs.

Device Concepts

The most important Device concepts are these:

Filter Concepts

The most important Filter concepts are these:

Optional Behavior

Boost.Iostreams prvides several concepts corresponding to optional behavior that a Filter or Device might implement:

Convenience Templates and typedefs

The Iostreams library provides several templates intended for derivation by user-defined Filter and Device types. They ease the task of defining Filters and Devices by providing member types and default implementations of several member functions.

The template device and its specializations source and sink help users define new Device types; the template filter and its specializations input_filter and output_filter help users define new Filter types; the template multichar_filter and its specializations multichar_input_filter and multichar_output_filter help users define new multichar Filter types. There are also wide-character versions of these templates, wdevice, wfilter and multichar_wfilter, as well as corresponding wide-character typedefs.


[1]For complete details, see mode_of.

[2]A more precise definition is given in Modes.