/usr/include/boost/iostreams
Edit: /usr/include/boost/iostreams/traits.hpp (11846B)
// (C) Copyright 2008 CodeRage, LLC (turkanis at coderage dot com)
// (C) Copyright 2003-2007 Jonathan Turkanis
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
// See http://www.boost.org/libs/iostreams for documentation.
//
// Contains metafunctions char_type_of, category_of and mode_of used for
// deducing the i/o category and i/o mode of a model of Filter or Device.
//
// Also contains several utility metafunctions, functions and macros.
//
#ifndef BOOST_IOSTREAMS_IO_TRAITS_HPP_INCLUDED
#define BOOST_IOSTREAMS_IO_TRAITS_HPP_INCLUDED
#if defined(_MSC_VER)
# pragma once
#endif
#include
// stream types, char_traits.
#include // partial spec, deduced typename.
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
// Must come last.
#include
namespace boost { namespace iostreams {
//----------Definitions of predicates for streams and stream buffers----------//
#ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------------------//
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_istream, std::basic_istream, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_ostream, std::basic_ostream, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_iostream, std::basic_iostream, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_streambuf, std::basic_streambuf, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_ifstream, std::basic_ifstream, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_ofstream, std::basic_ofstream, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_fstream, std::basic_fstream, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_filebuf, std::basic_filebuf, 2)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_istringstream, std::basic_istringstream, 3)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_ostringstream, std::basic_ostringstream, 3)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_stringstream, std::basic_stringstream, 3)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_stringbuf, std::basic_stringbuf, 3)
#else // #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-----------------------//
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_istream, std::istream, 0)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_ostream, std::ostream, 0)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_iostream, std::iostream, 0)
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_streambuf, std::streambuf, 0)
#endif // #ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //----------------------//
template
struct is_std_io
: mpl::or_< is_istream, is_ostream, is_streambuf >
{ };
template
struct is_std_file_device
: mpl::or_<
is_ifstream,
is_ofstream,
is_fstream,
is_filebuf
>
{ };
template
struct is_std_string_device
: mpl::or_<
is_istringstream,
is_ostringstream,
is_stringstream,
is_stringbuf
>
{ };
template
struct stream;
template
class stream_buffer;
template< typename Mode, typename Ch, typename Tr,
typename Alloc, typename Access >
class filtering_stream;
template< typename Mode, typename Ch, typename Tr,
typename Alloc, typename Access >
class wfiltering_stream;
template< typename Mode, typename Ch, typename Tr,
typename Alloc, typename Access >
class filtering_streambuf;
template< typename Mode, typename Ch, typename Tr,
typename Alloc, typename Access >
class filtering_wstreambuf;
namespace detail {
template
class linked_streambuf;
BOOST_IOSTREAMS_BOOL_TRAIT_DEF( is_boost_stream,
boost::iostreams::stream,
3 )
BOOST_IOSTREAMS_BOOL_TRAIT_DEF( is_boost_stream_buffer,
boost::iostreams::stream_buffer,
4 )
BOOST_IOSTREAMS_BOOL_TRAIT_DEF( is_filtering_stream_impl,
boost::iostreams::filtering_stream,
5 )
BOOST_IOSTREAMS_BOOL_TRAIT_DEF( is_filtering_wstream_impl,
boost::iostreams::wfiltering_stream,
5 )
BOOST_IOSTREAMS_BOOL_TRAIT_DEF( is_filtering_streambuf_impl,
boost::iostreams::filtering_streambuf,
5 )
BOOST_IOSTREAMS_BOOL_TRAIT_DEF( is_filtering_wstreambuf_impl,
boost::iostreams::filtering_wstreambuf,
5 )
BOOST_IOSTREAMS_BOOL_TRAIT_DEF(is_linked, linked_streambuf, 2)
template
struct is_filtering_stream
: mpl::or_<
is_filtering_stream_impl,
is_filtering_wstream_impl
>
{ };
template
struct is_filtering_streambuf
: mpl::or_<
is_filtering_streambuf_impl,
is_filtering_wstreambuf_impl
>
{ };
template
struct is_boost
: mpl::or_<
is_boost_stream,
is_boost_stream_buffer,
is_filtering_stream,
is_filtering_streambuf
>
{ };
} // End namespace detail.
//------------------Definitions of char_type_of-------------------------------//
namespace detail {
template
struct member_char_type { typedef typename T::char_type type; };
} // End namespace detail.
# ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //-------------------------------//
template
struct char_type_of
: detail::member_char_type<
typename detail::unwrapped_type::type
>
{ };
# else // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //---------------------//
template
struct char_type_of {
typedef typename detail::unwrapped_type::type U;
typedef typename
mpl::eval_if<
is_std_io,
mpl::identity,
detail::member_char_type
>::type type;
};
# endif // # ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES //--------------------//
template
struct char_type_of< iterator_range > {
typedef typename iterator_value::type type;
};
//------------------Definitions of category_of--------------------------------//
namespace detail {
template
struct member_category { typedef typename T::category type; };
} // End namespace detail.
template
struct category_of {
template
struct member_category {
typedef typename U::category type;
};
typedef typename detail::unwrapped_type::type U;
typedef typename
mpl::eval_if<
mpl::and_<
is_std_io,
mpl::not_< detail::is_boost >
>,
iostreams::select< // Disambiguation for Tru64
is_filebuf, filebuf_tag,
is_ifstream, ifstream_tag,
is_ofstream, ofstream_tag,
is_fstream, fstream_tag,
is_stringbuf, stringbuf_tag,
is_istringstream, istringstream_tag,
is_ostringstream, ostringstream_tag,
is_stringstream, stringstream_tag,
is_streambuf, generic_streambuf_tag,
is_iostream, generic_iostream_tag,
is_istream, generic_istream_tag,
is_ostream, generic_ostream_tag
>,
detail::member_category
>::type type;
};
// Partial specialization for reference wrappers
template
struct category_of< reference_wrapper >
: category_of
{ };
//------------------Definition of get_category--------------------------------//
//
// Returns an object of type category_of::type.
//
template
inline typename category_of::type get_category(const T&)
{ typedef typename category_of::type category; return category(); }
//------------------Definition of int_type_of---------------------------------//
template
struct int_type_of {
#ifndef BOOST_IOSTREAMS_NO_STREAM_TEMPLATES
typedef std::char_traits<
BOOST_DEDUCED_TYPENAME char_type_of::type
> traits_type;
typedef typename traits_type::int_type type;
#else
typedef int type;
#endif
};
//------------------Definition of mode_of-------------------------------------//
namespace detail {
template struct io_mode_impl;
#define BOOST_IOSTREAMS_MODE_HELPER(tag_, id_) \
case_ io_mode_impl_helper(tag_); \
template<> struct io_mode_impl { typedef tag_ type; }; \
/**/
BOOST_IOSTREAMS_MODE_HELPER(input, 1)
BOOST_IOSTREAMS_MODE_HELPER(output, 2)
BOOST_IOSTREAMS_MODE_HELPER(bidirectional, 3)
BOOST_IOSTREAMS_MODE_HELPER(input_seekable, 4)
BOOST_IOSTREAMS_MODE_HELPER(output_seekable, 5)
BOOST_IOSTREAMS_MODE_HELPER(seekable, 6)
BOOST_IOSTREAMS_MODE_HELPER(dual_seekable, 7)
BOOST_IOSTREAMS_MODE_HELPER(bidirectional_seekable, 8)
BOOST_IOSTREAMS_MODE_HELPER(dual_use, 9)
#undef BOOST_IOSTREAMS_MODE_HELPER
template
struct io_mode_id {
typedef typename category_of::type category;
BOOST_SELECT_BY_SIZE(int, value, detail::io_mode_impl_helper(category()));
};
} // End namespace detail.
template // Borland 5.6.4 requires this circumlocution.
struct mode_of : detail::io_mode_impl< detail::io_mode_id::value > { };
// Partial specialization for reference wrappers
template
struct mode_of< reference_wrapper >
: mode_of
{ };
//------------------Definition of is_device, is_filter and is_direct----------//
namespace detail {
template
struct has_trait_impl {
typedef typename category_of::type category;
BOOST_STATIC_CONSTANT(bool, value = (is_convertible::value));
};
template
struct has_trait
: mpl::bool_::value>
{ };
} // End namespace detail.
template
struct is_device : detail::has_trait { };
template
struct is_filter : detail::has_trait { };
template
struct is_direct : detail::has_trait { };
//------------------Definition of BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS----------//
#define BOOST_IOSTREAMS_STREAMBUF_TYPEDEFS(Tr) \
typedef Tr traits_type; \
typedef typename traits_type::int_type int_type; \
typedef typename traits_type::off_type off_type; \
typedef typename traits_type::pos_type pos_type; \
/**/
} } // End namespaces iostreams, boost.
#include
#endif // #ifndef BOOST_IOSTREAMS_IO_TRAITS_HPP_INCLUDED