Boost-Graph
view release on metacpan or search on metacpan
include/boost/iostreams/chain.hpp view on Meta::CPAN
flags_(f_auto_close)
{ }
~chain_impl() { try { close(); reset(); } catch (std::exception&) { } }
void close()
{
if ((flags_ & f_open) != 0) {
stream_buffer< basic_null_device<Ch, Mode> > null;
if ((flags_ & f_complete) == 0) {
null.open(basic_null_device<Ch, Mode>());
set_next(links_.back(), &null);
}
links_.front()->BOOST_IOSTREAMS_PUBSYNC();
if (is_convertible<Mode, input>::value)
std::for_each( links_.rbegin(), links_.rend(),
closer(BOOST_IOS::in) );
if (is_convertible<Mode, output>::value)
std::for_each( links_.begin(), links_.end(),
closer(BOOST_IOS::out) );
flags_ &= ~f_open;
}
}
void reset()
{
typedef typename list_type::iterator iterator;
for ( iterator first = links_.begin(),
last = links_.end();
first != last;
++first )
{
if ( (flags_ & f_complete) == 0 ||
(flags_ & f_auto_close) == 0 )
{
set_auto_close(*first, false);
}
streambuf_type* buf = 0;
std::swap(buf, *first);
delete buf;
}
links_.clear();
flags_ &= ~f_complete;
flags_ &= ~f_open;
}
list_type links_;
client_type* client_;
int device_buffer_size_,
filter_buffer_size_,
pback_size_;
int flags_;
};
friend struct chain_impl;
//----------Member data---------------------------------------------------//
private:
shared_ptr<chain_impl> pimpl_;
};
} // End namespace detail.
//
// Macro: BOOST_IOSTREAMS_DECL_CHAIN(name, category)
// Description: Defines a template derived from chain_base appropriate for a
// particular i/o category. The template has the following parameters:
// Ch - The character type.
// Tr - The character traits type.
// Alloc - The allocator type.
// Macro parameters:
// name_ - The name of the template to be defined.
// category_ - The i/o category of the template to be defined.
//
#define BOOST_IOSTREAMS_DECL_CHAIN(name_, default_char_) \
template< typename Mode, typename Ch = default_char_, \
typename Tr = BOOST_IOSTREAMS_CHAR_TRAITS(Ch), \
typename Alloc = std::allocator<Ch> > \
class name_ : public boost::iostreams::detail::chain_base< \
name_<Mode, Ch, Tr, Alloc>, \
Ch, Tr, Alloc, Mode \
> \
{ \
public: \
struct category : device_tag, Mode { }; \
typedef Mode mode; \
private: \
typedef boost::iostreams::detail::chain_base< \
name_<Mode, Ch, Tr, Alloc>, \
Ch, Tr, Alloc, Mode \
> base_type; \
public: \
typedef Ch char_type; \
typedef Tr traits_type; \
typedef typename traits_type::int_type int_type; \
typedef typename traits_type::off_type off_type; \
name_() { } \
name_(const name_& rhs) { *this = rhs; } \
name_& operator=(const name_& rhs) \
{ base_type::operator=(rhs); return *this; } \
}; \
/**/
BOOST_IOSTREAMS_DECL_CHAIN(chain, char)
BOOST_IOSTREAMS_DECL_CHAIN(wchain, wchar_t)
#undef BOOST_IOSTREAMS_DECL_CHAIN
//--------------Definition of chain_client------------------------------------//
namespace detail {
//
// Template name: chain_client
// Description: Class whose instances provide access to an underlying chain
// using an interface similar to the chains.
// Subclasses: the various stream and stream buffer templates.
//
template<typename Chain>
class chain_client {
public:
typedef Chain chain_type;
typedef typename chain_type::char_type char_type;
typedef typename chain_type::traits_type traits_type;
typedef typename chain_type::size_type size_type;
typedef typename chain_type::mode mode;
chain_client(chain_type* chn = 0) : chain_(chn ) { }
chain_client(chain_client* client) : chain_(client->chain_) { }
virtual ~chain_client() { }
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1310)
template<int N>
( run in 0.701 second using v1.01-cache-2.11-cpan-39bf76dae61 )