Looking for robust gzip streambuf class

M

mathieu

Hello,

Browsing the archive of this group I see that the c++ iostream
wrapper that are shipped with zlib are not satisfying :

http://groups.google.com/group/comp.lang.c++/msg/b2a2dcda4989879c?dmode=source

Has anyone found a good implementation of a gzip (input+output)
std::streambuf class ?

I found one that would work on internet in a polish forum:

http://forum.idg.pl/index.php?showtopic=72330

Since I do not speak polish I am not sure if I can use that code or
not ?

Thanks
-Mathieu
Ps: I'll also be looking for a iostream wrapper above socket later
on...
 
V

Victor Bazarov

mathieu said:
Browsing the archive of this group I see that the c++ iostream
wrapper that are shipped with zlib are not satisfying :


http://groups.google.com/group/comp.lang.c++/msg/b2a2dcda4989879c?dmode=source

Has anyone found a good implementation of a gzip (input+output)
std::streambuf class ?

There is 'comp.compression' newsgroup, why don't you ask them?
I found one that would work on internet in a polish forum:

http://forum.idg.pl/index.php?showtopic=72330

Since I do not speak polish I am not sure if I can use that code or
not ?

Use it. Refer to where you found it, and use it.
Thanks
-Mathieu
Ps: I'll also be looking for a iostream wrapper above socket later
on...

<sigh> This is not really a group to share solutions for specific
problems, not related to C++ language itself. Try google (not the
archives) for that.

The Polish forum you found has the source code. Why don't you just
read the code to figure out what it's doing and how to use it? The
message with the code essentially asks the same question: "Can someone
tell me what the code is for? I tried reading an archive, but ended
up with an error bit set and number of bytes read 0, should be >0".

V
 
A

Alexandre Farias

It's a bit offtopic, but, perhaps you should take a look at
Boost.Iostreams [www.boost.org]

Quote from the description of the library:
"For example, Boost.Iostreams can be used to create streams to access
TCP connections or as a framework for cryptography and data
compression. The library includes components for accessing memory-
mapped files, for file access using operating system file descriptors,
for code conversion, for text filtering with regular expressions, for
line-ending conversion and for compression and decompression in the
zlib, gzip and bzip2 formats."

Alexandre Farias
 
M

mathieu

There is 'comp.compression' newsgroup, why don't you ask them?

Using gzip/zlib is the easy part. I was struggling on the C++
std::streambuf part. This is AFAIK a very difficult concept to grasp.
Or I haven't been able to find good documentation on how to subclass a
std::streambuf... I used :

http://www.cplusplus.com/reference/iostream/streambuf/
Use it. Refer to where you found it, and use it.

That's what I did :

http://gdcm.svn.sourceforge.net/viewvc/gdcm/trunk/Source/Common/gdcmDeflateStream.h

It worked in some cases, and failed in some other...
<sigh> This is not really a group to share solutions for specific
problems, not related to C++ language itself. Try google (not the
archives) for that.

Again, this is specifically c++: how to derive a std::streambuf. As I
have said in my previous post, solution provided in the zlib/contrib
are not considered correct. Thus my question: has anyone done it the
correct way ?
The Polish forum you found has the source code. Why don't you just
read the code to figure out what it's doing and how to use it? The
message with the code essentially asks the same question: "Can someone
tell me what the code is for? I tried reading an archive, but ended
up with an error bit set and number of bytes read 0, should be >0".

Thanks :)

-Mathieu
 
M

mathieu

It's a bit offtopic, but, perhaps you should take a look at
Boost.Iostreams [www.boost.org]

Quote from the description of the library:
"For example, Boost.Iostreams can be used to create streams to access
TCP connections or as a framework for cryptography and data
compression. The library includes components for accessing memory-
mapped files, for file access using operating system file descriptors,
for code conversion, for text filtering with regular expressions, for
line-ending conversion and for compression and decompression in the
zlib, gzip and bzip2 formats."

That's pretty cool ! I should have first check this library, I knew
this was something so obvious someone must had implemented it.

Thanks a bunch !
-Mathieu
 
J

James Kanze

There is 'comp.compression' newsgroup, why don't you ask them?
Use it. Refer to where you found it, and use it.

Sounds a bit dangerous, in a way, if he can't read and
understand the copyright, to be sure he has a right to.
 
J

James Kanze

[...]
Using gzip/zlib is the easy part. I was struggling on the C++
std::streambuf part. This is AFAIK a very difficult concept to grasp.

Not at all. See the articles at
http://kanze.james.neuf.fr/articles-en.html for an explination
of some simple cases.

In the simplest case, all you have to do is override underflow()
for input, and overflow() for output. (Note that this requires
at least a one byte buffer for input.) Supporting seek or
buffering requires a bit more; you probably don't want to
support seeking (I don't see how you could), but buffering might
be useful.
Or I haven't been able to find good documentation on how to
subclass a std::streambuf... I used :

That article doesn't seem to do much more than list the
functions in the class.

[...]
Again, this is specifically c++: how to derive a std::streambuf. As I
have said in my previous post, solution provided in the zlib/contrib
are not considered correct. Thus my question: has anyone done it the
correct way ?

Boost? The boost::iostream package is very well done, and even
if they don't have a zlib implementation directly available, it
should be easy to create one using their adapters.
 

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,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top