wrapping streams

Discussion in 'C++' started by Daniel Oberhoff, Feb 28, 2007.

  1. 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
     
    Daniel Oberhoff, Feb 28, 2007
    #1
    1. Advertising

  2. Daniel Oberhoff wrote:
    > 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
     
    John Harrison, Feb 28, 2007
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Pawel Banys
    Replies:
    1
    Views:
    496
    Joe Smith
    Jul 8, 2004
  2. Justin Weinberg

    Audio Streams from ASP.NET

    Justin Weinberg, Oct 14, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    355
    Justin Weinberg
    Oct 14, 2003
  3. Detlef Hüttenbach

    **Bug**: Handling Streams from within ashx handlers

    Detlef Hüttenbach, Jan 25, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    428
    Hermit Dave
    Jan 25, 2004
  4. =?Utf-8?B?Sm9obiBIb3BwZXI=?=

    streams and querystrings

    =?Utf-8?B?Sm9obiBIb3BwZXI=?=, Jan 21, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    415
    =?Utf-8?B?Sm9obiBIb3BwZXI=?=
    Jan 21, 2005
  5. Ryan Stewart

    Wrapping Piped Streams?

    Ryan Stewart, Jan 11, 2004, in forum: Java
    Replies:
    10
    Views:
    1,893
    Ryan Stewart
    Jan 11, 2004
Loading...

Share This Page