wrapping streams

D

Daniel Oberhoff

Hello all,

I am writing a util framework to operate on matlab mat files because I
don't want to link to matlab for this and I didn't like the available
c-implementation. also i wanted to use blitz++ as the matrix
representation.

now I want to add compression support so I got a nice stl zlib iostream
wrapper from the code project, but it doesn't work. before I dive into
the gory details of debugging i wanted to check if maybe I got the
iostream concept wrong.

what I do is when I encounter a header indicating zipped data I wrap the
zistream around my fstream like this:

zistream * unzipper = new zistream(myfstream);

at this point fstream.tellg() should point to the first zipped byte and
the zistream should take it from there. now I am wondering if it is
actualy possible to wrap streams like this, "on demand", and if also
alter it is ok to do

delete unzipper;

after the zipped block is exhausted (I know how many bytes to expect)
and keep on reading from myfstream?

the zistream class, as I understand, is implemented the STL way by
reimplementing the relevant streambuf class.

Daniel
 
J

John Harrison

Daniel said:
Hello all,

I am writing a util framework to operate on matlab mat files because I
don't want to link to matlab for this and I didn't like the available
c-implementation. also i wanted to use blitz++ as the matrix
representation.

now I want to add compression support so I got a nice stl zlib iostream
wrapper from the code project, but it doesn't work. before I dive into
the gory details of debugging i wanted to check if maybe I got the
iostream concept wrong.

what I do is when I encounter a header indicating zipped data I wrap the
zistream around my fstream like this:

zistream * unzipper = new zistream(myfstream);

at this point fstream.tellg() should point to the first zipped byte and
the zistream should take it from there. now I am wondering if it is
actualy possible to wrap streams like this, "on demand", and if also
alter it is ok to do

delete unzipper;

after the zipped block is exhausted (I know how many bytes to expect)
and keep on reading from myfstream?

the zistream class, as I understand, is implemented the STL way by
reimplementing the relevant streambuf class.

Daniel

Doesn't it all depend on how the zistream class has be written?
Everything you say seems OK to me, I can't think why it wouldn't work,
but I didn't write zistream.

It's certainly possible to wrap streams, it's a logical way to implement
a compressed stream.

john
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top