1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/os/ossrv/ossrv_pub/boost_apis/boost/iostreams/pipeline.hpp Fri Jun 15 03:10:57 2012 +0200
1.3 @@ -0,0 +1,125 @@
1.4 +// (C) Copyright Jonathan Turkanis 2003.
1.5 +// Distributed under the Boost Software License, Version 1.0. (See accompanying
1.6 +// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt.)
1.7 +
1.8 +// See http://www.boost.org/libs/iostreams for documentation.
1.9 +
1.10 +#ifndef BOOST_IOSTREAMS_PIPABLE_HPP_INCLUDED
1.11 +#define BOOST_IOSTREAMS_PIPABLE_HPP_INCLUDED
1.12 +
1.13 +#if defined(_MSC_VER) && (_MSC_VER >= 1020)
1.14 +# pragma once
1.15 +#endif
1.16 +
1.17 +#include <boost/config.hpp> // BOOST_MSVC.
1.18 +#include <boost/detail/workaround.hpp>
1.19 +#include <boost/iostreams/detail/template_params.hpp>
1.20 +#include <boost/iostreams/traits.hpp>
1.21 +#include <boost/mpl/bool.hpp>
1.22 +#include <boost/preprocessor/punctuation/comma_if.hpp>
1.23 +#include <boost/preprocessor/repetition/enum_params.hpp>
1.24 +#include <boost/static_assert.hpp>
1.25 +#if BOOST_WORKAROUND(BOOST_MSVC, < 1300)
1.26 +# include <boost/type_traits/is_base_and_derived.hpp>
1.27 +#endif
1.28 +
1.29 +#define BOOST_IOSTREAMS_PIPABLE(filter, arity) \
1.30 + template< BOOST_PP_ENUM_PARAMS(arity, typename T) \
1.31 + BOOST_PP_COMMA_IF(arity) typename Component> \
1.32 + ::boost::iostreams::pipeline< \
1.33 + ::boost::iostreams::detail::pipeline_segment< \
1.34 + filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T) \
1.35 + >, \
1.36 + Component \
1.37 + > operator|( const filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T)& f, \
1.38 + const Component& c ) \
1.39 + { \
1.40 + typedef ::boost::iostreams::detail::pipeline_segment< \
1.41 + filter BOOST_IOSTREAMS_TEMPLATE_ARGS(arity, T) \
1.42 + > segment; \
1.43 + return ::boost::iostreams::pipeline<segment, Component> \
1.44 + (segment(f), c); \
1.45 + } \
1.46 + /**/
1.47 +
1.48 +namespace boost { namespace iostreams {
1.49 +
1.50 +template<typename Pipeline, typename Component>
1.51 +struct pipeline;
1.52 +
1.53 +namespace detail {
1.54 +
1.55 +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
1.56 + struct pipeline_base { };
1.57 +
1.58 + template<typename T>
1.59 + struct is_pipeline
1.60 + : is_base_and_derived<pipeline_base, T>
1.61 + { };
1.62 +#endif
1.63 +#if BOOST_WORKAROUND(__BORLANDC__, < 0x600)
1.64 + template<typename T>
1.65 + struct is_pipeline : mpl::false_ { };
1.66 +
1.67 + template<typename Pipeline, typename Component>
1.68 + struct is_pipeline< pipeline<Pipeline, Component> > : mpl::true_ { };
1.69 +#endif
1.70 +
1.71 +template<typename Component>
1.72 +class pipeline_segment
1.73 +#if BOOST_WORKAROUND(BOOST_MSVC, <= 1300)
1.74 + : pipeline_base
1.75 +#endif
1.76 +{
1.77 +public:
1.78 + pipeline_segment(const Component& component)
1.79 + : component_(component)
1.80 + { }
1.81 + template<typename Fn>
1.82 + void for_each(Fn fn) const { fn(component_); }
1.83 + template<typename Chain>
1.84 + void push(Chain& chn) const { chn.push(component_); }
1.85 +private:
1.86 + const Component& component_;
1.87 +};
1.88 +
1.89 +} // End namespace detail.
1.90 +
1.91 +//------------------Definition of Pipeline------------------------------------//
1.92 +
1.93 +template<typename Pipeline, typename Component>
1.94 +struct pipeline : Pipeline {
1.95 + typedef Pipeline pipeline_type;
1.96 + typedef Component component_type;
1.97 + pipeline(const Pipeline& p, const Component& component)
1.98 + : Pipeline(p), component_(component)
1.99 + { }
1.100 + template<typename Fn>
1.101 + void for_each(Fn fn) const
1.102 + {
1.103 + Pipeline::for_each(fn);
1.104 + fn(component_);
1.105 + }
1.106 + template<typename Chain>
1.107 + void push(Chain& chn) const
1.108 + {
1.109 + Pipeline::push(chn);
1.110 + chn.push(component_);
1.111 + }
1.112 + const Pipeline& tail() const { return *this; }
1.113 + const Component& head() const { return component_; }
1.114 +private:
1.115 + const Component& component_;
1.116 +};
1.117 +
1.118 +template<typename Pipeline, typename Filter, typename Component>
1.119 +pipeline<pipeline<Pipeline, Filter>, Component>
1.120 +operator|(const pipeline<Pipeline, Filter>& p, const Component& cmp)
1.121 +{
1.122 + BOOST_STATIC_ASSERT(is_filter<Filter>::value);
1.123 + return pipeline<pipeline<Pipeline, Filter>, Component>(p, cmp);
1.124 +}
1.125 +
1.126 +} } // End namespaces iostreams, boost.
1.127 +
1.128 +#endif // #ifndef BOOST_IOSTREAMS_PIPABLE_HPP_INCLUDED