From: Joe Mariadassou (JMariadassou_at_[hidden])
Date: 2001-02-15 20:35:31
> -----Original Message-----
> From: Murray, Peter C [mailto:Peter.Murray_at_[hidden]]
> Sent: Thursday, 15 February 2001 10:56 AM
> To: 'boost_at_[hidden]'
> Subject: [boost] Stream manipulators for compression, encryption, etc
> With regard to the disussions on compression, would a more
> elegant approach
> be to create some form of compressing stream manipulator? I
> admit that I am
> particularly weak on streams, so apologies if I am proposing something
> Conceptually, I'd like to do something like this:
> outfile << encrypt<DES> << compress<ZIP> << myClass;
> infile >> decrypt<DES> >> decompress<ZIP> >> myClass;
> What do people think of this approach, if its even possible?
> - Peter.
One solution would be like this
class CompressStream: public ostream
// some code
However the catch would be after excecuting
the compress stream adapter would be destroyed.
So a better solution would be something like this:
class CompressBuf: public streambuf
CompressBuf(streambuf& inbuf): buf(inbuf)
// other init code
//override overflow to compress the data before putting it into buf
which would be used as:
Of course you can cascade streams like this:
This should compress Mydata and convert it base64 and put it to ofs;
Developing in VC++ I must caution:
puts only one character (0xa) which is not quite what I expected.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk