|
Boost Users : |
From: Pedro Lamarão (pedro.lamarao_at_[hidden])
Date: 2006-01-24 14:31:04
Here follows a simple pattern to use Boost.IOstreams with your
non-copyable Device, allowing you quick access to formatted input and
output:
#include <boost/iostreams/stream.hpp>
#include <boost/ref.hpp>
#include "foo_device.hpp"
/* Don't; just to make lines shorter. */
using boost::iostreams;
using boost;
class foo_device;
class foo_stream_base {
public:
/* Define constructor forwarding to foo_device. */
foo_stream_base (...) : _M_device(...) {}
protected:
foo_device _M_device;
};
class foo_stream : private foo_stream_base,
public stream<reference_wrapper<foo_device> > {
public:
/* Define constructor forwarding to foo_device. */
foo_stream (...)
: foo_stream_base(...),
stream<reference_wrapper<foo_device> >(ref(_M_device)) {}
};
-- Pedro Lamarão Desenvolvimento Intersix Technologies S.A. SP: (55 11 3803-9300) RJ: (55 21 3852-3240) www.intersix.com.br Your Security is our Business
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net