mirror of
https://github.com/boostorg/iostreams.git
synced 2026-02-22 03:22:24 +00:00
174 lines
10 KiB
HTML
Executable File
174 lines
10 KiB
HTML
Executable File
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<TITLE>Concepts</TITLE>
|
|
<LINK REL="stylesheet" HREF="../../../boost.css">
|
|
<LINK REL="stylesheet" HREF="theme/iostreams.css">
|
|
</HEAD>
|
|
<BODY>
|
|
|
|
<!-- Begin Banner -->
|
|
|
|
<H1 CLASS="title">Concepts</H1>
|
|
<HR CLASS="banner">
|
|
|
|
<!-- End Banner -->
|
|
|
|
<DL class="page-index">
|
|
<DT><A href="#overview">Overview</A></DT>
|
|
<DT><A href="#device_concepts">Device Concepts</A></DT>
|
|
<DT><A href="#filter_concepts">Filter Concepts</A></DT>
|
|
<DT><A href="#optional_behavior">Optional Behavior</A></DT>
|
|
<DT><A href="#convenience">Convenience Templates and <CODE>typedef</CODE>s</A></DT>
|
|
</DL>
|
|
|
|
<HR>
|
|
|
|
<A NAME="overview"></A>
|
|
<H2>Overview</H2>
|
|
|
|
<P>
|
|
The fundamental building blocks of the Iostreams Library are the concepts of a <A HREF="concepts/source.html">Source</A>, which provides read access to a sequence of characters, a <A HREF="concepts/sink.html">Sink</A>, which provides write access to a sequence of characters, an <A HREF="concepts/input_filter.html">InputFilter</A>, which Filters input read from a Source, and an <A HREF="concepts/output_filter.html">OutputFilter</A>, which Filters output written to a Sink. Sources, Sinks and their refinements are called <SPAN CLASS="term">Devices</SPAN>. InputFilters, OutputFilter and their refinements are called <SPAN CLASS="term">Filters</SPAN>.
|
|
</P>
|
|
<P>
|
|
In general, a Filter or Device may provide access to an <SPAN>input sequence</SPAN>, for reading, an <SPAN>output sequence</SPAN>, 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 <A HREF="modes.html">modes</A>.<SUP><A CLASS="footnote_ref" NAME="note_1_ref" HREF="#note_1">[1]</A></SUP> 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 <A HREF="modes.html#input">input</A> and <A HREF="modes.html#output">output</A> and are by far the most important of the Filter and Device concepts.
|
|
</P>
|
|
<P>
|
|
The most common Device and Filter concepts are documented individually. Readers new to the Iostreams Library should familiarize themselves with the four central concepts <A HREF="concepts/source.html">Source</A>, <A HREF="concepts/sink.html">Sink</A>, <A HREF="concepts/input_filter.html">InputFilter</A> and <A HREF="concepts/output_filter.html">OutputFilter</A>. The full sets of requirements for the Filter and Device concepts are summarized in the definitions of the concepts <A HREF="concepts/device.html">Device</A> and <A HREF="concepts/filter.html">Filter</A> which form the roots of the concept hierarchies.
|
|
</P>
|
|
<P>
|
|
To ease the task of defining new Filter and Device types, the Iostreams Library provides a number of <A HREF="#convenience">convenience templates and <CODE>typedef</CODE>s</A>.
|
|
</P>
|
|
|
|
<A NAME="device_concepts"></A>
|
|
<H2>Device Concepts</H2>
|
|
|
|
<UL>
|
|
<LI><A STYLE="font-weight:normal" HREF="concepts/device.html">Device:</A> Base for all Device concepts, provides associated character type and category.
|
|
<LI><A STYLE="font-weight:normal" HREF="concepts/source.html">Source:</A> Provides read-only access to a sequence of characters.
|
|
<LI><A STYLE="font-weight:normal" HREF="concepts/sink.html">Sink:</A> Provides write-only access to a sequence of characters.
|
|
<LI><A STYLE="font-weight:normal" HREF="concepts/bidirectional_device.html">Bidirectionaldevice:</A> Provides access to two separate sequences of characters, one for reading and the other for writing.
|
|
<LI><A STYLE="font-weight:normal" HREF="concepts/seekable_device.html">SeekableDevice:</A> Provides read-write access to a single sequence of characters, with a single repositionable read/write head.
|
|
</UL>
|
|
|
|
<A NAME="filter_concepts"></A>
|
|
<H2>Filter Concepts</H2>
|
|
|
|
<UL>
|
|
<LI><A STYLE="font-weight:normal" HREF="concepts/filter.html">Filter:</A> Base for all Filter concepts, provides associated character type and category.
|
|
<LI><A HREF="concepts/input_filter.html">InputFilter:</A> Filters characters read from a stream buffer.
|
|
<LI><A HREF="concepts/output_filter.html">OutputFilter:</A> Filters characters written to a stream buffer.
|
|
<LI><A HREF="concepts/bidirectional_filter.html">BidirectionalFilter:</A> Filters two separate character sequences, one read from a stream buffer and the other written to a stream buffer.
|
|
<LI><A HREF="concepts/seekable_filter.html">SeekableFilter:</A> Filters a single characters sequence, controlled by a stream buffer,
|
|
providing filtered input, output and random access with a single repositionable read/write head
|
|
</UL>
|
|
|
|
<A NAME="optional_behavior"></A>
|
|
<H2>Optional Behavior</H2>
|
|
|
|
<UL>
|
|
<LI><A HREF="concepts/closable.html">Closable:</A> A Filter or Device which receives notifications immediately before a stream is closed.
|
|
<LI><A HREF="concepts/localizable.html">Localizable:</A> A Filter or Device which receives notifications when the <CODE>locale</CODE> of a stream or stream buffer is set using <CODE>basic_ios::imbue</CODE> or <CODE>basic_streambuf::pubimbue</CODE>.
|
|
<LI><A HREF="concepts/direct.html">Direct:</A> A Device which provides access to its controlled sequences as regions of memory rather than <I>via</I> a socket-like interface.
|
|
<LI><A HREF="concepts/peekable.html">Peekable:</A> A source which allows characters to be put back to the input sequence.
|
|
<LI><A HREF="concepts/multi-character.html">Multi-Character:</A> A Filter which provides access to its controlled sequences several characters at a time, <I>via</I> a socket-like interface.
|
|
</UL>
|
|
|
|
<A NAME="convenience"></A>
|
|
<H2>Convenience Templates and <CODE>typedef</CODE>s</H2>
|
|
|
|
<H4>Headers</H4>
|
|
|
|
<DL class="page-index">
|
|
<DT><A CLASS="header" HREF="../../../boost/iostreams/concepts.hpp"><CODE><boost/iostreams/concepts.hpp></CODE></A></DT>
|
|
</DL>
|
|
|
|
<H4>Overview</H4>
|
|
|
|
<P>
|
|
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 member functions.
|
|
</P>
|
|
<P>
|
|
The template <A href="classes/device.html"><CODE>device</CODE></A> and its specializations <A HREF="classes/device.html#source"><CODE>source</CODE></A> and <A HREF="classes/device.html#sink"><CODE>sink</CODE></A> help users define new Device types; the template <A href="classes/filter.html"><CODE>filter</CODE></A> and its specializations <A HREF="classes/filter.html#input_filter"><CODE>input_filter</CODE></A> and <A HREF="classes/filter.html#output_filter"><CODE>output_filter</CODE></A> help users define new Filter types; the template <A href="classes/multichar_filter.html"><CODE>multichar_filter</CODE></A> and its specializations <A HREF="classes/multichar_filter.html#multichar_input_filter"><CODE>multichar_input_filter</CODE></A> and <A HREF="classes/multichar_filter.html#multichar_output_filter"><CODE>multichar_output_filter</CODE></A> help users define new multichar Filter types. There are also wide-character versions of these templates, <A href="classes/device.html#wdevice"><CODE>wdevice</CODE></A>, <A href="classes/filter.html#wfilter"><CODE>wfilter</CODE></A> and <A href="classes/multichar_filter.html#multichar_wfilter"><CODE>multichar_wfilter</CODE></A>, as well as corresponding wide-character <CODE>typedef</CODE>s.
|
|
</P>
|
|
|
|
<H4>Reference</H4>
|
|
|
|
<DL class="page-index">
|
|
<DT><A href="classes/device.html">Class template <CODE>Device</CODE></A></DT>
|
|
<DT><A href="classes/filter.html">Class template <CODE>filter</CODE></A></DT>
|
|
<DT><A href="classes/multichar_filter.html">Class template <CODE>multichar_filter</CODE></A></DT>
|
|
</DL>
|
|
|
|
<!-- <PRE CLASS="broken_ie">template< typename Mode,
|
|
typename Ch = char,
|
|
typename Tr = std::char_traits<Ch> >
|
|
struct device;
|
|
|
|
template< typename Mode,
|
|
typename Ch = wchar_t,
|
|
typename Tr = std::char_traits<Ch> >
|
|
struct wdevice : device<Mode, Ch, Tr> { };
|
|
|
|
typedef device<input> source;
|
|
typedef device<output> sink;
|
|
typedef wdevice<input> wsource;
|
|
typedef wdevice<output> wsink;
|
|
|
|
template< typename Mode,
|
|
typename Ch = char,
|
|
typename Tr = std::char_traits<Ch> >
|
|
struct filter;
|
|
|
|
template< typename Mode,
|
|
typename Ch = wchar_t,
|
|
typename Tr = std::char_traits<Ch> >
|
|
struct wfilter : filter<Mode, Ch, Tr> { };
|
|
|
|
typedef filter<input> input_filter;
|
|
typedef filter<output> output_filter;
|
|
typedef wfilter<input> winput_filter;
|
|
typedef wfilter<output> woutput_filter;
|
|
|
|
template< typename Mode,
|
|
typename Ch = char,
|
|
typename Tr = std::char_traits<Ch> >
|
|
struct multichar_filter;
|
|
|
|
template< typename Mode,
|
|
typename Ch = wchar_t,
|
|
typename Tr = std::char_traits<Ch> >
|
|
struct wmultichar_filter : multichar_filter<Mode, Ch, Tr> { };
|
|
|
|
typedef multichar_filter<input> multichar_input_filter;
|
|
typedef multichar_filter<output> multichar_output_filter;
|
|
typedef wmultichar_filter<input> wmultichar_input_filter;
|
|
typedef wmultichar_filter<output> wmultichar_output_filter;</PRE> -->
|
|
|
|
<!-- Begin Footnotes -->
|
|
|
|
<HR>
|
|
|
|
<P>
|
|
<A CLASS="footnote_ref" NAME="note_1" HREF="#note_1_ref"><SUP>[1]</SUP></A>A more precise definition is given in <A HREF="modes.html">Modes</A>.
|
|
</P>
|
|
|
|
<!-- End Footnotes -->
|
|
|
|
<!-- Begin Footer -->
|
|
|
|
<HR>
|
|
<P CLASS="copyright">Revised
|
|
<!--webbot bot="Timestamp" S-Type="EDITED" S-Format="%d %B, %Y" startspan -->
|
|
20 May, 2004
|
|
<!--webbot bot="Timestamp" endspan i-checksum="38504" -->
|
|
</P>
|
|
|
|
<P CLASS="copyright">© Copyright Jonathan Turkanis, 2004</P>
|
|
<P CLASS="copyright">
|
|
Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at <A HREF="http://www.boost.org/LICENSE_1_0.txt">http://www.boost.org/LICENSE_1_0.txt</A>)
|
|
</P>
|
|
|
|
<!-- End Footer -->
|
|
|
|
</BODY> |