I/O Traits and Categories

Overview
Headers
Class template io_char
Class template io_category
Category Tags

Overview

The header <boost/iostreams/categories.hpp> contains category tags for classifying models of the various Filter and Device concepts. The header <boost/iostreams/traits.hpp> contains the definitions of the metafunctions io_char and category, used to associate two fundamental types with each model of one the Filter or Device concepts:

Character Type

The type of characters which a Filter or Device reads or writes.

Category

A tag structure which the Iostreams Library relies on to determine which operations a Filter or Device supports. It indicates, for a given type T:

Its function is similar to the iterator_category member of std::iterator_traits.[1] Types which serve as categories are called category tags.

Headers

<boost/iostreams/categories.hpp>
<boost/iostreams/traits.hpp>

Class Template io_char

Description

Metafunction associating a character type to each Filter or Device type. Although io_char is designed to be specialized for new Filter and Device types, the default implementation should be suitable for most purposes.

Synopsis

namespace boost { namespace iostreams {

template<typename T>
struct io_char {
    typedef see below type;
};

} } // End namespace boost::io

Template parameters

T- A model of one of the Filter or Device concepts, or a standard stream or stream buffer

io_traits::type

    typedef see below char_type;

The value of the nested type type depends on the template parameter T as follows:

Tchar_type
Sepcialization of std::back_insert_iterator The value_type of the iterator's container_type
All other types T::char_type

Class Template io_category

Description

Metafunction associating a category tag to each Filter or Device type. Although category is designed to be specialized for new Filter and Device types, the default implementation should be suitable for most purposes.

Synopsis

namespace boost { namespace iostreams {

template<typename T>
struct io_category {
    typedef see below type;
};

} } // End namespace boost::io

Template parameters

T- A model of one of the Filter or Device concepts, or a standard stream or stream buffer

category::type

    typedef see below type;

The value of the nested type type depends on the template parameter T as follows:

Tio_category
Specialization of std::basic_iostream, or derived from such a specialization iostream_tag
Specialization of std::basic_istream, or derived from such a specialization istream_tag
Specialization of std::basic_ostream, or derived from such a specialization ostream_tag
Specialization of std::basic_streambuf, or derived from such a specialization streambuf_tag
Specialization of std::back_insert_iterator, or derived from such a specialization insert_iterator_tag
All other types T::category

For more information, see <boost/iostreams/traits.hpp>.

Category Tags

In addition to the various mode tags, the header <boost/iostreams/categories.hpp> provides the category tags shown in the following table. To produce a new category tag which combines several existing tags, simply define a struct extending the existing tags. E.g.,

    struct io_category
        : seekable,
          filter_tag, 
          localizable_tag 
        { };
This defines a category tag representing Seekable, Localizable Filters.

TagDescription
filter_tag Indicates that a type models Filter
device_tag Indicates that a type models Device
closable_tag
localizable_tag
direct_tag
peekable_tag
multichar_tag
Used to indicate optional behavior implemented by a Filter or Device type
source_tag
sink_tag
bidirectional_device_tag
seekable_device_tag
input_filter_tag
output_filter_tag
bidirectional_filter_tag
seekable_filter_tag
multichar_input_filter_tag
multichar_output_filter_tag
multichar_bidirectional_filter_tag
multichar_seekable_filter_tag
Convenience tags for defining models of the various Filter and Device refinements
istream_tag
ostream_tag
iostream_tag
streambuf_tag
Used internally to distinguish standard stream and stream buffer types
insert_iterator_tag Used internally to distinguish specialization of std::back_insert_iterator

[1][ISO] 24.3.1. See Tag Dispatching for a discussion.