Here follows a simple pattern to use Boost.IOstreams with your
non-copyable Device, allowing you quick access to formatted input and
output:
#include
#include
#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 > {
public:
/* Define constructor forwarding to foo_device. */
foo_stream (...)
: foo_stream_base(...),
stream >(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